:root {
    --accent: #3ccb3c;
    --badge-w: 56px;
    --badge-h: 180px;
    --badge-top: 2rem;
    --badge-image-top: -2rem;
    --badge-image-h: 300px;
    --badge-art-w: 73px;
    --badge-art-right: -16px;
    /* sized to exactly fit the fixed badge + its left margin, so there's no leftover gap before the content */
    --spine-w: 74px;
    --content-peek: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Segoe UI", Tahoma, sans-serif;
    overflow: hidden;
}

body {
    color: #163a4d;
    background:
        radial-gradient(circle at 15% 15%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 20%),
        radial-gradient(circle at 85% 75%, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 22%),
        linear-gradient(180deg, #eaf8ff 0%, #bfe9fb 35%, #6cc6ec 65%, #1f9fd6 100%);
}

/* ---- Logo shown at the top of every blade's content ---- */
.blade-logo {
    display: block;
    /* scales with whichever viewport dimension is more constrained, so it always fits without ever getting oversized */
    height: clamp(40px, min(8vw, 10vh), 120px);
    width: auto;
    margin: 0 auto 1.5rem;
}

/* ---- Blade viewport: a row of vertical glass blades ---- */
#bladeViewport {
    display: flex;
    align-items: stretch;
    height: 100%;
    width: 100%;
}

.blade-panel {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    width: calc(var(--spine-w) + var(--content-peek));
    height: 100%;
    background: #5a6570;
    border-right: 1px solid rgba(0, 0, 0, 0.9);
    box-shadow: 6px 0 18px rgba(5, 30, 45, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    cursor: pointer;
    overflow: hidden;
    transition: width 0.55s linear, background 0.55s linear, box-shadow 0.55s linear;
}

/* glossy highlight sweeping across the top third, the classic Aero sheen */
.blade-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

/* shadow hugging the left edge, so the panel reads as lifted above its neighbor */
.blade-panel::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 14px;
    background: linear-gradient(90deg, rgba(5, 30, 45, 0.35) 0%, rgba(5, 30, 45, 0) 100%);
    pointer-events: none;
}

.blade-panel:not(.active)::after {
    width: 20px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.62) 0%, rgba(5, 30, 45, 0.24) 45%, rgba(5, 30, 45, 0) 100%);
}

.blade-panel.active {
    /* set by JS to exactly fill whatever space the fixed-width spines leave behind */
    width: var(--active-w, 420px);
    cursor: default;
    box-shadow: 12px 0 30px rgba(5, 30, 45, 0.45), -6px 0 24px rgba(5, 30, 45, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* ---- The narrow tab strip that is always visible on every blade ---- */
.blade-spine {
    position: relative;
    z-index: 4;
    flex: 0 0 var(--spine-w);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 2rem;
    backdrop-filter: blur(6px);
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(8, 18, 26, 0.2) 0,
        rgba(8, 18, 26, 0.2) 1px,
        rgba(255, 255, 255, 0.14) 1px,
        rgba(255, 255, 255, 0.14) 2px,
        rgba(255, 255, 255, 0) 2px,
        rgba(255, 255, 255, 0) 20px
    );
}

.blade-spine::after {
    content: "";
    position: absolute;
    top: calc(var(--badge-top) + var(--badge-image-top) + var(--badge-image-h));
    right: var(--badge-art-right);
    bottom: 0;
    width: var(--badge-art-w);
    background-color: var(--badge-base, var(--accent));
    background-image: url("../img/badge-grayscale_repeat.png");
    background-position: top right;
    background-size: var(--badge-art-w) auto;
    background-repeat: repeat-y;
    background-blend-mode: hard-light;
    -webkit-mask-image: url("../img/badge-grayscale_repeat.png");
    mask-image: url("../img/badge-grayscale_repeat.png");
    -webkit-mask-position: top right;
    mask-position: top right;
    -webkit-mask-size: var(--badge-art-w) auto;
    mask-size: var(--badge-art-w) auto;
    -webkit-mask-repeat: repeat-y;
    mask-repeat: repeat-y;
    pointer-events: none;
}

/* PNG badge artwork behind the vertical label */
.blade-badge {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: var(--badge-w);
    height: var(--badge-h);
    margin-left: calc(var(--spine-w) - var(--badge-w));
    padding: 2rem 0 1rem 0.25rem;
    overflow: visible;
    isolation: isolate;
    transition: none;
}

.blade-badge::before {
    content: "";
    position: absolute;
    top: var(--badge-image-top);
    right: var(--badge-art-right);
    width: var(--badge-art-w);
    height: var(--badge-image-h);
    background-color: var(--badge-base, var(--accent));
    -webkit-mask: url("../img/badge-grayscale.png") top right / 100% 100% no-repeat;
    mask: url("../img/badge-grayscale.png") top right / 100% 100% no-repeat;
    pointer-events: none;
}

.blade-badge-image {
    position: absolute;
    top: var(--badge-image-top);
    right: var(--badge-art-right);
    display: block;
    width: var(--badge-art-w);
    height: var(--badge-image-h);
    max-width: none;
    z-index: 1;
    image-rendering: auto;
    mix-blend-mode: hard-light;
    pointer-events: none;
}

.blade-label {
    position: relative;
    z-index: 2;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 0.1em;
    font-size: 1.1rem;
    color: #000000;
    transition: none;
    white-space: nowrap;
}

.blade-panel.active .blade-label {
    color: #ffffff;
    font-weight: 600;
}

/* ---- Expanded content area, only meaningful on the active blade ---- */
.blade-body {
    position: relative;
    z-index: 3;
    flex: 0 0 auto;
    /* active panel width already includes the fixed spine, so subtract it here to keep content fully visible */
    width: calc(var(--active-w, 420px) - var(--spine-w));
    overflow: hidden;
    pointer-events: none;
    backdrop-filter: blur(6px);
    visibility: visible;
    background: var(--accent);
}

.blade-divider {
    position: absolute;
    z-index: 5;
    top: 0;
    bottom: 0;
    left: calc(var(--spine-w) + var(--content-peek) - 3px);
    width: 3px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.88) 0 2px, rgba(255, 255, 255, 0.24) 2px 3px);
    box-shadow: inset 1px 0 1px rgba(0, 0, 0, 0.65);
    pointer-events: none;
}

.blade-panel.active .blade-body {
    pointer-events: auto;
}

.blade-content {
    height: 100%;
    overflow-y: auto;
    padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1.25rem, 5vw, 3rem) 2rem 1.75rem;
}

.blade-title {
    font-weight: 600;
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    letter-spacing: 0.02em;
    margin: 0 0 1.5rem;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(5, 30, 45, 0.4);
    white-space: nowrap;
}

/* ---- Reusable text content styles for blade content ---- */
.text-section {
    margin: 0 0 1.15rem;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(8, 18, 26, 0.14) 0,
            rgba(8, 18, 26, 0.14) 1px,
            rgba(255, 255, 255, 0.1) 1px,
            rgba(255, 255, 255, 0.1) 2px,
            rgba(255, 255, 255, 0) 2px,
            rgba(255, 255, 255, 0) 20px
        ),
        linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.07) 46%, rgba(255, 255, 255, 0) 100%),
        linear-gradient(180deg, #6d7782 0%, #5a6570 52%, #4d5965 100%);
    background-position: 0 0, 0 0, 0 0;
    background-attachment: scroll, scroll, scroll;
    border: 1px solid rgba(0, 0, 0, 0.92);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.55), inset 0 -3px 6px rgba(0, 0, 0, 0.42), inset 0 0 8px rgba(0, 0, 0, 0.22), 0 4px 10px rgba(5, 30, 45, 0.14);
}

.text-heading {
    margin: 0 0 0.45rem;
    font-size: clamp(0.95rem, 2.5vw, 1.18rem);
    line-height: 1.3;
    letter-spacing: 0.01em;
    font-weight: 700;
    color: #ffffff;
}

.text-subheading {
    margin: 0 0 0.45rem;
    font-size: clamp(0.82rem, 2.2vw, 0.95rem);
    line-height: 1.3;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.92);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.text-paragraph {
    margin: 0 0 0.7rem;
    font-size: clamp(0.8rem, 2vw, 0.92rem);
    line-height: 1.58;
    color: #ecf8ff;
    text-wrap: pretty;
}

.text-paragraph:last-child {
    margin-bottom: 0;
}

.auth-panel {
    max-width: 34rem;
}

.auth-panel-signed-out {
    display: grid;
    min-height: clamp(15rem, 42vh, 22rem);
    margin: clamp(2rem, 8vh, 5rem) auto 0;
    place-items: center;
}

.auth-signed-out {
    max-width: 25rem;
    padding: 1rem;
    text-align: center;
}

.auth-signed-out .text-heading {
    margin-bottom: 0.6rem;
    font-size: clamp(1.15rem, 3vw, 1.5rem);
}

.auth-signed-out .text-paragraph {
    margin-bottom: 1.15rem;
}

.auth-eyebrow {
    margin: 0 0 0.4rem;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-message {
    margin: 0 0 0.85rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.72);
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.82rem;
    line-height: 1.45;
}

.auth-message-error {
    background: rgba(117, 20, 20, 0.78);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.55);
}

.auth-message-success {
    background: rgba(20, 104, 54, 0.78);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

.auth-button {
    display: inline-flex;
    min-height: 2.5rem;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.95rem;
    border: 1px solid rgba(0, 0, 0, 0.9);
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.04)),
        color-mix(in srgb, var(--accent) 82%, black);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 3px 7px rgba(0, 0, 0, 0.28);
    color: #ffffff;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
    cursor: pointer;
}

.auth-button:hover {
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.58), 0 1px 2px rgba(0, 0, 0, 0.2);
}

.auth-button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

.auth-button-secondary {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.03)),
        #4e5963;
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.auth-actions form {
    margin: 0;
}

.auth-avatar-form {
    position: relative;
}

.auth-avatar-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.auth-avatar-editor {
    width: min(92vw, 25rem);
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.95);
    border-radius: 8px;
    background: linear-gradient(180deg, #65717c, #46515b);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.34);
    color: #ffffff;
}

.auth-avatar-editor::backdrop {
    background: rgba(4, 12, 18, 0.72);
}

.auth-avatar-editor-header,
.auth-avatar-editor-controls,
.auth-avatar-editor-actions {
    display: flex;
    align-items: center;
}

.auth-avatar-editor-header {
    justify-content: space-between;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.72);
}

.auth-avatar-editor-header h2 {
    margin: 0;
    font-size: 1rem;
}

.auth-avatar-crop {
    position: relative;
    width: min(78vw, 19rem);
    aspect-ratio: 1;
    margin: 1rem auto;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.82);
    border-radius: 50%;
    background: #20272d;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.12), inset 0 0 18px rgba(0, 0, 0, 0.55);
    cursor: grab;
    touch-action: none;
}

.auth-avatar-crop:active {
    cursor: grabbing;
}

.auth-avatar-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.auth-avatar-editor-controls {
    gap: 0.65rem;
    padding: 0.3rem 0.85rem 0.85rem;
}

.auth-avatar-zoom-label {
    font-size: 0.75rem;
    font-weight: 700;
}

.auth-avatar-zoom {
    min-width: 0;
    flex: 1 1 auto;
    accent-color: var(--accent);
}

.auth-icon-button {
    display: inline-grid;
    flex: 0 0 2.35rem;
    width: 2.35rem;
    height: 2.35rem;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.85);
    border-radius: 50%;
    background: linear-gradient(180deg, #75818c, #4d5862);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34), 0 2px 4px rgba(0, 0, 0, 0.28);
    color: #ffffff;
    font: inherit;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.auth-icon-button:hover,
.auth-icon-button:focus-visible {
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.58);
}

.auth-avatar-editor-actions {
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 0.8rem 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.auth-user-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.auth-user-heading .text-heading {
    margin-bottom: 0.1rem;
}

.auth-avatar {
    flex: 0 0 auto;
    width: 3.25rem;
    height: 3.25rem;
    border: 1px solid rgba(0, 0, 0, 0.85);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18), 0 3px 8px rgba(0, 0, 0, 0.42);
    object-fit: cover;
}

.auth-avatar-fallback {
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--accent) 72%, black);
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.auth-username {
    margin: 0;
    color: rgba(236, 248, 255, 0.82);
    font-size: 0.76rem;
}

.auth-details {
    display: grid;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.auth-details > div {
    display: grid;
    grid-template-columns: minmax(4rem, 0.3fr) minmax(0, 1fr);
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.auth-details dt {
    color: rgba(236, 248, 255, 0.72);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.auth-details dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: #ffffff;
    font-size: 0.82rem;
}

.text-lead {
    font-size: clamp(0.88rem, 2.3vw, 1.03rem);
    line-height: 1.62;
    color: #ffffff;
}

.text-muted {
    color: rgba(236, 248, 255, 0.82);
}

.text-divider {
    margin: 0.85rem 0;
    height: 3px;
    border: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 34%),
        linear-gradient(90deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
    border-radius: 2px;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.75), inset 0 -1px 1px rgba(255, 255, 255, 0.12), 0 1px 1px rgba(0, 0, 0, 0.35);
}

.text-list {
    margin: 0;
    padding-left: 1.15rem;
    color: #ecf8ff;
}

.text-list li {
    margin: 0 0 0.38rem;
    line-height: 1.48;
    font-size: clamp(0.8rem, 2vw, 0.92rem);
}

.text-list li:last-child {
    margin-bottom: 0;
}

.text-note {
    margin-top: 0.6rem;
    padding: 0.52rem 0.65rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    border-left: 3px solid rgba(255, 255, 255, 0.72);
    color: #ffffff;
    font-size: 0.78rem;
    line-height: 1.45;
}

/* ---- Reusable textbox styles for blade content ---- */
.textbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
}

.textbox-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.textbox,
.textbox-multiline {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(242, 250, 255, 0.9) 100%);
    color: #103649;
    box-shadow: inset 0 1px 2px rgba(16, 54, 73, 0.14), 0 1px 0 rgba(255, 255, 255, 0.6);
    padding: 0.6rem 0.75rem;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.textbox::placeholder,
.textbox-multiline::placeholder {
    color: #5f8395;
}

.textbox:focus,
.textbox-multiline:focus {
    border-color: color-mix(in srgb, var(--accent) 72%, #ffffff);
    box-shadow: inset 0 1px 2px rgba(16, 54, 73, 0.14), 0 0 0 3px color-mix(in srgb, var(--accent) 28%, #ffffff);
    background: #ffffff;
}

.textbox {
    min-height: 2.4rem;
}

.textbox-multiline {
    min-height: 6rem;
    resize: vertical;
}

.textbox-sm {
    max-width: 16rem;
}

.textbox-lg {
    max-width: 28rem;
}

.textbox-error {
    border-color: #b84141;
    box-shadow: inset 0 1px 2px rgba(122, 22, 22, 0.18), 0 0 0 2px rgba(184, 65, 65, 0.2);
}

.textbox-help {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.92);
}

/* ---- Vertical tile list within a blade, styled as glossy Aero buttons ---- */
.tile-column {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: clamp(0.6rem, 2vw, 1rem);
    padding: clamp(0.6rem, 2vw, 0.9rem) clamp(0.75rem, 3vw, 1.2rem);
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.92);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.07) 46%, rgba(255, 255, 255, 0) 100%),
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--accent) 88%, white) 0%,
            var(--accent) 52%,
            color-mix(in srgb, var(--accent) 68%, black) 100%
        );
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.9), inset 0 -4px 9px rgba(0, 0, 0, 0.72), inset 0 0 14px rgba(0, 0, 0, 0.42), 0 5px 14px rgba(5, 30, 45, 0.2);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(8, 18, 26, 0.14) 0,
        rgba(8, 18, 26, 0.14) 1px,
        rgba(255, 255, 255, 0.1) 1px,
        rgba(255, 255, 255, 0.1) 2px,
        rgba(255, 255, 255, 0) 2px,
        rgba(255, 255, 255, 0) 20px
    );
    background-position: 0 0;
    background-attachment: scroll;
    pointer-events: none;
}

.tile:hover, .tile:focus-visible {
    transform: none;
    box-shadow:
        inset 0 4px 6px rgba(0, 0, 0, 0.68),
        inset 0 -2px 3px rgba(255, 255, 255, 0.14),
        inset 0 0 12px rgba(0, 0, 0, 0.42),
        0 1px 2px rgba(5, 30, 45, 0.12);
}

.tile-icon {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    color: #f5fbff;
    width: 2rem;
    text-align: center;
}

.tile-text {
    position: relative;
    z-index: 1;
}

.tile-title {
    font-size: clamp(0.8rem, 2.2vw, 0.95rem);
    font-weight: 700;
    color: #ffffff;
}

.tile-desc {
    font-size: clamp(0.65rem, 1.8vw, 0.75rem);
    color: rgba(236, 248, 255, 0.9);
}

/* ---- Chat workspace ---- */
#panel-chat .blade-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#panel-chat .blade-title {
    flex: 0 0 auto;
}

.chat-shell {
    display: grid;
    grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 28rem;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.94);
    border-radius: 8px;
    background: #35414a;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 22px rgba(0, 0, 0, 0.3);
    color: #f3f8fa;
}

.chat-sidebar {
    display: flex;
    min-width: 0;
    flex-direction: column;
    border-right: 1px solid rgba(0, 0, 0, 0.8);
    background:
        repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 20px),
        linear-gradient(180deg, #4f5b65, #3b4650);
}

.chat-sidebar-header,
.chat-main-header,
.chat-composer-bar,
.chat-dialog-header,
.chat-dialog-actions {
    display: flex;
    align-items: center;
}

.chat-sidebar-header {
    min-height: 4rem;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.7);
}

.chat-sidebar-header h2,
.chat-main-header h2,
.chat-dialog h2 {
    margin: 0;
    color: #ffffff;
    font-size: 1rem;
    letter-spacing: 0;
}

.chat-kicker {
    margin: 0 0 0.15rem;
    color: rgba(235, 245, 250, 0.66);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
}

.chat-create-actions,
.chat-composer-tools {
    display: flex;
    gap: 0.4rem;
}

.chat-icon-button {
    display: inline-grid;
    flex: 0 0 2.1rem;
    width: 2.1rem;
    height: 2.1rem;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.82);
    border-radius: 50%;
    background: linear-gradient(180deg, #77838d, #4f5a64);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 2px 4px rgba(0, 0, 0, 0.25);
    color: #ffffff;
    font: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.chat-icon-button:hover,
.chat-icon-button:focus-visible {
    background: color-mix(in srgb, var(--accent) 76%, #38434c);
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.48), 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.chat-conversation-list {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.45rem;
}

.chat-conversation-list h3 {
    margin: 0.75rem 0.45rem 0.3rem;
    color: rgba(235, 245, 250, 0.62);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-conversation,
.chat-conversation-copy {
    min-width: 0;
}

.chat-conversation {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #edf6fa;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.chat-conversation:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-conversation.active {
    border-color: rgba(0, 0, 0, 0.72);
    background: color-mix(in srgb, var(--accent) 58%, #3d4851);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.46);
}

.chat-conversation-copy {
    display: grid;
    gap: 0.12rem;
    flex: 1 1 auto;
}

.chat-conversation-copy strong,
.chat-conversation-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-conversation-copy strong {
    font-size: 0.78rem;
}

.chat-conversation-copy small {
    color: rgba(235, 245, 250, 0.68);
    font-size: 0.66rem;
}

.chat-conversation-avatar,
.chat-message-avatar,
.chat-room-icon {
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
}

.chat-conversation-avatar,
.chat-room-icon {
    width: 2rem;
    height: 2rem;
}

.chat-room-icon,
.chat-avatar-fallback {
    display: grid;
    place-items: center;
    border: 1px solid rgba(0, 0, 0, 0.76);
    background: color-mix(in srgb, var(--accent) 66%, #35414a);
    color: #ffffff;
    font-weight: 800;
}

.chat-main {
    display: grid;
    min-width: 0;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: linear-gradient(180deg, #53606a, #46515b);
}

.chat-main-header {
    min-height: 4rem;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.76);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.chat-connection {
    color: rgba(235, 245, 250, 0.66);
    font-size: 0.67rem;
}

.chat-connection::before {
    content: "";
    display: inline-block;
    width: 0.48rem;
    height: 0.48rem;
    margin-right: 0.35rem;
    border-radius: 50%;
    background: #d39a3c;
    box-shadow: 0 0 5px rgba(211, 154, 60, 0.7);
}

.chat-connection.connected::before {
    background: #55cf77;
    box-shadow: 0 0 5px rgba(85, 207, 119, 0.8);
}

.chat-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 0.9rem;
    scroll-behavior: smooth;
}

.chat-empty-state,
.chat-loading {
    margin: 1.5rem auto;
    color: rgba(235, 245, 250, 0.7);
    font-size: 0.78rem;
    text-align: center;
}

.chat-message {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr);
    gap: 0.6rem;
    padding: 0.55rem 0;
}

.chat-message + .chat-message {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-message-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid rgba(0, 0, 0, 0.75);
}

.chat-message-content {
    min-width: 0;
}

.chat-message-meta {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.chat-message-meta strong {
    color: #ffffff;
    font-size: 0.78rem;
}

.chat-message-meta time {
    color: rgba(235, 245, 250, 0.55);
    font-size: 0.62rem;
}

.chat-message-content p {
    margin: 0.2rem 0 0;
    overflow-wrap: anywhere;
    color: #f0f7fa;
    font-size: 0.8rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.chat-message-image-link {
    display: block;
    width: fit-content;
    max-width: min(100%, 28rem);
    margin-top: 0.45rem;
}

.chat-message-image {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 22rem;
    border: 1px solid rgba(0, 0, 0, 0.8);
    border-radius: 6px;
    object-fit: contain;
    background: #263038;
}

.chat-composer {
    position: relative;
    padding: 0.65rem;
    border-top: 1px solid rgba(0, 0, 0, 0.78);
    background: #3d4851;
}

.chat-message-input {
    display: block;
    width: 100%;
    min-height: 2.7rem;
    max-height: 8rem;
    resize: vertical;
    padding: 0.7rem 0.8rem;
    border: 1px solid rgba(0, 0, 0, 0.82);
    border-radius: 6px;
    background: #f6fbfd;
    color: #173746;
    font: inherit;
    font-size: 0.82rem;
}

.chat-message-input:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 70%, white);
    outline-offset: 1px;
}

.chat-composer-bar {
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.chat-compose-status {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    color: #ffd9d9;
    font-size: 0.67rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-send {
    min-height: 2.1rem;
    padding: 0.4rem 0.8rem;
}

.chat-send:disabled,
.chat-message-input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.chat-image-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.chat-image-preview {
    position: relative;
    width: 5rem;
    margin-bottom: 0.5rem;
}

.chat-image-preview img {
    display: block;
    width: 5rem;
    height: 4rem;
    border: 1px solid rgba(0, 0, 0, 0.82);
    border-radius: 5px;
    object-fit: cover;
}

.chat-image-preview .chat-remove-image {
    position: absolute;
    top: -0.55rem;
    right: -0.55rem;
    width: 1.55rem;
    height: 1.55rem;
    font-size: 0.9rem;
}

.chat-emoji-picker {
    position: absolute;
    z-index: 4;
    bottom: 3.5rem;
    left: 3rem;
    display: grid;
    width: min(15rem, calc(100% - 4rem));
    grid-template-columns: repeat(6, 1fr);
    gap: 0.2rem;
    padding: 0.45rem;
    border: 1px solid rgba(0, 0, 0, 0.9);
    border-radius: 6px;
    background: #59656f;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.chat-emoji-picker[hidden] {
    display: none;
}

.chat-emoji-picker button {
    min-width: 0;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    font-size: 1.15rem;
    cursor: pointer;
}

.chat-emoji-picker button:hover,
.chat-emoji-picker button:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    outline: 1px solid rgba(255, 255, 255, 0.7);
}

.chat-dialog {
    width: min(92vw, 24rem);
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.95);
    border-radius: 8px;
    background: linear-gradient(180deg, #65717c, #46515b);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.58);
    color: #ffffff;
}

.chat-dialog::backdrop {
    background: rgba(4, 12, 18, 0.72);
}

.chat-dialog-form {
    display: grid;
    gap: 0.65rem;
    padding: 0.9rem;
}

.chat-dialog-header {
    justify-content: space-between;
    margin: -0.2rem 0 0.2rem;
}

.chat-dialog-form > label {
    font-size: 0.75rem;
    font-weight: 700;
}

.chat-dialog-help,
.chat-dialog-error {
    min-height: 1rem;
    margin: 0;
    font-size: 0.7rem;
}

.chat-dialog-help {
    color: rgba(235, 245, 250, 0.7);
}

.chat-dialog-error {
    color: #ffd1d1;
}

.chat-dialog-actions {
    justify-content: flex-end;
    gap: 0.6rem;
}

.chat-toast {
    position: fixed;
    z-index: 20;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    width: min(22rem, calc(100vw - 2rem));
    grid-template-columns: 2.4rem minmax(0, 1fr) 1rem;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.92);
    border-radius: 7px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 48%),
        #47545e;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 10px 28px rgba(0, 0, 0, 0.42);
    color: #ffffff;
    font: inherit;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    transform: translateY(0.75rem);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-toast[hidden] {
    display: none;
}

.chat-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-toast:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

.chat-toast-avatar {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    place-items: center;
    border: 1px solid rgba(0, 0, 0, 0.76);
    border-radius: 50%;
    background: #b33d43;
    font-size: 0.85rem;
    font-weight: 800;
}

.chat-toast-copy {
    display: grid;
    min-width: 0;
    gap: 0.16rem;
}

.chat-toast-copy strong,
.chat-toast-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-toast-copy strong {
    font-size: 0.76rem;
}

.chat-toast-copy small {
    color: rgba(239, 247, 250, 0.78);
    font-size: 0.7rem;
}

.chat-toast-close {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
}

/* ---- Mobile: shrink the spine further and tighten spacing ---- */
@media (max-width: 600px) {
    :root {
        --mobile-spine-h: 42px;
        --content-peek: 0px;
        --active-h: calc(100dvh - (var(--mobile-spine-h) * 4));
    }

    #bladeViewport {
        flex-direction: column;
    }

    .blade-panel,
    .blade-panel.active {
        width: 100%;
    }

    .blade-panel {
        flex-direction: column;
        height: var(--mobile-spine-h);
        transition: background 0.45s linear, box-shadow 0.45s linear;
    }

    .blade-panel.active {
        height: var(--active-h, 300px);
    }

    .blade-spine {
        flex: 0 0 var(--mobile-spine-h);
        width: 100%;
        height: var(--mobile-spine-h);
        flex-direction: row;
        align-items: center;
        padding: 0;
        background-image: repeating-linear-gradient(
            to right,
            rgba(8, 18, 26, 0.18) 0,
            rgba(8, 18, 26, 0.18) 1px,
            rgba(255, 255, 255, 0.1) 1px,
            rgba(255, 255, 255, 0.1) 2px,
            transparent 2px,
            transparent 20px
        );
    }

    .blade-panel.active .blade-spine {
        background-color: var(--accent);
    }

    .blade-spine::after,
    .blade-badge::before,
    .blade-badge-image {
        display: none;
    }

    .blade-badge {
        width: 100%;
        height: var(--mobile-spine-h);
        flex-direction: row;
        align-items: center;
        margin: 0;
        padding: 0 0.9rem;
    }

    .blade-label {
        writing-mode: horizontal-tb;
        transform: none;
        margin: 0;
        font-size: 0.76rem;
        letter-spacing: 0.05em;
    }

    .blade-body {
        width: 100%;
        height: calc(var(--active-h, 300px) - var(--mobile-spine-h));
        flex: 0 0 auto;
    }

    .blade-divider {
        top: calc(var(--mobile-spine-h) - 3px);
        right: 0;
        bottom: auto;
        left: 0;
        width: 100%;
        height: 3px;
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.88) 0 2px, rgba(255, 255, 255, 0.24) 2px 3px);
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.65);
    }

    .blade-content {
        padding: 0.75rem;
    }

    .blade-title {
        margin-bottom: 0.65rem;
        font-size: 1.3rem;
    }

    .tile-column {
        gap: 0.6rem;
    }

    .chat-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        min-height: 0;
    }

    .chat-sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.8);
    }

    .chat-sidebar-header {
        min-height: 3rem;
        padding: 0.4rem 0.55rem;
    }

    .chat-sidebar-header h2 {
        font-size: 0.82rem;
    }

    .chat-conversation-list {
        display: flex;
        flex: 0 0 auto;
        gap: 0.35rem;
        overflow-x: auto;
        padding: 0.35rem;
    }

    .chat-conversation-list h3 {
        display: none;
    }

    .chat-conversation {
        width: 9.5rem;
        flex: 0 0 9.5rem;
        padding: 0.4rem;
    }

    .chat-main-header {
        min-height: 3.1rem;
        padding: 0.45rem 0.6rem;
    }

    .chat-messages {
        padding: 0.55rem;
    }

    .chat-composer {
        padding: 0.5rem;
    }

    .chat-message-image {
        max-height: 13rem;
    }
}

