      /* ============================== TOKENS ============================== */
      :root {
        /* Surfaces */
        --bg-deep: #060709;
        --bg: #0a0b0e;
        --surface: #0f1116;
        --surface-2: #14161d;
        --surface-3: #1a1d26;
        --surface-4: #21242f;
        --surface-5: #2a2d3a;
        --border: #1f2129;
        --border-2: #272a35;
        --border-3: #363a48;

        /* Text */
        --text: #ecedf0;
        --text-2: #a9adb8;
        --text-3: #6e7280;
        --text-4: #4a4d5a;
        --text-5: #353844;

        /* Brand */
        --accent: #53fc18;
        --accent-2: #6dff35;
        --accent-deep: #2dbb00;
        --accent-soft: rgba(83, 252, 24, 0.12);
        --accent-soft-2: rgba(83, 252, 24, 0.22);
        --accent-glow: rgba(83, 252, 24, 0.5);
        --accent-glow-soft: rgba(83, 252, 24, 0.18);

        /* Secondary accent (used sparingly for reactions, hot links) */
        --pink: #ff5ec1;
        --pink-soft: rgba(255, 94, 193, 0.14);

        /* Roles */
        --role-owner: var(--accent);
        --role-admin: #c084fc;
        --role-admin-soft: rgba(192, 132, 252, 0.14);
        --role-support: #60a5fa;
        --role-support-soft: rgba(96, 165, 250, 0.14);

        /* Status */
        --danger: #f87171;
        --danger-soft: rgba(248, 113, 113, 0.14);
        --warning: #fbbf24;
        --warning-soft: rgba(251, 191, 36, 0.14);
        --info: #60a5fa;
        --info-soft: rgba(96, 165, 250, 0.14);

        /* Geometry */
        --radius-xs: 3px;
        --radius-sm: 5px;
        --radius: 8px;
        --radius-lg: 12px;
        --radius-xl: 16px;
        --radius-2xl: 22px;

        /* Shadows */
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
        --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
        --shadow-glow:
          0 0 0 1px var(--accent-soft-2), 0 8px 32px var(--accent-glow-soft);

        /* Type */
        --font-display: "Geist", system-ui, -apple-system, sans-serif;
        --font-sans: "Geist", system-ui, -apple-system, sans-serif;
        --font-mono: "JetBrains Mono", ui-monospace, monospace;

        /* Layout */
        --sidebar-w: 272px;
        --members-w: 248px;
      }

      /* ============================== BASE ============================== */
      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }
      html,
      body {
        height: 100%;
      }
      body {
        font-family: var(--font-sans);
        font-feature-settings: "ss01", "ss02", "cv11";
        background: var(--bg-deep);
        color: var(--text);
        font-size: 14px;
        line-height: 1.55;
        letter-spacing: -0.005em;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        overflow: hidden;
        position: relative;
      }
      button {
        font: inherit;
        color: inherit;
        cursor: pointer;
        background: none;
        border: none;
      }
      input,
      textarea {
        font: inherit;
        color: inherit;
      }
      a {
        color: var(--info);
        text-decoration: none;
      }
      a:hover {
        text-decoration: underline;
        text-decoration-color: rgba(96, 165, 250, 0.5);
      }
      ::selection {
        background: var(--accent-soft-2);
        color: var(--accent);
      }
      ::placeholder {
        color: var(--text-4);
      }

      /* Custom scrollbars */
      ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
      }
      ::-webkit-scrollbar-track {
        background: transparent;
      }
      ::-webkit-scrollbar-thumb {
        background: var(--surface-4);
        border: 2px solid transparent;
        background-clip: padding-box;
        border-radius: 10px;
      }
      ::-webkit-scrollbar-thumb:hover {
        background: var(--surface-5);
        background-clip: padding-box;
      }

      /* ============================== AMBIENT BACKGROUND ============================== */
      .aurora {
        position: fixed;
        inset: 0;
        z-index: 0;
        overflow: hidden;
        pointer-events: none;
      }
      .aurora-blob {
        position: absolute;
        border-radius: 50%;
        filter: blur(120px);
        opacity: 0.55;
        mix-blend-mode: screen;
        will-change: transform;
      }
      .aurora-blob.b1 {
        width: 700px;
        height: 700px;
        background: radial-gradient(circle, var(--accent) 0%, transparent 60%);
        top: -200px;
        right: -150px;
        opacity: 0.18;
        animation: drift1 28s ease-in-out infinite;
      }
      .aurora-blob.b2 {
        width: 600px;
        height: 600px;
        background: radial-gradient(circle, #1e3a8a 0%, transparent 60%);
        bottom: -200px;
        left: -150px;
        opacity: 0.22;
        animation: drift2 36s ease-in-out infinite;
      }
      .aurora-blob.b3 {
        width: 500px;
        height: 500px;
        background: radial-gradient(circle, var(--pink) 0%, transparent 60%);
        top: 40%;
        left: 30%;
        opacity: 0.08;
        animation: drift3 40s ease-in-out infinite;
      }
      @keyframes drift1 {
        0%,
        100% {
          transform: translate(0, 0) scale(1);
        }
        50% {
          transform: translate(-80px, 60px) scale(1.1);
        }
      }
      @keyframes drift2 {
        0%,
        100% {
          transform: translate(0, 0) scale(1);
        }
        50% {
          transform: translate(80px, -60px) scale(1.15);
        }
      }
      @keyframes drift3 {
        0%,
        100% {
          transform: translate(0, 0) scale(1);
        }
        33% {
          transform: translate(60px, 40px) scale(1.2);
        }
        66% {
          transform: translate(-40px, 80px) scale(0.9);
        }
      }
      @media (prefers-reduced-motion: reduce) {
        .aurora-blob.b1,
        .aurora-blob.b2,
        .aurora-blob.b3 {
          animation: none;
        }
        /* Skeleton shimmer (infinite) is injected at runtime by polish.js, so
           !important is needed to win against that later <style> element. */
        .kvb-skeleton {
          animation: none !important;
        }
      }
      .grain {
        position: fixed;
        inset: 0;
        z-index: 1;
        pointer-events: none;
        opacity: 0.06;
        mix-blend-mode: overlay;
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' /%3E%3C/svg%3E");
      }

      /* ============================== SCREEN SYSTEM ============================== */
      .screen {
        display: none;
        height: 100vh;
        width: 100vw;
        position: relative;
        z-index: 2;
      }
      .screen.active {
        display: flex;
        animation: fadeUp 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
      }
      @keyframes fadeUp {
        from {
          opacity: 0;
          transform: translateY(6px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      /* ============================== AUTH ============================== */
      .auth-wrap {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: stretch;
        position: relative;
        overflow: hidden;
      }
      .auth-grid {
        position: absolute;
        inset: 0;
        background-image:
          linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
          linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.018) 1px,
            transparent 1px
          );
        background-size: 56px 56px;
        mask-image: radial-gradient(
          ellipse 80% 60% at 50% 40%,
          #000 30%,
          transparent 75%
        );
        pointer-events: none;
      }

      .auth-left {
        flex: 1.1;
        display: flex;
        flex-direction: column;
        padding: 44px 64px;
        position: relative;
        z-index: 3;
        border-right: 1px solid var(--border);
        background: linear-gradient(
          180deg,
          transparent,
          rgba(83, 252, 24, 0.015) 90%
        );
      }
      .auth-right {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 44px;
        position: relative;
        z-index: 3;
      }

      /* Brand */
      .brand {
        display: flex;
        align-items: center;
        gap: 11px;
      }
      .brand-mark {
        width: 36px;
        height: 36px;
        background: linear-gradient(
          135deg,
          var(--accent) 0%,
          var(--accent-deep) 100%
        );
        color: #000;
        border-radius: 9px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: var(--font-display);
        font-weight: 800;
        font-size: 17px;
        letter-spacing: -0.06em;
        box-shadow:
          0 0 0 1px rgba(255, 255, 255, 0.05) inset,
          0 8px 24px var(--accent-glow-soft),
          0 0 36px var(--accent-glow);
        position: relative;
        overflow: hidden;
      }
      .brand-mark::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(
          transparent 0%,
          transparent 49%,
          rgba(0, 0, 0, 0.12) 50%,
          transparent 51%
        );
        background-size: 100% 4px;
        pointer-events: none;
      }
      .brand-text {
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 16px;
        letter-spacing: -0.025em;
      }
      .brand-text .dim {
        color: var(--text-3);
        font-weight: 400;
      }

      /* Auth hero */
      .auth-hero {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        max-width: 540px;
        margin-top: 72px;
      }
      .auth-eyebrow {
        font-family: var(--font-mono);
        font-size: 11px;
        color: var(--accent);
        letter-spacing: 0.16em;
        text-transform: uppercase;
        margin-bottom: 22px;
        display: inline-flex;
        align-items: center;
        gap: 9px;
        width: fit-content;
        padding: 5px 11px 5px 9px;
        background: var(--accent-soft);
        border: 1px solid var(--accent-soft-2);
        border-radius: 999px;
      }
      .auth-eyebrow::before {
        content: "";
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--accent);
        box-shadow: 0 0 10px var(--accent-glow);
        animation: pulse 2.4s ease-in-out infinite;
      }
      @keyframes pulse {
        0%,
        100% {
          opacity: 1;
          transform: scale(1);
        }
        50% {
          opacity: 0.4;
          transform: scale(0.85);
        }
      }
      .auth-title {
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 60px;
        line-height: 1;
        letter-spacing: -0.045em;
        margin-bottom: 20px;
        color: var(--text);
      }
      .auth-title em {
        font-style: normal;
        font-weight: 600;
        color: var(--accent);
        background: linear-gradient(
          180deg,
          var(--accent) 0%,
          var(--accent-deep) 100%
        );
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
      }
      .auth-subtitle {
        color: var(--text-2);
        font-size: 17px;
        line-height: 1.55;
        margin-bottom: 36px;
        max-width: 480px;
        letter-spacing: -0.005em;
      }

      /* Feature cards */
      .auth-features {
        display: grid;
        gap: 12px;
        margin-top: auto;
      }
      .auth-feature {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 16px 18px;
        background: linear-gradient(
          180deg,
          rgba(255, 255, 255, 0.025),
          rgba(255, 255, 255, 0.005)
        );
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        backdrop-filter: blur(8px);
        transition: all 0.25s cubic-bezier(0.2, 0.7, 0.3, 1);
        position: relative;
        overflow: hidden;
      }
      .auth-feature::before {
        content: "";
        position: absolute;
        inset: 0;
        background: radial-gradient(
          600px circle at var(--mx, 50%) var(--my, 50%),
          rgba(83, 252, 24, 0.08),
          transparent 40%
        );
        opacity: 0;
        transition: opacity 0.25s;
        pointer-events: none;
      }
      .auth-feature:hover {
        border-color: var(--border-2);
        transform: translateY(-1px);
      }
      .auth-feature:hover::before {
        opacity: 1;
      }
      .auth-feature-icon {
        width: 36px;
        height: 36px;
        background: var(--surface-3);
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: var(--accent);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
      }
      .auth-feature h4 {
        font-size: 13.5px;
        font-weight: 500;
        margin-bottom: 2px;
        letter-spacing: -0.01em;
      }
      .auth-feature p {
        font-size: 12.5px;
        color: var(--text-3);
        line-height: 1.45;
      }

      /* Stat strip at bottom of left side */
      .auth-stats {
        margin-top: 28px;
        display: flex;
        gap: 28px;
        padding-top: 22px;
        border-top: 1px solid var(--border);
      }
      .auth-stat-item .num {
        font-family: var(--font-display);
        font-size: 26px;
        font-weight: 600;
        letter-spacing: -0.035em;
        color: var(--text);
        line-height: 1;
      }
      .auth-stat-item .lbl {
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.14em;
        margin-top: 5px;
      }
      .auth-stat-item .num em {
        color: var(--accent);
        font-style: normal;
      }

      /* Auth card */
      .auth-card {
        width: 100%;
        max-width: 420px;
        background: linear-gradient(
          180deg,
          rgba(20, 22, 29, 0.85),
          rgba(15, 17, 22, 0.85)
        );
        border: 1px solid var(--border-2);
        border-radius: var(--radius-2xl);
        padding: 40px 36px;
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        position: relative;
      }
      .auth-card::before {
        content: "";
        position: absolute;
        top: -1px;
        left: 28px;
        right: 28px;
        height: 1px;
        background: linear-gradient(
          90deg,
          transparent,
          var(--accent),
          transparent
        );
        opacity: 0.7;
      }
      .auth-card::after {
        content: "";
        position: absolute;
        inset: 1px;
        border-radius: calc(var(--radius-2xl) - 1px);
        background: linear-gradient(
          180deg,
          rgba(255, 255, 255, 0.04),
          transparent 30%
        );
        pointer-events: none;
      }
      .auth-card-inner {
        position: relative;
        z-index: 1;
      }
      .modal-eyebrow {
        font-family: var(--font-mono);
        font-size: 10.5px;
        color: var(--accent);
        letter-spacing: 0.16em;
        text-transform: uppercase;
        margin-bottom: 8px;
        display: flex;
        align-items: center;
        gap: 7px;
      }
      .modal-eyebrow::before {
        content: "";
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--accent);
        box-shadow: 0 0 8px var(--accent-glow);
      }
      .auth-card h2 {
        font-family: var(--font-display);
        font-size: 28px;
        font-weight: 600;
        letter-spacing: -0.035em;
        margin-bottom: 6px;
        line-height: 1.05;
      }
      .auth-card .sub {
        color: var(--text-3);
        font-size: 13.5px;
        margin-bottom: 28px;
        line-height: 1.5;
      }

      /* Fields */
      .field {
        margin-bottom: 18px;
      }
      .field label {
        display: block;
        font-size: 12px;
        color: var(--text-2);
        margin-bottom: 7px;
        font-weight: 500;
        letter-spacing: 0.005em;
      }
      .input,
      .textarea {
        width: 100%;
        background: var(--bg);
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        padding: 11px 13px;
        color: var(--text);
        font-size: 14px;
        transition:
          border-color 0.15s,
          background 0.15s,
          box-shadow 0.15s;
        outline: none;
        font-family: inherit;
      }
      .input:hover,
      .textarea:hover {
        border-color: var(--border-3);
      }
      .input:focus,
      .textarea:focus {
        border-color: var(--accent);
        background: var(--surface-2);
        box-shadow: 0 0 0 4px var(--accent-soft);
      }
      .textarea {
        min-height: 100px;
        resize: vertical;
        line-height: 1.55;
      }
      .input-with-icon {
        position: relative;
      }
      .input-with-icon .input {
        padding-left: 38px;
      }
      .input-with-icon .icon {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-4);
        width: 16px;
        height: 16px;
        pointer-events: none;
      }
      .input-with-icon .input:focus + .icon {
        color: var(--accent);
      }
      .input-hint {
        font-size: 11.5px;
        color: var(--text-3);
        margin-top: 5px;
        font-family: var(--font-mono);
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .input-hint a {
        font-family: var(--font-sans);
        font-size: 12px;
        color: var(--text-2);
      }
      .input-hint a:hover {
        color: var(--accent);
        text-decoration: none;
      }

      /* Buttons */
      .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        padding: 11px 18px;
        border-radius: var(--radius);
        font-size: 13.5px;
        font-weight: 500;
        transition: all 0.18s cubic-bezier(0.2, 0.7, 0.3, 1);
        border: 1px solid transparent;
        white-space: nowrap;
        letter-spacing: -0.005em;
        position: relative;
        overflow: hidden;
      }
      .btn-primary {
        background: linear-gradient(
          180deg,
          var(--accent) 0%,
          var(--accent-deep) 100%
        );
        color: #001a00;
        box-shadow:
          inset 0 1px 0 rgba(255, 255, 255, 0.18),
          0 1px 0 rgba(0, 0, 0, 0.2),
          0 0 0 0 var(--accent-glow);
        font-weight: 600;
      }
      .btn-primary:hover {
        box-shadow:
          inset 0 1px 0 rgba(255, 255, 255, 0.24),
          0 1px 0 rgba(0, 0, 0, 0.2),
          0 0 28px var(--accent-glow-soft);
        transform: translateY(-1px);
      }
      .btn-primary:active {
        transform: translateY(0);
      }
      .btn-secondary {
        background: var(--surface-3);
        color: var(--text);
        border-color: var(--border-2);
      }
      .btn-secondary:hover {
        background: var(--surface-4);
        border-color: var(--border-3);
      }
      .btn-ghost {
        color: var(--text-2);
      }
      .btn-ghost:hover {
        color: var(--text);
        background: var(--surface-3);
      }
      .btn-danger {
        background: var(--danger-soft);
        color: var(--danger);
        border-color: rgba(248, 113, 113, 0.22);
      }
      .btn-danger:hover {
        background: rgba(248, 113, 113, 0.22);
      }
      .btn-block {
        width: 100%;
      }
      .btn-sm {
        padding: 7px 12px;
        font-size: 12.5px;
        gap: 5px;
      }
      .btn .arrow {
        transition: transform 0.2s;
      }
      .btn:hover .arrow {
        transform: translateX(2px);
      }

      /* Turnstile */
      .turnstile-mock {
        background: linear-gradient(180deg, var(--surface-2), var(--surface));
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        padding: 14px 16px;
        display: flex;
        align-items: center;
        gap: 13px;
        margin-bottom: 20px;
        position: relative;
        overflow: hidden;
      }
      .turnstile-mock::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background: var(--accent);
        box-shadow: 0 0 12px var(--accent-glow);
      }
      .turnstile-check {
        width: 22px;
        height: 22px;
        border: 2px solid var(--border-3);
        border-radius: 5px;
        flex-shrink: 0;
        position: relative;
        cursor: pointer;
        transition: all 0.25s cubic-bezier(0.2, 0.7, 0.3, 1);
      }
      .turnstile-check.checked {
        background: var(--accent);
        border-color: var(--accent);
        box-shadow: 0 0 16px var(--accent-glow-soft);
      }
      .turnstile-check.checked::after {
        content: "";
        position: absolute;
        inset: 0;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
        background-size: 14px;
        background-position: center;
        background-repeat: no-repeat;
        animation: pop 0.3s cubic-bezier(0.2, 1.6, 0.3, 1);
      }
      @keyframes pop {
        from {
          transform: scale(0);
        }
        to {
          transform: scale(1);
        }
      }
      .turnstile-text {
        font-size: 13.5px;
        color: var(--text);
        flex: 1;
        font-weight: 500;
      }
      .turnstile-brand {
        font-size: 9.5px;
        color: var(--text-3);
        font-family: var(--font-mono);
        letter-spacing: 0.12em;
        margin-top: 3px;
        font-weight: 400;
      }
      .turnstile-cf-mark {
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        text-align: right;
      }

      .auth-divider {
        display: flex;
        align-items: center;
        gap: 14px;
        margin: 22px 0;
        color: var(--text-3);
        font-size: 11px;
        font-family: var(--font-mono);
        letter-spacing: 0.14em;
      }
      .auth-divider::before,
      .auth-divider::after {
        content: "";
        flex: 1;
        height: 1px;
        background: linear-gradient(
          90deg,
          transparent,
          var(--border-2),
          transparent
        );
      }
      .auth-foot {
        text-align: center;
        color: var(--text-3);
        font-size: 13.5px;
      }
      .auth-foot a {
        color: var(--accent);
        font-weight: 500;
      }
      .auth-foot a:hover {
        color: var(--accent-2);
        text-decoration: none;
      }

      /* ============================== APP SHELL ============================== */
      .app {
        width: 100%;
        height: 100vh;
        display: grid;
        grid-template-columns: var(--sidebar-w) 1fr var(--members-w);
        background: var(--bg);
        position: relative;
        z-index: 2;
      }

      /* ============================== SIDEBAR ============================== */
      .sidebar {
        background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
        border-right: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        min-width: 0;
        position: relative;
        height: 100%;
        overflow: hidden;
      }

      /* Server header (banner) */
      .server-header {
        height: 84px;
        position: relative;
        border-bottom: 1px solid var(--border);
        overflow: hidden;
        cursor: pointer;
      }
      .server-banner {
        position: absolute;
        inset: 0;
        background:
          radial-gradient(
            ellipse at top right,
            rgba(83, 252, 24, 0.18),
            transparent 60%
          ),
          linear-gradient(135deg, #052804 0%, #0a0c10 70%);
      }
      .server-banner::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image:
          linear-gradient(rgba(83, 252, 24, 0.06) 1px, transparent 1px),
          linear-gradient(90deg, rgba(83, 252, 24, 0.06) 1px, transparent 1px);
        background-size: 14px 14px;
        mask-image: linear-gradient(180deg, #000 30%, transparent);
      }
      .server-content {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        padding: 0 16px;
        gap: 12px;
      }
      .server-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: linear-gradient(
          135deg,
          var(--accent) 0%,
          var(--accent-deep) 100%
        );
        color: #000;
        font-family: var(--font-display);
        font-weight: 800;
        font-size: 19px;
        display: flex;
        align-items: center;
        justify-content: center;
        letter-spacing: -0.06em;
        box-shadow:
          0 0 0 1px rgba(255, 255, 255, 0.07) inset,
          0 4px 14px var(--accent-glow-soft),
          0 0 28px var(--accent-glow-soft);
        flex-shrink: 0;
      }
      .server-info {
        flex: 1;
        min-width: 0;
      }
      /* When an admin uploads a custom server banner, hide the default
         "KVB Chat / LIVE / chat.kvb.gg" overlay so it doesn't sit on top
         of the user's image. The logo (.server-icon) stays visible.
         Toggled by app.js applyServerBranding() via data attributes. */
      .server-banner[data-has-custom-banner] ~ .server-content .server-info {
        display: none;
      }
      .server-name {
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 15px;
        letter-spacing: -0.025em;
        line-height: 1.1;
        margin-bottom: 3px;
      }
      .server-meta {
        display: flex;
        align-items: center;
        gap: 8px;
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.1em;
      }
      .live-pill {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        color: var(--accent);
      }
      .live-dot {
        width: 6px;
        height: 6px;
        background: var(--accent);
        border-radius: 50%;
        box-shadow: 0 0 8px var(--accent-glow);
        animation: pulse 2.4s ease-in-out infinite;
      }

      /* Quick actions */
      .quick-actions {
        display: flex;
        align-items: center;
        padding: 8px 8px 0;
        gap: 4px;
        border-bottom: 1px solid var(--border);
        padding-bottom: 8px;
      }
      .qa-btn {
        flex: 1;
        height: 32px;
        border-radius: var(--radius-sm);
        color: var(--text-3);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.12s;
        position: relative;
      }
      .qa-btn:hover {
        background: var(--surface-3);
        color: var(--text);
      }
      .qa-btn.has-badge::after {
        content: "";
        position: absolute;
        top: 5px;
        right: 6px;
        width: 7px;
        height: 7px;
        background: var(--accent);
        border-radius: 50%;
        border: 2px solid var(--surface);
        box-shadow: 0 0 6px var(--accent-glow);
      }
      .qa-btn svg {
        width: 16px;
        height: 16px;
      }

      /* Channels list */
      .channels {
        flex: 1;
        overflow-y: auto;
        padding: 14px 8px;
      }
      .channel-cat {
        margin-bottom: 18px;
      }
      .channel-cat-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 10px 4px 8px;
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        letter-spacing: 0.14em;
        text-transform: uppercase;
        margin-bottom: 4px;
        cursor: pointer;
        user-select: none;
        transition: color 0.12s;
      }
      .channel-cat-header:hover .cat-name {
        color: var(--text);
      }
      .cat-arrow {
        transition: transform 0.15s;
        flex-shrink: 0;
      }
      .channel-cat.collapsed .cat-arrow {
        transform: rotate(-90deg);
      }
      .cat-actions {
        display: flex;
        gap: 2px;
      }
      .cat-btn {
        width: 18px;
        height: 18px;
        border-radius: 3px;
        color: var(--text-3);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.12s;
      }
      .cat-btn:hover {
        color: var(--text);
        background: var(--surface-3);
      }

      .channel {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 7px 10px;
        border-radius: var(--radius);
        color: var(--text-2);
        font-size: 14px;
        cursor: pointer;
        margin-bottom: 1px;
        position: relative;
        transition: all 0.1s;
        line-height: 1;
      }
      .channel:hover {
        background: var(--surface-2);
        color: var(--text);
      }
      .channel.active {
        background: linear-gradient(
          90deg,
          rgba(83, 252, 24, 0.08),
          rgba(83, 252, 24, 0.02)
        );
        color: var(--text);
        box-shadow: inset 0 0 0 1px rgba(83, 252, 24, 0.08);
      }
      .channel.active::before {
        content: "";
        position: absolute;
        left: -8px;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 22px;
        background: var(--accent);
        border-radius: 0 3px 3px 0;
        box-shadow: 0 0 10px var(--accent-glow);
      }
      .channel.unread {
        color: var(--text);
        font-weight: 500;
      }
      .channel-icon {
        width: 18px;
        height: 18px;
        color: var(--text-4);
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .channel.active .channel-icon {
        color: var(--accent);
      }
      .channel-name {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .channel-meta {
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .unread-pill {
        background: var(--accent);
        color: #001a00;
        font-family: var(--font-mono);
        font-size: 9.5px;
        font-weight: 700;
        padding: 1px 5px;
        border-radius: 4px;
        letter-spacing: 0.02em;
        box-shadow: 0 0 12px var(--accent-glow-soft);
      }
      .mention-pill {
        background: var(--danger);
        color: #fff;
        font-family: var(--font-mono);
        font-size: 9.5px;
        font-weight: 700;
        padding: 1px 5px;
        border-radius: 4px;
      }
      .lock-icon {
        color: var(--text-4);
        display: flex;
        align-items: center;
      }
      .channel.readonly .channel-name {
        color: var(--text-3);
      }
      .channel.readonly:hover .channel-name {
        color: var(--text-2);
      }
      .channel.readonly.active .channel-name {
        color: var(--text);
      }
      .channel.readonly .channel-icon {
        color: var(--text-4);
      }
      .channel.readonly:hover .channel-icon {
        color: var(--text-3);
      }
      .channel.readonly.active .channel-icon {
        color: var(--accent);
      }

      /* Ticket channels */
      .ticket-channel {
        font-family: var(--font-mono);
        font-size: 13px;
      }
      .ticket-channel .channel-name {
        letter-spacing: 0.01em;
      }
      .ticket-channel .ticket-status {
        font-size: 9px;
        padding: 2px 6px;
        border-radius: 3px;
        background: var(--accent-soft);
        color: var(--accent);
        letter-spacing: 0.06em;
        text-transform: uppercase;
        font-weight: 600;
      }
      .ticket-channel .ticket-status.closed {
        background: var(--surface-4);
        color: var(--text-3);
      }
      .ticket-channel .ticket-status.in-progress {
        background: var(--warning-soft);
        color: var(--warning);
      }

      .new-ticket-btn {
        margin: 6px 2px 0;
        padding: 9px 11px;
        border: 1px dashed var(--border-3);
        border-radius: var(--radius);
        color: var(--text-2);
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 9px;
        width: calc(100% - 4px);
        transition: all 0.15s;
        font-weight: 500;
      }
      .new-ticket-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
        background: var(--accent-soft);
        box-shadow: 0 0 24px var(--accent-glow-soft);
      }

      /* User card */
      .user-card {
        height: 60px;
        padding: 0 12px;
        display: flex;
        align-items: center;
        gap: 10px;
        background: linear-gradient(180deg, var(--surface-2), var(--surface));
        border-top: 1px solid var(--border);
        backdrop-filter: blur(12px);
      }
      .user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: linear-gradient(135deg, #4338ca, #7c3aed);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-weight: 600;
        font-size: 12.5px;
        position: relative;
        flex-shrink: 0;
        letter-spacing: -0.02em;
      }
      .user-avatar.kvb-staff {
        background: linear-gradient(
          135deg,
          var(--accent) 0%,
          var(--accent-deep) 100%
        );
        color: #001a00;
      }
      .user-avatar.support {
        background: linear-gradient(135deg, #0891b2, #2563eb);
      }
      .user-avatar.admin {
        background: linear-gradient(135deg, #a855f7, #6d28d9);
      }
      .user-avatar.member-1 {
        background: linear-gradient(135deg, #f59e0b, #ea580c);
      }
      .user-avatar.member-2 {
        background: linear-gradient(135deg, #ec4899, #8b5cf6);
      }
      .user-avatar.member-3 {
        background: linear-gradient(135deg, #06b6d4, #3b82f6);
      }
      .user-avatar.member-4 {
        background: linear-gradient(135deg, #84cc16, #14b8a6);
      }
      .user-avatar.member-5 {
        background: linear-gradient(135deg, #f43f5e, #e11d48);
      }
      .user-avatar.member-6 {
        background: linear-gradient(135deg, #be123c, #831843);
      }
      .user-avatar.member-7 {
        background: linear-gradient(135deg, #2563eb, #1e3a8a);
      }
      .user-avatar.member-8 {
        background: linear-gradient(135deg, #a16207, #78350f);
      }
      .user-avatar.member-9 {
        background: linear-gradient(135deg, #9333ea, #6b21a8);
      }

      /* Role rings around avatars */
      .user-avatar.ring-owner {
        box-shadow:
          0 0 0 2px var(--bg),
          0 0 0 4px var(--accent),
          0 0 20px var(--accent-glow);
      }
      .user-avatar.ring-admin {
        box-shadow:
          0 0 0 2px var(--bg),
          0 0 0 4px var(--role-admin);
      }
      .user-avatar.ring-support {
        box-shadow:
          0 0 0 2px var(--bg),
          0 0 0 4px var(--role-support);
      }
      .user-avatar.ring-owner::after {
        content: "";
        position: absolute;
        top: -3px;
        right: -3px;
        width: 12px;
        height: 12px;
        background: var(--accent)
          url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M5 16L3 7l5.5 5L12 4l3.5 8L21 7l-2 9H5zm0 2v3h14v-3H5z'/%3E%3C/svg%3E")
          center/8px no-repeat;
        border: 2px solid var(--bg);
        border-radius: 50%;
        z-index: 2;
      }

      .user-avatar .status {
        position: absolute;
        bottom: -2px;
        right: -2px;
        width: 12px;
        height: 12px;
        background: var(--text-3);
        border: 2.5px solid var(--surface);
        border-radius: 50%;
      }
      .user-avatar .status.online {
        background: var(--accent);
      }
      .user-avatar .status.away {
        background: var(--warning);
      }
      .user-avatar .status.dnd {
        background: var(--danger);
      }
      .user-info {
        flex: 1;
        min-width: 0;
      }
      .user-name {
        font-size: 13.5px;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: -0.005em;
      }
      .user-handle {
        font-size: 11px;
        color: var(--text-3);
        font-family: var(--font-mono);
      }
      .user-actions {
        display: flex;
        gap: 2px;
      }
      .icon-btn {
        width: 30px;
        height: 30px;
        border-radius: var(--radius-sm);
        color: var(--text-3);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.12s;
      }
      .icon-btn:hover {
        background: var(--surface-3);
        color: var(--text);
      }
      .icon-btn svg {
        width: 16px;
        height: 16px;
      }

      /* ============================== MAIN CHAT ============================== */
      .main {
        display: flex;
        flex-direction: column;
        background: var(--bg);
        min-width: 0;
        position: relative;
        height: 100%;
        overflow: hidden;
      }

      .chat-header {
        height: 56px;
        padding: 0 22px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        background: linear-gradient(180deg, var(--surface), var(--bg));
        backdrop-filter: blur(12px);
        z-index: 5;
      }
      .chat-title {
        display: flex;
        align-items: center;
        gap: 11px;
        min-width: 0;
      }
      .chat-title-icon {
        color: var(--text-3);
        width: 20px;
        height: 20px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .chat-name {
        font-size: 15.5px;
        font-weight: 600;
        letter-spacing: -0.015em;
        white-space: nowrap;
      }
      .chat-divider {
        width: 1px;
        height: 22px;
        background: var(--border-2);
        margin: 0 6px;
      }
      .chat-topic {
        color: var(--text-3);
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1;
      }
      .chat-actions {
        display: flex;
        gap: 4px;
        align-items: center;
      }
      .chat-search {
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-radius: 999px;
        padding: 6px 14px 6px 32px;
        font-size: 12.5px;
        color: var(--text);
        width: 200px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 11px center;
        background-size: 13px;
        outline: none;
        transition: all 0.18s;
      }
      .chat-search:focus {
        border-color: var(--accent);
        width: 240px;
        box-shadow: 0 0 0 4px var(--accent-soft);
      }

      /* Pinned strip */
      .pinned-strip {
        background: linear-gradient(
          180deg,
          rgba(251, 191, 36, 0.05),
          transparent
        );
        border-bottom: 1px solid var(--border);
        padding: 8px 22px;
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 12.5px;
        color: var(--text-2);
      }
      .pinned-strip .icon {
        color: var(--warning);
        flex-shrink: 0;
      }
      .pinned-strip .author {
        color: var(--accent);
        font-weight: 500;
      }
      .pinned-strip .preview {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--text-3);
      }

      /* Ticket header bar */
      .ticket-bar {
        background: linear-gradient(180deg, var(--surface-2), transparent);
        border-bottom: 1px solid var(--border);
        padding: 16px 22px;
        display: flex;
        align-items: center;
        gap: 18px;
        font-size: 13px;
      }
      .ticket-bar-item {
        display: flex;
        align-items: center;
        gap: 7px;
        color: var(--text-2);
      }
      .ticket-bar-item .label {
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.12em;
      }
      .ticket-bar-spacer {
        flex: 1;
      }

      .badge {
        padding: 3px 9px;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 600;
        font-family: var(--font-mono);
        letter-spacing: 0.04em;
        text-transform: uppercase;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border: 1px solid currentColor;
      }
      .badge-open {
        background: var(--accent-soft);
        color: var(--accent);
        border-color: var(--accent-soft-2);
      }
      .badge-progress {
        background: var(--warning-soft);
        color: var(--warning);
        border-color: rgba(251, 191, 36, 0.22);
      }
      .badge-closed {
        background: var(--surface-4);
        color: var(--text-3);
        border-color: var(--border-3);
      }
      .badge-priority-high {
        background: var(--danger-soft);
        color: var(--danger);
        border-color: rgba(248, 113, 113, 0.22);
      }
      .badge-priority-medium {
        background: var(--warning-soft);
        color: var(--warning);
        border-color: rgba(251, 191, 36, 0.22);
      }
      .badge-priority-low {
        background: var(--info-soft);
        color: var(--info);
        border-color: rgba(96, 165, 250, 0.22);
      }
      .badge::before {
        content: "";
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: currentColor;
        box-shadow: 0 0 8px currentColor;
      }

      /* ============================== MESSAGES ============================== */
      .messages {
        flex: 1;
        overflow-y: auto;
        padding: 16px 0 8px;
        display: flex;
        flex-direction: column;
        gap: 1px;
        scroll-behavior: smooth;
      }
      .day-divider {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 22px 22px 14px;
        color: var(--text-3);
        font-size: 10.5px;
        font-family: var(--font-mono);
        letter-spacing: 0.16em;
      }
      .day-divider::before,
      .day-divider::after {
        content: "";
        flex: 1;
        height: 1px;
        background: linear-gradient(
          90deg,
          transparent,
          var(--border-2),
          transparent
        );
      }
      .day-divider .label {
        background: var(--surface);
        border: 1px solid var(--border-2);
        padding: 4px 12px;
        border-radius: 999px;
      }

      .new-divider {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 22px;
        color: var(--accent);
        font-size: 10.5px;
        font-family: var(--font-mono);
        letter-spacing: 0.16em;
        font-weight: 600;
      }
      .new-divider::before,
      .new-divider::after {
        content: "";
        flex: 1;
        height: 1px;
        background: var(--accent);
        opacity: 0.4;
      }

      .message {
        padding: 4px 22px 4px 22px;
        display: grid;
        grid-template-columns: 40px 1fr;
        gap: 14px;
        position: relative;
        transition: background 0.1s;
      }
      .message:hover {
        background: rgba(255, 255, 255, 0.018);
      }
      .message:hover .msg-actions {
        opacity: 1;
        transform: translateY(0);
      }
      .message.first-of-group {
        padding-top: 14px;
      }
      .message-avatar {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        grid-row: span 2;
        cursor: pointer;
        transition: transform 0.12s;
      }
      .message-avatar:hover {
        transform: scale(1.05);
      }
      .message.continued .message-avatar {
        visibility: hidden;
        height: 0;
      }
      .message.continued {
        padding-top: 1px;
        padding-bottom: 1px;
      }
      .message.continued .msg-meta {
        display: none;
      }
      .message.continued .msg-time-inline {
        display: block;
        position: absolute;
        left: 22px;
        top: 50%;
        transform: translateY(-50%);
        width: 38px;
        text-align: center;
        font-family: var(--font-mono);
        font-size: 10.5px;
        color: var(--text-4);
        opacity: 0;
        transition: opacity 0.12s;
      }
      .message.continued:hover .msg-time-inline {
        opacity: 1;
      }

      /* Reply quote — clean inline reply pill above the actual message. */
      .msg-reply-quote {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 4px;
        font-size: 12.5px;
        color: var(--text-3);
        cursor: pointer;
        max-width: 100%;
        transition: color 0.12s;
      }
      .msg-reply-quote .reply-icon {
        flex-shrink: 0;
        opacity: 0.55;
        transition: opacity 0.12s;
      }
      .msg-reply-quote:hover { color: var(--text-2); }
      .msg-reply-quote:hover .reply-icon { opacity: 0.95; }
      .msg-reply-quote .reply-avatar {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        flex-shrink: 0;
      }
      .msg-reply-quote .reply-author {
        color: var(--text-2);
        font-weight: 500;
      }
      .msg-reply-quote .reply-author.staff-owner {
        color: var(--accent);
      }
      .msg-reply-quote .reply-author.staff-support {
        color: var(--info);
      }
      .msg-reply-quote:hover .reply-text {
        color: var(--text);
      }
      .msg-reply-quote .reply-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 360px;
        transition: color 0.12s;
      }

      .msg-meta {
        display: flex;
        align-items: baseline;
        gap: 8px;
        margin-bottom: 3px;
      }
      .msg-author {
        font-weight: 600;
        font-size: 14.5px;
        letter-spacing: -0.015em;
        cursor: pointer;
      }
      .msg-author:hover {
        text-decoration: underline;
        text-decoration-thickness: 1.5px;
        text-underline-offset: 3px;
      }
      .msg-author.staff-owner {
        color: var(--accent);
      }
      .msg-author.staff-admin {
        color: var(--role-admin);
      }
      .msg-author.staff-support {
        color: var(--role-support);
      }

      .msg-role-badge {
        font-family: var(--font-mono);
        font-size: 9px;
        padding: 2px 6px;
        border-radius: 4px;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        font-weight: 600;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        line-height: 1;
      }
      .msg-role-badge svg {
        width: 8px;
        height: 8px;
      }
      .msg-role-badge.owner {
        background: var(--accent-soft-2);
        color: var(--accent);
        border: 1px solid var(--accent-soft-2);
      }
      .msg-role-badge.admin {
        background: var(--role-admin-soft);
        color: var(--role-admin);
        border: 1px solid var(--role-admin-soft);
      }
      .msg-role-badge.support {
        background: var(--role-support-soft);
        color: var(--role-support);
        border: 1px solid var(--role-support-soft);
      }
      .msg-role-badge.system {
        background: var(--surface-3);
        color: var(--text-3);
      }

      .msg-time {
        font-family: var(--font-mono);
        font-size: 11px;
        color: var(--text-3);
      }
      .msg-edited {
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-4);
        margin-left: 4px;
      }

      .msg-content {
        color: var(--text);
        font-size: 14.5px;
        line-height: 1.5;
        word-wrap: break-word;
      }
      .msg-content code {
        font-family: var(--font-mono);
        font-size: 12.5px;
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        padding: 1.5px 6px;
        border-radius: 4px;
        color: var(--accent);
      }
      .msg-content a {
        color: var(--info);
        text-decoration: underline;
        text-decoration-color: rgba(96, 165, 250, 0.4);
      }
      .msg-content strong {
        font-weight: 600;
      }
      .msg-content em {
        font-style: italic;
      }

      .msg-content .mention {
        background: var(--accent-soft);
        color: var(--accent);
        padding: 1px 5px;
        border-radius: 4px;
        font-weight: 500;
        cursor: pointer;
        transition: background 0.12s;
      }
      .msg-content .mention:hover {
        background: var(--accent-soft-2);
      }
      .msg-content .mention.role {
        background: var(--role-support-soft);
        color: var(--role-support);
      }

      /* Code block */
      .msg-codeblock {
        margin-top: 6px;
        background: var(--bg-deep);
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        overflow: hidden;
        max-width: 720px;
      }
      .msg-codeblock-header {
        background: var(--surface-2);
        border-bottom: 1px solid var(--border);
        padding: 6px 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-family: var(--font-mono);
        font-size: 11px;
        color: var(--text-3);
        text-transform: lowercase;
      }
      .msg-codeblock-header .copy-btn {
        color: var(--text-3);
        font-size: 10.5px;
        text-transform: uppercase;
        letter-spacing: 0.1em;
      }
      .msg-codeblock-header .copy-btn:hover {
        color: var(--text);
      }
      .msg-codeblock pre {
        font-family: var(--font-mono);
        font-size: 12.5px;
        line-height: 1.5;
        padding: 12px 14px;
        color: var(--text-2);
        overflow-x: auto;
      }
      .msg-codeblock .kw {
        color: var(--pink);
      }
      .msg-codeblock .str {
        color: var(--accent);
      }
      .msg-codeblock .num {
        color: var(--warning);
      }
      .msg-codeblock .comment {
        color: var(--text-4);
        font-style: italic;
      }

      /* Link embed */
      .msg-embed {
        margin-top: 8px;
        max-width: 460px;
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-left: 3px solid var(--accent);
        border-radius: var(--radius);
        overflow: hidden;
        display: flex;
        transition: border-color 0.15s;
        cursor: pointer;
      }
      .msg-embed:hover {
        border-color: var(--border-3);
        border-left-color: var(--accent-2);
      }
      .msg-embed-content {
        flex: 1;
        padding: 12px 14px;
        min-width: 0;
      }
      .msg-embed-site {
        font-family: var(--font-mono);
        font-size: 10.5px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.1em;
        margin-bottom: 5px;
        display: flex;
        align-items: center;
        gap: 5px;
      }
      .msg-embed-title {
        font-size: 14px;
        font-weight: 600;
        color: var(--info);
        line-height: 1.3;
        margin-bottom: 4px;
        letter-spacing: -0.01em;
      }
      .msg-embed-desc {
        font-size: 12.5px;
        color: var(--text-2);
        line-height: 1.45;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
      }
      .msg-embed-thumb {
        width: 90px;
        background: linear-gradient(135deg, var(--accent-deep), #052804);
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--accent);
        font-family: var(--font-mono);
        font-size: 24px;
        font-weight: 700;
      }

      /* Image attachment */
      .msg-image {
        margin-top: 8px;
        max-width: 420px;
        border-radius: var(--radius-lg);
        overflow: hidden;
        border: 1px solid var(--border-2);
        background: var(--surface-2);
        cursor: pointer;
        position: relative;
        aspect-ratio: 16/9;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .msg-image-preview {
        width: 100%;
        height: 100%;
        background: linear-gradient(
          135deg,
          #1a2840 0%,
          #052804 50%,
          #14161d 100%
        );
        position: relative;
        overflow: hidden;
      }
      .msg-image-preview::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image:
          radial-gradient(
            circle at 30% 40%,
            rgba(83, 252, 24, 0.4),
            transparent 25%
          ),
          radial-gradient(
            circle at 70% 70%,
            rgba(96, 165, 250, 0.3),
            transparent 25%
          );
      }
      .msg-image-overlay {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 14px;
        background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.7));
        color: #fff;
        font-family: var(--font-mono);
        font-size: 11px;
        display: flex;
        justify-content: space-between;
      }

      /* File attachment */
      .msg-file {
        margin-top: 6px;
        max-width: 380px;
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        background: var(--surface-2);
        padding: 10px 12px;
        display: flex;
        align-items: center;
        gap: 12px;
        transition: border-color 0.15s;
        cursor: pointer;
      }
      .msg-file:hover {
        border-color: var(--border-3);
      }
      .msg-file-icon {
        width: 36px;
        height: 36px;
        background: var(--surface-3);
        border: 1px solid var(--border-2);
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--accent);
        flex-shrink: 0;
      }
      .msg-file-info {
        flex: 1;
        min-width: 0;
      }
      .msg-file-name {
        font-weight: 500;
        font-size: 13px;
        line-height: 1.3;
      }
      .msg-file-meta {
        font-family: var(--font-mono);
        font-size: 10.5px;
        color: var(--text-3);
        margin-top: 2px;
      }
      .msg-file-dl {
        color: var(--text-3);
      }
      .msg-file:hover .msg-file-dl {
        color: var(--accent);
      }

      /* Reactions */
      .msg-reactions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-top: 6px;
      }
      .reaction {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 3px 8px;
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-radius: 999px;
        font-family: var(--font-mono);
        font-size: 11.5px;
        color: var(--text-2);
        cursor: pointer;
        transition: all 0.12s;
      }
      .reaction:hover {
        background: var(--surface-3);
        border-color: var(--border-3);
        transform: translateY(-1px);
      }
      .reaction.mine {
        background: var(--accent-soft);
        border-color: var(--accent-soft-2);
        color: var(--accent);
      }
      .reaction-emoji {
        font-size: 13px;
        line-height: 1;
      }
      .reaction-add {
        width: 26px;
        padding: 3px 6px;
        color: var(--text-3);
        background: transparent;
        border-style: dashed;
      }
      .reaction-add:hover {
        color: var(--text);
        border-color: var(--border-3);
      }

      /* Replies indicator */
      .msg-replies {
        margin-top: 6px;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-radius: var(--radius-sm);
        font-size: 12px;
        color: var(--text-2);
        cursor: pointer;
        transition: all 0.12s;
      }
      .msg-replies:hover {
        border-color: var(--info);
        color: var(--text);
      }
      .msg-replies .stack {
        display: flex;
      }
      .msg-replies .stack .user-avatar {
        width: 18px;
        height: 18px;
        font-size: 9px;
        margin-right: -5px;
        border: 2px solid var(--bg);
      }
      .msg-replies .count {
        color: var(--info);
        font-weight: 500;
      }

      .msg-actions {
        position: absolute;
        top: -16px;
        right: 22px;
        background: var(--surface-3);
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        padding: 3px;
        display: flex;
        gap: 1px;
        opacity: 0;
        pointer-events: none;
        transform: translateY(4px);
        transition:
          opacity 0.15s,
          transform 0.15s;
        /* Lighter shadow so it doesn't bleed into the previous row when the
           toolbar floats above tightly-stacked messages. */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(12px);
      }
      .message:hover .msg-actions {
        pointer-events: auto;
      }
      /* Stacked jumbo-emoji rows have almost zero vertical padding, so the
         default top:-16 toolbar floats above the row — its drop-shadow then
         falls onto the PREVIOUS message and looks misaligned. Pin the
         toolbar inside the row for jumbo-emoji + continued combos. */
      .message.msg-jumbo .msg-actions,
      .message.continued .msg-actions {
        top: -10px;
      }
      .message.continued.msg-jumbo .msg-actions {
        top: 4px;
        right: 16px;
      }
      .msg-action-btn {
        width: 30px;
        height: 30px;
        border-radius: var(--radius-sm);
        color: var(--text-2);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.12s;
      }
      .msg-action-btn svg {
        width: 15px;
        height: 15px;
      }
      .msg-action-btn:hover {
        background: var(--surface-4);
        color: var(--text);
      }
      .msg-action-btn.danger:hover {
        background: var(--danger-soft);
        color: var(--danger);
      }
      .msg-action-btn.accent:hover {
        color: var(--accent);
      }

      .msg-deleted .msg-content {
        font-style: italic;
        color: var(--text-3);
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 10px;
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-radius: var(--radius-sm);
        width: fit-content;
      }

      .msg-pinned-mark {
        position: absolute;
        top: 50%;
        left: 6px;
        transform: translateY(-50%);
        color: var(--warning);
        opacity: 0;
        transition: opacity 0.12s;
        width: 12px;
        height: 12px;
      }
      .message.pinned .msg-pinned-mark {
        opacity: 0.6;
      }
      .message.pinned {
        background: linear-gradient(
          90deg,
          rgba(251, 191, 36, 0.04),
          transparent 30%
        );
      }

      .system-message {
        padding: 12px 22px;
        color: var(--text-3);
        font-size: 12.5px;
        font-family: var(--font-mono);
        display: flex;
        align-items: center;
        gap: 10px;
      }
      .system-message .icon {
        width: 18px;
        height: 18px;
        background: var(--surface-3);
        border: 1px solid var(--border-2);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--accent);
        flex-shrink: 0;
      }
      .system-message .icon svg {
        width: 11px;
        height: 11px;
      }

      /* Typing indicator */
      .typing-indicator {
        padding: 6px 22px 14px;
        color: var(--text-3);
        font-size: 12.5px;
        height: 30px;
        display: flex;
        align-items: center;
        gap: 8px;
        font-family: var(--font-mono);
      }
      .typing-dots {
        display: inline-flex;
        gap: 3px;
        padding: 5px 10px;
        background: var(--surface-2);
        border-radius: 999px;
        border: 1px solid var(--border-2);
      }
      .typing-dots span {
        width: 4px;
        height: 4px;
        background: var(--accent);
        border-radius: 50%;
        animation: typing 1.4s infinite ease-in-out;
      }
      .typing-dots span:nth-child(2) {
        animation-delay: 0.2s;
      }
      .typing-dots span:nth-child(3) {
        animation-delay: 0.4s;
      }
      @keyframes typing {
        0%,
        60%,
        100% {
          opacity: 0.3;
          transform: translateY(0);
        }
        30% {
          opacity: 1;
          transform: translateY(-3px);
        }
      }

      /* ============================== COMPOSER ============================== */
      .composer-wrap {
        padding: 0 22px 20px;
        flex-shrink: 0;
      }
      .composer-reply {
        background: var(--surface-2);
        border: 1px solid var(--border-2);
        border-bottom: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 8px 14px;
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 12.5px;
        color: var(--text-3);
        margin-bottom: -1px;
      }
      .composer-reply .label {
        color: var(--text-2);
      }
      .composer-reply .who {
        color: var(--accent);
        font-weight: 500;
      }
      .composer-reply .close-btn {
        margin-left: auto;
        color: var(--text-3);
        width: 22px;
        height: 22px;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .composer-reply .close-btn:hover {
        color: var(--text);
        background: var(--surface-3);
      }

      .composer {
        background: linear-gradient(180deg, var(--surface), var(--surface-2));
        border: 1px solid var(--border-2);
        border-radius: var(--radius-lg);
        transition:
          border-color 0.15s,
          box-shadow 0.15s;
        position: relative;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
      }
      .composer:focus-within {
        border-color: var(--border-3);
        box-shadow:
          0 0 0 4px rgba(255, 255, 255, 0.025),
          0 8px 24px rgba(0, 0, 0, 0.18);
      }
      .composer-input {
        width: 100%;
        background: transparent;
        border: none;
        padding: 14px 16px 6px;
        color: var(--text);
        font-size: 14.5px;
        outline: none;
        resize: none;
        min-height: 24px;
        max-height: 200px;
        line-height: 1.55;
        font-family: inherit;
      }
      .composer-toolbar {
        display: flex;
        align-items: center;
        padding: 6px 10px 10px;
        gap: 2px;
      }
      .composer-toolbar .icon-btn {
        width: 32px;
        height: 32px;
      }
      .composer-spacer {
        flex: 1;
      }
      .composer-divider {
        width: 1px;
        height: 18px;
        background: var(--border-2);
        margin: 0 4px;
      }
      .char-count {
        font-family: var(--font-mono);
        font-size: 10.5px;
        color: var(--text-3);
        margin-right: 10px;
      }
      .send-btn {
        background: linear-gradient(180deg, var(--accent), var(--accent-deep));
        color: #001a00;
        border-radius: var(--radius-sm);
        padding: 7px 14px;
        font-size: 12.5px;
        font-weight: 600;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        transition: all 0.15s;
        box-shadow:
          inset 0 1px 0 rgba(255, 255, 255, 0.18),
          0 0 0 0 var(--accent-glow);
      }
      .send-btn:hover {
        box-shadow:
          inset 0 1px 0 rgba(255, 255, 255, 0.24),
          0 0 18px var(--accent-glow-soft);
        transform: translateY(-1px);
      }
      .send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
      }
      .send-btn svg {
        width: 12px;
        height: 12px;
      }
      .send-shortcut {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: rgba(0, 26, 0, 0.6);
        background: rgba(0, 0, 0, 0.12);
        padding: 1px 4px;
        border-radius: 3px;
        font-weight: 700;
      }

      /* Slash command preview */
      .slash-preview {
        position: absolute;
        bottom: calc(100% + 8px);
        left: 0;
        right: 0;
        background: var(--surface);
        border: 1px solid var(--border-2);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        overflow: hidden;
        backdrop-filter: blur(20px);
      }
      .slash-header {
        padding: 8px 14px;
        border-bottom: 1px solid var(--border);
        font-family: var(--font-mono);
        font-size: 10.5px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.14em;
        background: var(--surface-2);
      }
      .slash-cmd {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        cursor: pointer;
        transition: background 0.1s;
      }
      .slash-cmd:hover,
      .slash-cmd.active {
        background: var(--surface-3);
      }
      .slash-cmd .name {
        font-family: var(--font-mono);
        color: var(--accent);
        font-size: 13px;
        font-weight: 500;
        flex-shrink: 0;
      }
      .slash-cmd .desc {
        color: var(--text-3);
        font-size: 12.5px;
      }

      /* ============================== MEMBERS / SIDE PANEL ============================== */
      .members {
        background: var(--surface);
        border-left: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        min-width: 0;
      }
      .members-header {
        height: 56px;
        padding: 0 18px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        background: linear-gradient(
          180deg,
          var(--surface),
          rgba(15, 17, 22, 0.6)
        );
      }
      .members-header .title {
        font-family: var(--font-display);
        font-size: 13px;
        font-weight: 600;
        letter-spacing: -0.01em;
        color: var(--text-2);
        text-transform: uppercase;
        letter-spacing: 0.06em;
      }
      .members-header-actions {
        display: flex;
        gap: 2px;
      }

      /* Channel info card at top of side panel */
      .channel-info-card {
        margin: 14px 14px 4px;
        padding: 14px;
        background: linear-gradient(180deg, var(--surface-2), var(--surface));
        border: 1px solid var(--border-2);
        border-radius: var(--radius-lg);
        position: relative;
        overflow: hidden;
      }
      .channel-info-card::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: linear-gradient(
          90deg,
          transparent,
          var(--accent-soft-2),
          transparent
        );
      }
      .channel-info-name {
        display: flex;
        align-items: center;
        gap: 6px;
        font-family: var(--font-display);
        font-size: 14px;
        font-weight: 600;
        letter-spacing: -0.02em;
        margin-bottom: 6px;
      }
      .channel-info-name .hash {
        color: var(--text-4);
        font-family: var(--font-mono);
        font-weight: 400;
      }
      .channel-info-desc {
        font-size: 12.5px;
        color: var(--text-3);
        line-height: 1.5;
        margin-bottom: 12px;
      }
      .channel-info-stats {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
        padding-top: 12px;
        border-top: 1px dashed var(--border-2);
      }
      .channel-info-stat {
        display: flex;
        flex-direction: column;
        gap: 2px;
      }
      .channel-info-stat .num {
        font-family: var(--font-display);
        font-size: 16px;
        font-weight: 600;
        letter-spacing: -0.025em;
        color: var(--text);
        line-height: 1;
      }
      .channel-info-stat .num.live::after {
        content: "";
        display: inline-block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--accent);
        box-shadow: 0 0 8px var(--accent-glow);
        margin-left: 6px;
        animation: pulse 2.4s ease-in-out infinite;
        vertical-align: middle;
      }
      .channel-info-stat .lbl {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.12em;
      }

      /* Member list */
      .members-list {
        flex: 1;
        overflow-y: auto;
        padding: 12px 8px 8px;
      }
      .members-section {
        position: relative;
        padding-left: 2px;
        margin-bottom: 16px;
      }
      .members-section-label {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        letter-spacing: 0.16em;
        text-transform: uppercase;
        padding: 2px 8px 6px 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
      }
      .members-section-label::before {
        content: "";
        position: absolute;
        left: 4px;
        top: 5px;
        bottom: 8px;
        width: 2px;
        border-radius: 1px;
        background: var(--text-5);
      }
      .members-section.role-owner .members-section-label::before {
        background: var(--accent);
        box-shadow: 0 0 6px var(--accent-glow-soft);
      }
      .members-section.role-admin .members-section-label::before {
        background: var(--role-admin);
      }
      .members-section.role-support .members-section-label::before {
        background: var(--role-support);
      }
      .members-section-label .lbl-name {
        color: var(--text-3);
      }
      .members-section.role-owner .members-section-label .lbl-name {
        color: var(--accent);
      }
      .members-section.role-admin .members-section-label .lbl-name {
        color: var(--role-admin);
      }
      .members-section.role-support .members-section-label .lbl-name {
        color: var(--role-support);
      }
      .members-section-label .lbl-count {
        color: var(--text-4);
        font-size: 9.5px;
      }

      .member {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 5px 10px 5px 12px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition:
          background 0.12s,
          transform 0.12s;
        position: relative;
      }
      .member:hover {
        background: var(--surface-2);
      }
      .member:active {
        transform: scale(0.99);
      }
      .member-avatar {
        width: 26px;
        height: 26px;
        border-radius: 50%;
        flex-shrink: 0;
        position: relative;
        font-size: 10px !important;
      }
      .member-avatar > span {
        font-size: 10px !important;
      }
      .member-avatar .status {
        position: absolute;
        bottom: -2px;
        right: -2px;
        width: 9px;
        height: 9px;
        background: var(--text-4);
        border: 2px solid var(--surface);
        border-radius: 50%;
      }
      .member:hover .member-avatar .status {
        border-color: var(--surface-2);
      }
      .member-avatar .status.online {
        background: var(--accent);
        box-shadow: 0 0 4px var(--accent-glow-soft);
      }
      .member-avatar .status.away {
        background: var(--warning);
      }
      .member-avatar .status.dnd {
        background: var(--danger);
      }
      .member-info {
        min-width: 0;
        flex: 1;
      }
      .member-name {
        font-size: 13px;
        color: var(--text-2);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        align-items: center;
        gap: 4px;
        line-height: 1.3;
      }
      .member:hover .member-name {
        color: var(--text);
      }
      .member-name.owner {
        color: var(--accent);
        font-weight: 600;
      }
      .member-name.admin {
        color: var(--role-admin);
        font-weight: 500;
      }
      .member-name.support {
        color: var(--role-support);
        font-weight: 500;
      }
      .member-name.offline {
        color: var(--text-4);
      }
      .member-name svg {
        width: 10px;
        height: 10px;
        flex-shrink: 0;
        opacity: 0.85;
      }
      .member-status-text {
        font-size: 10.5px;
        color: var(--text-4);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 0px;
        font-family: var(--font-mono);
      }

      /* Activity badge in member */
      .member-activity {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        color: var(--accent);
        font-size: 10px;
      }
      .member-activity svg {
        width: 8px;
        height: 8px;
      }

      /* Offline expand button */
      .members-offline-toggle {
        width: calc(100% - 16px);
        margin: 8px 8px 0;
        padding: 9px 12px;
        background: transparent;
        border: 1px dashed var(--border-2);
        border-radius: var(--radius-sm);
        color: var(--text-3);
        font-family: var(--font-mono);
        font-size: 10.5px;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: all 0.15s;
      }
      .members-offline-toggle:hover {
        border-color: var(--border-3);
        color: var(--text-2);
        background: var(--surface-2);
      }
      .members-offline-toggle svg {
        width: 11px;
        height: 11px;
        transition: transform 0.2s;
      }
      .members-offline-toggle.open svg {
        transform: rotate(180deg);
      }
      .members-offline-section {
        display: none;
        margin-top: 10px;
      }
      .members-offline-section.open {
        display: block;
      }

      /* Ticket info panel (in ticket view) */
      .ticket-panel {
        flex: 1;
        overflow-y: auto;
        padding: 14px 14px 18px;
        display: flex;
        flex-direction: column;
        gap: 14px;
      }
      .ticket-panel-card {
        background: linear-gradient(180deg, var(--surface-2), var(--surface));
        border: 1px solid var(--border-2);
        border-radius: var(--radius-lg);
        padding: 14px;
        position: relative;
        overflow: hidden;
      }
      .ticket-panel-card.featured::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: linear-gradient(
          90deg,
          transparent,
          var(--warning),
          transparent
        );
        opacity: 0.7;
      }
      .ticket-panel-label {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        letter-spacing: 0.16em;
        text-transform: uppercase;
        margin-bottom: 8px;
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .ticket-panel-label::before {
        content: "";
        width: 3px;
        height: 3px;
        border-radius: 50%;
        background: var(--text-4);
      }
      .ticket-panel-value {
        font-size: 13.5px;
        line-height: 1.5;
        font-weight: 500;
        color: var(--text);
      }
      .ticket-panel-value.mono {
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--text-2);
        word-break: break-all;
        font-weight: 400;
      }
      .ticket-panel-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--accent);
        padding: 5px 10px;
        background: var(--accent-soft);
        border: 1px solid var(--accent-soft-2);
        border-radius: 6px;
        font-weight: 500;
      }
      .ticket-panel-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
      }
      .ticket-panel-mini {
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 10px 12px;
      }
      .ticket-panel-mini .num {
        font-family: var(--font-display);
        font-size: 18px;
        font-weight: 600;
        letter-spacing: -0.025em;
        color: var(--text);
        line-height: 1;
        margin-bottom: 4px;
      }
      .ticket-panel-mini .lbl {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.12em;
      }
      .ticket-panel-participants .member {
        padding-left: 0;
        padding-right: 0;
      }
      .ticket-activity {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 4px;
      }
      .ticket-activity-item {
        display: grid;
        grid-template-columns: 18px 1fr;
        gap: 10px;
        align-items: flex-start;
        font-family: var(--font-mono);
        font-size: 11.5px;
        color: var(--text-2);
        line-height: 1.4;
      }
      .ticket-activity-item .time {
        color: var(--text-4);
        font-size: 10px;
        margin-left: 4px;
      }
      .ticket-activity-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        margin-top: 5px;
        margin-left: 5px;
        box-shadow: 0 0 0 3px var(--surface);
        flex-shrink: 0;
      }
      .ticket-activity-dot.accent {
        background: var(--accent);
        box-shadow:
          0 0 0 3px var(--surface),
          0 0 8px var(--accent-glow-soft);
      }
      .ticket-activity-dot.info {
        background: var(--info);
      }
      .ticket-activity-dot.warning {
        background: var(--warning);
      }
      .ticket-activity-dot.pending {
        background: transparent;
        border: 1.5px dashed var(--text-4);
        width: 9px;
        height: 9px;
        margin-top: 4.5px;
        box-shadow: 0 0 0 3px var(--surface);
      }
      .ticket-activity-line {
        position: relative;
        padding-left: 9px;
        border-left: 1px dashed var(--border-2);
        margin-left: 9px;
        padding-bottom: 0;
      }

      /* ============================== SETTINGS / PROFILE SCREEN ============================== */
      .settings-shell {
        width: 100%;
        height: 100vh;
        display: grid;
        grid-template-columns: 280px 1fr;
        background: var(--bg);
        position: relative;
        z-index: 2;
      }
      .settings-sidebar {
        background: var(--surface);
        border-right: 1px solid var(--border);
        padding: 60px 14px 20px;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
      }
      .settings-sidebar-section {
        margin-bottom: 16px;
      }
      .settings-sidebar-label {
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        letter-spacing: 0.16em;
        text-transform: uppercase;
        padding: 6px 12px 8px;
      }
      .settings-nav-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 7px 12px;
        border-radius: var(--radius-sm);
        color: var(--text-2);
        font-size: 14px;
        cursor: pointer;
        transition: all 0.15s;
        margin-bottom: 1px;
      }
      .settings-nav-item:hover {
        background: var(--surface-2);
        color: var(--text);
      }
      .settings-nav-item.active {
        background: var(--surface-3);
        color: var(--text);
        font-weight: 500;
      }
      .settings-nav-item.danger {
        color: var(--danger);
      }
      .settings-nav-item.danger:hover {
        background: var(--danger-soft);
      }
      .settings-nav-item svg {
        width: 15px;
        height: 15px;
        opacity: 0.85;
      }
      .settings-divider {
        height: 1px;
        background: var(--border);
        margin: 10px 12px;
      }

      .settings-main {
        overflow-y: auto;
        padding: 60px 56px 80px;
        max-width: 900px;
        width: 100%;
        position: relative;
      }
      .settings-close {
        position: fixed;
        top: 28px;
        right: 32px;
        width: 38px;
        height: 38px;
        border-radius: 50%;
        border: 1px solid var(--border-2);
        background: var(--surface);
        color: var(--text-2);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.15s;
        z-index: 5;
      }
      .settings-close::after {
        content: "ESC";
        position: absolute;
        top: 100%;
        right: 0;
        margin-top: 6px;
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        letter-spacing: 0.12em;
      }
      .settings-close:hover {
        color: var(--text);
        border-color: var(--border-3);
        background: var(--surface-2);
      }

      .settings-section {
        margin-bottom: 48px;
      }
      .settings-section-title {
        font-family: var(--font-display);
        font-size: 20px;
        font-weight: 600;
        letter-spacing: -0.025em;
        margin-bottom: 6px;
        color: var(--text);
      }
      .settings-section-sub {
        color: var(--text-3);
        font-size: 13px;
        margin-bottom: 24px;
        line-height: 1.55;
      }

      /* Profile preview card */
      .profile-preview-wrap {
        margin-bottom: 36px;
      }
      .profile-preview {
        background: linear-gradient(180deg, var(--surface-2), var(--surface));
        border: 1px solid var(--border-2);
        border-radius: var(--radius-xl);
        overflow: hidden;
        max-width: 380px;
        box-shadow: var(--shadow);
      }
      .profile-preview-banner {
        height: 110px;
        background:
          radial-gradient(
            ellipse at top right,
            var(--accent-glow) 0%,
            transparent 50%
          ),
          linear-gradient(135deg, #0d4f04 0%, #07390a 50%, #0a0b0e 100%);
        position: relative;
        overflow: hidden;
      }
      .profile-preview-banner::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image:
          linear-gradient(rgba(83, 252, 24, 0.04) 1px, transparent 1px),
          linear-gradient(90deg, rgba(83, 252, 24, 0.04) 1px, transparent 1px);
        background-size: 24px 24px;
        mask-image: linear-gradient(180deg, transparent, #000);
      }
      .profile-preview-banner-edit {
        position: absolute;
        top: 12px;
        right: 12px;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(6px);
        border: 1px solid rgba(255, 255, 255, 0.12);
        color: #fff;
        padding: 5px 10px;
        border-radius: 6px;
        font-size: 11px;
        font-weight: 500;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        z-index: 2;
      }
      .profile-preview-banner-edit svg {
        width: 12px;
        height: 12px;
      }
      .profile-preview-body {
        padding: 0 20px 20px;
        position: relative;
      }
      .profile-preview-avatar {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: 5px solid var(--surface);
        margin-top: -42px;
        margin-bottom: 14px;
        background: linear-gradient(135deg, #ec4899, #8b5cf6);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 28px;
        letter-spacing: -0.04em;
        position: relative;
      }
      .profile-preview-avatar .status {
        position: absolute;
        bottom: 4px;
        right: 4px;
        width: 18px;
        height: 18px;
        background: var(--accent);
        border: 4px solid var(--surface);
        border-radius: 50%;
        box-shadow: 0 0 8px var(--accent-glow-soft);
      }
      .profile-preview-avatar-edit {
        position: absolute;
        bottom: 12px;
        left: 56px;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: var(--accent);
        color: #000;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 12px var(--accent-glow-soft);
        border: 3px solid var(--surface);
      }
      .profile-preview-avatar-edit svg {
        width: 12px;
        height: 12px;
      }
      .profile-preview-name {
        font-family: var(--font-display);
        font-size: 18px;
        font-weight: 600;
        letter-spacing: -0.025em;
        margin-bottom: 2px;
      }
      .profile-preview-handle {
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--text-3);
        margin-bottom: 14px;
      }
      .profile-preview-status {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: var(--bg);
        border: 1px solid var(--border-2);
        padding: 5px 9px 5px 7px;
        border-radius: 6px;
        margin-bottom: 14px;
        font-size: 12px;
        color: var(--text-2);
      }
      .profile-preview-status .emoji {
        font-size: 14px;
      }
      .profile-preview-bio-label {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        letter-spacing: 0.14em;
        text-transform: uppercase;
        margin-bottom: 6px;
      }
      .profile-preview-bio {
        font-size: 13px;
        color: var(--text-2);
        line-height: 1.55;
        padding-top: 12px;
        border-top: 1px solid var(--border);
      }

      /* Form rows */
      .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 36px;
        margin-bottom: 28px;
      }
      .form-block {
        margin-bottom: 22px;
      }
      .form-block label {
        display: block;
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        letter-spacing: 0.14em;
        text-transform: uppercase;
        margin-bottom: 8px;
        font-weight: 500;
      }
      .form-block .help {
        font-size: 12px;
        color: var(--text-3);
        margin-top: 6px;
        line-height: 1.5;
      }

      /* Color swatch picker */
      .color-swatches {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
      }
      .color-swatch {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        cursor: pointer;
        border: 2px solid transparent;
        transition: all 0.15s;
        position: relative;
      }
      .color-swatch:hover {
        transform: scale(1.08);
      }
      .color-swatch.selected {
        border-color: var(--text);
        box-shadow: 0 0 0 2px var(--bg) inset;
      }
      .color-swatch.selected::after {
        content: "";
        position: absolute;
        inset: 4px;
        border: 2px solid #fff;
        border-radius: 4px;
        pointer-events: none;
      }

      /* Density selector */
      .density-options {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
      }
      .density-card {
        background: var(--surface);
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        padding: 14px;
        cursor: pointer;
        transition: all 0.15s;
      }
      .density-card:hover {
        border-color: var(--border-3);
      }
      .density-card.selected {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
        background: var(--surface-2);
      }
      .density-card .density-name {
        font-weight: 600;
        font-size: 13px;
        margin-bottom: 4px;
      }
      .density-card .density-desc {
        font-size: 11px;
        color: var(--text-3);
        line-height: 1.4;
      }
      .density-card .density-preview {
        margin-top: 12px;
        padding: 10px;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        height: 60px;
        display: flex;
        flex-direction: column;
        gap: 6px;
      }
      .density-preview-row {
        display: flex;
        align-items: center;
        gap: 8px;
      }
      .density-preview-row .av {
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: linear-gradient(135deg, #ec4899, #8b5cf6);
        flex-shrink: 0;
      }
      .density-preview-row .ln {
        flex: 1;
        height: 6px;
        background: var(--surface-3);
        border-radius: 3px;
      }
      .density-preview-row .ln.short {
        max-width: 60%;
      }

      /* Toggle switches */
      .toggle-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 0;
        border-bottom: 1px solid var(--border);
      }
      .toggle-row:last-child {
        border-bottom: none;
      }
      .toggle-row .label-block .ttl {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 2px;
      }
      .toggle-row .label-block .sub {
        font-size: 12px;
        color: var(--text-3);
        line-height: 1.5;
        max-width: 480px;
      }
      .toggle {
        width: 38px;
        height: 22px;
        border-radius: 11px;
        background: var(--surface-3);
        cursor: pointer;
        position: relative;
        transition: background 0.2s;
        flex-shrink: 0;
      }
      .toggle::after {
        content: "";
        position: absolute;
        top: 2px;
        left: 2px;
        width: 18px;
        height: 18px;
        background: var(--text-2);
        border-radius: 50%;
        transition: all 0.2s;
      }
      .toggle.on {
        background: var(--accent);
      }
      .toggle.on::after {
        left: 18px;
        background: #000;
      }

      /* Status emoji selector */
      .status-emoji-input {
        display: flex;
        align-items: center;
        background: var(--bg);
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        transition: all 0.15s;
      }
      .status-emoji-input:focus-within {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
      }
      .status-emoji-pick {
        padding: 9px 12px;
        cursor: pointer;
        font-size: 16px;
        border-right: 1px solid var(--border-2);
      }
      .status-emoji-input input {
        flex: 1;
        padding: 9px 12px;
        background: transparent;
        border: none;
        outline: none;
        color: var(--text);
        font-size: 14px;
      }

      /* Account row */
      .account-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        background: var(--surface);
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        margin-bottom: 8px;
      }
      .account-row .label-block .lbl {
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-3);
        letter-spacing: 0.12em;
        text-transform: uppercase;
        margin-bottom: 4px;
      }
      .account-row .label-block .val {
        font-size: 14px;
        font-weight: 500;
      }
      .account-row .label-block .val.mono {
        font-family: var(--font-mono);
        font-size: 13px;
      }

      /* Avatar upload zone */
      .upload-tile {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px;
        background: var(--surface);
        border: 1px dashed var(--border-3);
        border-radius: var(--radius);
        transition: all 0.15s;
        cursor: pointer;
      }
      .upload-tile:hover {
        border-color: var(--accent);
        background: var(--accent-soft);
      }
      .upload-tile-icon {
        width: 40px;
        height: 40px;
        background: var(--surface-2);
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-2);
        flex-shrink: 0;
      }
      .upload-tile:hover .upload-tile-icon {
        color: var(--accent);
        background: var(--bg);
      }
      .upload-tile-text {
        flex: 1;
      }
      .upload-tile-text .ttl {
        font-size: 13px;
        font-weight: 500;
        margin-bottom: 2px;
      }
      .upload-tile-text .sub {
        font-size: 11px;
        color: var(--text-3);
        font-family: var(--font-mono);
      }

      /* ============================== EMOJI / GIF PICKERS ============================== */
      .picker {
        position: fixed;
        bottom: 96px;
        background: linear-gradient(
          180deg,
          rgba(20, 22, 29, 0.96),
          rgba(15, 17, 22, 0.96)
        );
        border: 1px solid var(--border-2);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        width: 360px;
        z-index: 80;
        display: none;
        overflow: hidden;
        animation: slidein 0.2s ease-out;
      }
      .picker.active {
        display: block;
      }
      .picker-search {
        padding: 12px;
        border-bottom: 1px solid var(--border-2);
      }
      .picker-search input {
        width: 100%;
        background: var(--bg);
        border: 1px solid var(--border-2);
        border-radius: var(--radius-sm);
        padding: 8px 10px 8px 30px;
        font-size: 13px;
        color: var(--text);
        outline: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 9px center;
        background-size: 13px;
      }
      .picker-search input:focus {
        border-color: var(--accent);
      }
      .picker-tabs {
        display: flex;
        padding: 0 12px;
        border-bottom: 1px solid var(--border);
        gap: 2px;
        overflow-x: auto;
      }
      .picker-tab {
        padding: 8px 10px;
        color: var(--text-3);
        font-size: 12px;
        font-weight: 500;
        cursor: pointer;
        border-bottom: 2px solid transparent;
        transition: all 0.15s;
        white-space: nowrap;
      }
      .picker-tab:hover {
        color: var(--text-2);
      }
      .picker-tab.active {
        color: var(--text);
        border-bottom-color: var(--accent);
      }
      .picker-content {
        padding: 12px;
        max-height: 320px;
        overflow-y: auto;
      }
      .picker-section-label {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        letter-spacing: 0.14em;
        text-transform: uppercase;
        margin: 4px 0 8px;
      }
      .emoji-grid {
        display: grid;
        grid-template-columns: repeat(8, 1fr);
        gap: 2px;
        margin-bottom: 12px;
      }
      .emoji-cell {
        aspect-ratio: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: 18px;
        transition: all 0.1s;
      }
      .emoji-cell:hover {
        background: var(--surface-3);
        transform: scale(1.15);
      }

      .gif-grid {
        columns: 2;
        column-gap: 8px;
      }
      .gif-cell {
        width: 100%;
        margin-bottom: 8px;
        border-radius: var(--radius-sm);
        overflow: hidden;
        cursor: pointer;
        background: linear-gradient(135deg, #1a1d26, #0a0b0e);
        aspect-ratio: var(--ar, 1.6);
        position: relative;
        border: 1px solid var(--border);
        transition: all 0.15s;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: var(--font-mono);
        font-size: 11px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.12em;
      }
      .gif-cell:hover {
        border-color: var(--accent);
        transform: translateY(-1px);
      }
      .gif-cell::after {
        content: "GIF";
        position: absolute;
        bottom: 5px;
        left: 6px;
        background: rgba(0, 0, 0, 0.6);
        color: #fff;
        font-family: var(--font-mono);
        font-size: 8.5px;
        padding: 1px 4px;
        border-radius: 2px;
        letter-spacing: 0.1em;
        font-weight: 700;
      }

      /* Image attachment preview in composer */
      .composer-attachments {
        display: flex;
        gap: 8px;
        padding: 10px 12px 0;
        flex-wrap: wrap;
      }
      .composer-attachment {
        position: relative;
        width: 110px;
        height: 110px;
        border-radius: var(--radius);
        overflow: hidden;
        border: 1px solid var(--border-2);
        background: linear-gradient(135deg, #1a1d26, #0a0b0e);
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .composer-attachment.image-mock {
        background:
          radial-gradient(circle at 30% 30%, #ec489960, transparent 50%),
          linear-gradient(135deg, #1f2937, #111827);
      }
      .composer-attachment .att-name {
        position: absolute;
        bottom: 6px;
        left: 6px;
        right: 6px;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        color: #fff;
        font-family: var(--font-mono);
        font-size: 10px;
        padding: 2px 6px;
        border-radius: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .composer-attachment .att-remove {
        position: absolute;
        top: 5px;
        right: 5px;
        width: 22px;
        height: 22px;
        background: rgba(0, 0, 0, 0.7);
        color: #fff;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border: none;
        transition: all 0.15s;
      }
      .composer-attachment .att-remove:hover {
        background: var(--danger);
      }
      .composer-attachment .att-remove svg {
        width: 11px;
        height: 11px;
      }

      /* Custom status on user card */
      .user-custom-status {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 11px;
        color: var(--text-3);
        margin-top: 1px;
      }
      .user-custom-status .emoji {
        font-size: 11px;
      }

      /* ============================== MODAL ============================== */
      .modal-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(6, 7, 9, 0.78);
        backdrop-filter: blur(12px);
        z-index: 100;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 20px;
        animation: fadein 0.2s ease-out;
      }
      .modal-backdrop.active {
        display: flex;
      }
      @keyframes fadein {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }
      @keyframes slidein {
        from {
          opacity: 0;
          transform: translateY(12px) scale(0.97);
        }
        to {
          opacity: 1;
          transform: translateY(0) scale(1);
        }
      }
      .modal {
        background: linear-gradient(
          180deg,
          rgba(20, 22, 29, 0.96),
          rgba(15, 17, 22, 0.96)
        );
        border: 1px solid var(--border-2);
        border-radius: var(--radius-2xl);
        width: 100%;
        max-width: 500px;
        box-shadow: var(--shadow-lg);
        animation: slidein 0.25s cubic-bezier(0.2, 0.7, 0.3, 1);
        position: relative;
        backdrop-filter: blur(24px);
      }
      .modal::before {
        content: "";
        position: absolute;
        top: -1px;
        left: 28px;
        right: 28px;
        height: 1px;
        background: linear-gradient(
          90deg,
          transparent,
          var(--accent),
          transparent
        );
        opacity: 0.7;
      }
      .modal-header {
        padding: 22px 26px;
        border-bottom: 1px solid var(--border-2);
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
      }
      .modal-title {
        font-family: var(--font-display);
        font-size: 20px;
        font-weight: 600;
        letter-spacing: -0.025em;
        line-height: 1.1;
      }
      .modal-body {
        padding: 24px 26px;
      }
      .modal-body .field:last-child {
        margin-bottom: 0;
      }
      .modal-footer {
        padding: 16px 26px;
        border-top: 1px solid var(--border-2);
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
      }
      .modal-footer .actions {
        display: flex;
        gap: 8px;
      }
      .modal-footer-hint {
        font-family: var(--font-mono);
        font-size: 10.5px;
        color: var(--text-3);
        letter-spacing: 0.06em;
      }

      /* Priority radio */
      .priority-row {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
      }
      .priority-opt {
        border: 1px solid var(--border-2);
        border-radius: var(--radius);
        padding: 12px 12px;
        text-align: center;
        cursor: pointer;
        transition: all 0.15s;
        background: var(--bg);
        position: relative;
        overflow: hidden;
      }
      .priority-opt:hover {
        border-color: var(--border-3);
      }
      .priority-opt .label-line {
        font-size: 13px;
        font-weight: 500;
        color: var(--text);
        margin-bottom: 2px;
      }
      .priority-opt .desc {
        font-size: 11px;
        color: var(--text-3);
        font-family: var(--font-mono);
      }
      .priority-opt.selected.low {
        border-color: var(--info);
        background: var(--info-soft);
        box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.08);
      }
      .priority-opt.selected.low .label-line {
        color: var(--info);
      }
      .priority-opt.selected.medium {
        border-color: var(--warning);
        background: var(--warning-soft);
        box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.08);
      }
      .priority-opt.selected.medium .label-line {
        color: var(--warning);
      }
      .priority-opt.selected.high {
        border-color: var(--danger);
        background: var(--danger-soft);
        box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.08);
      }
      .priority-opt.selected.high .label-line {
        color: var(--danger);
      }

      /* User popover (decorative, shown on hover demo) */
      .user-popover {
        position: absolute;
        width: 300px;
        background: var(--surface);
        border: 1px solid var(--border-2);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        overflow: hidden;
        z-index: 50;
        backdrop-filter: blur(20px);
        display: none;
        animation: slidein 0.2s cubic-bezier(0.2, 0.7, 0.3, 1);
      }
      .user-popover.active {
        display: block;
      }
      .popover-banner {
        height: 60px;
        background: linear-gradient(135deg, var(--accent-deep), #052804 70%);
        position: relative;
        overflow: hidden;
      }
      .popover-banner::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image:
          linear-gradient(rgba(83, 252, 24, 0.1) 1px, transparent 1px),
          linear-gradient(90deg, rgba(83, 252, 24, 0.1) 1px, transparent 1px);
        background-size: 12px 12px;
      }
      .popover-content {
        padding: 0 16px 16px;
      }
      .popover-avatar {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        margin-top: -32px;
        margin-bottom: 10px;
        border: 4px solid var(--surface);
        background: linear-gradient(135deg, var(--accent), var(--accent-deep));
        color: #001a00;
        font-weight: 700;
        font-size: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
      }
      .popover-name {
        font-family: var(--font-display);
        font-size: 17px;
        font-weight: 600;
        color: var(--accent);
        letter-spacing: -0.025em;
      }
      .popover-handle {
        font-family: var(--font-mono);
        font-size: 11.5px;
        color: var(--text-3);
        margin-bottom: 12px;
      }
      .popover-roles {
        display: flex;
        gap: 5px;
        margin-bottom: 14px;
        flex-wrap: wrap;
      }
      .popover-divider {
        height: 1px;
        background: var(--border);
        margin: 12px 0;
      }
      .popover-section-title {
        font-family: var(--font-mono);
        font-size: 9.5px;
        color: var(--text-3);
        text-transform: uppercase;
        letter-spacing: 0.14em;
        margin-bottom: 8px;
      }
      .popover-meta {
        font-size: 12.5px;
        color: var(--text-2);
        line-height: 1.6;
      }
      .popover-actions {
        display: flex;
        gap: 6px;
        margin-top: 14px;
      }

      /* ============================== DEMO CONTROLS ============================== */
      .demo-controls {
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: linear-gradient(
          180deg,
          rgba(20, 22, 29, 0.96),
          rgba(15, 17, 22, 0.96)
        );
        border: 1px solid var(--border-2);
        border-radius: var(--radius-xl);
        padding: 8px;
        display: flex;
        gap: 4px;
        z-index: 200;
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(20px);
        flex-wrap: wrap;
        max-width: calc(100vw - 40px);
      }
      .demo-controls::before {
        content: "DEMO";
        position: absolute;
        top: -10px;
        left: 14px;
        background: linear-gradient(180deg, var(--accent), var(--accent-deep));
        color: #000;
        font-family: var(--font-mono);
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.14em;
        padding: 2px 7px;
        border-radius: 4px;
        box-shadow: 0 0 12px var(--accent-glow-soft);
      }
      .demo-btn {
        padding: 7px 13px;
        border-radius: var(--radius-sm);
        font-size: 11.5px;
        color: var(--text-2);
        background: var(--surface-2);
        transition: all 0.15s;
        font-family: var(--font-mono);
        letter-spacing: 0.02em;
        border: 1px solid var(--border);
      }
      .demo-btn:hover {
        background: var(--surface-3);
        color: var(--text);
        border-color: var(--border-2);
      }
      .demo-btn.active {
        background: linear-gradient(180deg, var(--accent), var(--accent-deep));
        color: #000;
        font-weight: 600;
        border-color: var(--accent);
        box-shadow: 0 0 16px var(--accent-glow-soft);
      }

      /* Mobile menu */
      .mobile-menu-btn {
        display: none;
      }
      .mobile-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(4px);
        z-index: 50;
      }

      /* ============================== RESPONSIVE ============================== */
      @media (max-width: 1180px) {
        .members {
          display: none;
        }
        .app {
          grid-template-columns: var(--sidebar-w) 1fr;
        }
      }
      @media (max-width: 768px) {
        .app {
          grid-template-columns: 1fr;
          position: relative;
        }
        .sidebar {
          position: fixed;
          top: 0;
          left: 0;
          bottom: 0;
          width: 280px;
          transform: translateX(-100%);
          transition: transform 0.25s ease;
          z-index: 60;
          box-shadow: var(--shadow-lg);
        }
        .sidebar.open {
          transform: translateX(0);
        }
        .mobile-overlay.active {
          display: block;
        }
        .mobile-menu-btn {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 32px;
          height: 32px;
          border-radius: var(--radius-sm);
          color: var(--text-2);
          margin-right: 4px;
        }
        .mobile-menu-btn:hover {
          background: var(--surface-2);
          color: var(--text);
        }
        .chat-search {
          display: none;
        }
        .chat-topic {
          display: none;
        }
        .auth-wrap {
          flex-direction: column;
        }
        .auth-left {
          display: none;
        }
        .auth-right {
          padding: 24px 16px;
        }
        .auth-card {
          padding: 32px 24px;
        }
        .demo-controls {
          bottom: 10px;
          right: 10px;
          left: 10px;
          justify-content: center;
        }
        .messages {
          padding-top: 8px;
        }
        .message {
          padding-left: 14px;
          padding-right: 14px;
          grid-template-columns: 36px 1fr;
          gap: 12px;
        }
        .composer-wrap {
          padding: 0 12px 12px;
        }
        .day-divider {
          padding: 14px 14px 10px;
        }
        .auth-title {
          font-size: 44px;
        }
        .ticket-bar {
          padding: 12px 14px;
          flex-wrap: wrap;
          gap: 10px;
        }
      }

      /* Helper utils */
      .row {
        display: flex;
        align-items: center;
        gap: 8px;
      }

      /* "Continue with Google" button (login / register).
         Inherits .btn for geometry + .btn-block for full width; this only
         supplies the neutral surface treatment so the multicolour Google
         glyph reads cleanly against it. Deliberately NOT accent-green: it is
         a secondary path next to the primary "Sign in" button. */
      .btn-google {
        gap: 9px;
        background: var(--surface-3);
        color: var(--text);
        border-color: var(--border-2);
        text-decoration: none;
      }
      .btn-google:hover {
        background: var(--surface-4);
        border-color: var(--border-3);
        transform: translateY(-1px);
      }
      .btn-google:active {
        transform: translateY(0);
      }
      .btn-google svg {
        flex: 0 0 auto;
        display: block;
      }

/* ==========================================================================
   MOBILE FIXES — 2026-07-31
   Appended deliberately at the end of the file: every rule below is an
   override, so nothing above is edited and desktop layout is untouched.
   No JavaScript was changed — these rules were written to match the class
   names the existing JS already sets.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. THE DRAWERS DID NOT OPEN AT ALL  (the actual "not mobile friendly" bug)

   initMobileMenu() toggles classes on <body>:
       body.sidebar-open / body.members-open / body.members-hidden
   but the stylesheet only ever defined  .sidebar.open  and  .mobile-overlay.active,
   neither of which the JS sets. So on a phone the hamburger button and the
   members button did nothing whatsoever — the channel list was unreachable.
   These rules bind the CSS to the classes the JS actually produces.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  body.sidebar-open #sidebar,
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* one overlay serves both drawers; JS never added .active, so match the body class */
  body.sidebar-open .mobile-overlay,
  body.members-open .mobile-overlay {
    display: block;
  }

  /* keep the drawer usable on narrow handsets (was a fixed 280px) */
  #sidebar,
  .sidebar {
    width: min(280px, 85vw);
  }

  /* don't let the page scroll behind an open drawer */
  body.sidebar-open,
  body.members-open {
    overflow: hidden;
  }
}

/* Members list: below 1180px it was simply display:none, i.e. unreachable on a
   phone even though the UI has a button for it. Make it a right-hand drawer. */
@media (max-width: 1180px) {
  .members {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 85vw);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    z-index: 61;
    box-shadow: var(--shadow-lg);
  }
  body.members-open .members {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s ease, visibility 0s;
  }
}

/* The desktop members toggle was dead for the same reason. Collapse the grid
   column too, otherwise hiding the panel leaves an empty gap. */
@media (min-width: 1181px) {
  body.members-hidden .members {
    display: none;
  }
  body.members-hidden .app {
    grid-template-columns: var(--sidebar-w) 1fr;
  }
}

/* --------------------------------------------------------------------------
   2. THE COMPOSER DISAPPEARED BEHIND THE ON-SCREEN KEYBOARD
   .app used height:100vh. On mobile browsers 100vh is the viewport WITHOUT the
   keyboard and does not shrink when it opens, so the message box slid off the
   bottom of the screen while typing. dvh tracks the visible viewport.
   Guarded by @supports so older browsers keep the original 100vh.
   -------------------------------------------------------------------------- */
@supports (height: 100dvh) {
  .app {
    height: 100dvh;
  }
}

/* --------------------------------------------------------------------------
   3. iOS SAFE AREAS — content sat under the notch and the home indicator.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .chat-header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(56px + env(safe-area-inset-top, 0px));
  }
  .composer-wrap {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  #sidebar,
  .sidebar,
  .members {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* --------------------------------------------------------------------------
   4. iOS ZOOMED IN EVERY TIME YOU TAPPED A FIELD
   Safari auto-zooms any focused input whose font-size is under 16px, then
   leaves the page zoomed. The composer was 14.5px and .input 14px.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .input,
  textarea,
  select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  .composer-input,
  #composer-input {
    font-size: 16px;
  }
}

/* --------------------------------------------------------------------------
   5. TOUCH TARGETS — navigation controls were 22–32px against a 44px guideline.
   Applied as min-* so nothing is forced larger than it already is.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  #mobile-menu-btn,
  .mobile-menu-btn,
  #mobile-members-btn,
  #members-mobile-close,
  .close-btn,
  .settings-close {
    min-width: 44px;
    min-height: 44px;
  }
  .icon-btn,
  .msg-action-btn {
    min-width: 38px;
    min-height: 38px;
  }
}

/* --------------------------------------------------------------------------
   6. SIDEWAYS SCROLLING from long links, wide code blocks and full-size images.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden;
    max-width: 100%;
  }
  .message img,
  .msg-embed img,
  .msg-file img,
  .message video {
    max-width: 100%;
    height: auto;
  }
  .message pre,
  .message code,
  pre {
    max-width: 100%;
    overflow-x: auto;
  }
  .message,
  .msg-body {
    overflow-wrap: anywhere;
  }
  /* modals were sized for a desktop window */
  .modal,
  .modal-card {
    max-width: calc(100vw - 24px);
  }
}

/* --------------------------------------------------------------------------
   scroll-behavior fix 2026-07-31
   .messages had `scroll-behavior: smooth`, so every programmatic
   `list.scrollTop = list.scrollHeight` ANIMATED - which is why opening a
   channel visibly scrolled from the top all the way to the bottom, on desktop
   as well as mobile. Jumps must be instant. Deliberate smooth scrolls (jump to
   a replied-to message, search result) pass behavior:'smooth' to
   scrollIntoView themselves and keep working.
   -------------------------------------------------------------------------- */
.messages {
  scroll-behavior: auto;
}

/* ==========================================================================
   Staff command confirmation cards — 2026-07-31
   Posted by the bot after /unban, /resetfp, /lookup. Uses the existing theme
   tokens so it sits inside the chat rather than looking bolted on.
   ========================================================================== */
.kvb-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 6px 0 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, #53fc18);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface-2, rgba(255, 255, 255, 0.03));
  max-width: 560px;
}
.kvb-card-icon {
  font-size: 16px;
  line-height: 1.5;
  flex-shrink: 0;
}
.kvb-card-body {
  min-width: 0;
  flex: 1;
  font-size: 13.5px;
  line-height: 1.65;
}
/* first line of the card reads as its title */
.kvb-card-body strong:first-child,
.kvb-card-body b:first-child {
  display: inline-block;
  margin-bottom: 2px;
  font-size: 14px;
}
.kvb-card-body em {
  color: var(--text-3);
  font-style: normal;
  font-size: 12.5px;
}

/* status accents */
.kvb-card-ok    { border-left-color: #3fb950; }
.kvb-card-info  { border-left-color: #58a6ff; }
.kvb-card-error { border-left-color: #f85149; }
.kvb-card-error .kvb-card-body strong:first-child { color: #f85149; }

/* "Only visible to staff" — mirrors how Discord marks an ephemeral reply */
.kvb-staffonly-badge {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.kvb-staffonly-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  opacity: 0.7;
}

@media (max-width: 768px) {
  .kvb-card {
    max-width: 100%;
    padding: 10px 12px;
  }
  .kvb-card-body { font-size: 14px; }
}

/* ==========================================================================
   MOBILE LAYOUT PASS 2 — 2026-07-31
   The first pass fixed NAVIGATION (drawers, keyboard, safe areas). This pass
   fixes the LAYOUT itself, which was still desktop-shaped:
     - the settings screen was a 280px + 1fr grid with 56px side padding, which
       overflows a 375px phone before any content is drawn
     - modals used 26px padding and desktop widths
     - a 22px horizontal rhythm everywhere ate ~12% of a phone screen
   Appended at the end so it overrides without editing anything above.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. SETTINGS — the worst offender. A fixed 280px nav column beside content is
   impossible at 375px, so stack it: the nav becomes a horizontally scrollable
   strip at the top (the standard phone pattern) and content takes the width.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .settings-shell {
    grid-template-columns: 1fr;
    height: 100vh;
    overflow-y: auto;
  }

  .settings-sidebar {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 10px;
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .settings-sidebar::-webkit-scrollbar { display: none; }

  /* the column sections become inline groups in the strip */
  .settings-sidebar-section {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
    flex-shrink: 0;
  }
  /* section captions ("ACCOUNT", "APP"…) are pure vertical-layout furniture */
  .settings-sidebar-label,
  .settings-divider {
    display: none;
  }
  .settings-nav-item {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 9px 13px;
    margin-bottom: 0;
    font-size: 14px;
  }

  .settings-main {
    padding: 20px 14px calc(48px + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
  }
  .settings-close {
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: 10px;
    width: 40px;
    height: 40px;
  }
  .settings-section {
    margin-bottom: 26px;
  }
}

@supports (height: 100dvh) {
  @media (max-width: 768px) {
    .settings-shell { height: 100dvh; }
  }
}

/* --------------------------------------------------------------------------
   2. MODALS — desktop widths and 26px padding on a phone.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .modal {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: 86vh;
  }
  .modal-header { padding: 16px 16px 14px; }
  .modal-body   { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .modal-footer .btn { flex: 1; }
}
@supports (height: 100dvh) {
  @media (max-width: 768px) {
    .modal { max-height: 86dvh; }
  }
}

/* --------------------------------------------------------------------------
   3. THE 22px RHYTHM — fine on a 1440px window, ~12% of a 375px screen.
   Only the horizontal padding is reduced; vertical spacing is left alone so
   the visual rhythm and tap spacing are preserved.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .chat-header   { padding-left: 10px;  padding-right: 10px; }
  .ticket-bar,
  .pinned-strip,
  .system-message,
  .new-divider,
  .typing-indicator,
  .day-divider   { padding-left: 14px;  padding-right: 14px; }
  .composer-wrap { padding-left: 10px;  padding-right: 10px; }

  /* the chat header holds title + several icon buttons; let the title shrink
     instead of pushing the buttons off the edge */
  .chat-header > *:first-child { min-width: 0; }
  .chat-title,
  .chat-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
}

/* --------------------------------------------------------------------------
   4. Narrow handsets (<=400px): reclaim a little more.
   -------------------------------------------------------------------------- */
@media (max-width: 400px) {
  .message {
    padding-left: 10px;
    padding-right: 10px;
    grid-template-columns: 32px 1fr;
    gap: 9px;
  }
  .settings-main { padding-left: 12px; padding-right: 12px; }
  .modal-body    { padding: 14px 12px; }
}

/* ==========================================================================
   Customer Context Panel — 2026-08-01 (v3, native styling)
   v1/v2 invented their own look and stuck out. This version borrows the
   patterns the chat already uses so it reads as part of the app:
     - gradient-into-transparent strip + bottom border, like .ticket-bar
       and .pinned-strip, and the SAME 22px gutter so it lines up with the
       ticket bar directly above it
     - JetBrains Mono for labels/meta, like .system-message
     - accent-green pills in the .unread-pill idiom for status
     - semantic tokens (--accent / --danger / --warning / --info), never raw hex
   ========================================================================== */
#ticket-context-panel {
  background: linear-gradient(180deg, var(--surface-2), transparent);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 230px;
  overflow-y: auto;
}

/* header row — mirrors the .pinned-strip / .ticket-bar rhythm */
.ctx-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 22px 0;
}
.ctx-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.ctx-staffonly {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--role-support);
  background: var(--role-support-soft);
  border-radius: 4px;
  padding: 2px 6px;
}
.ctx-toggle {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ctx-toggle:hover { color: var(--text-2); border-color: var(--border-3); }

.ctx-body { padding: 8px 22px 14px; }

/* status pills — same idiom as .unread-pill */
.ctx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.ctx-chip {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-3);
  white-space: nowrap;
}
.ctx-chip-ok   { background: var(--accent);        color: #001a00; }
.ctx-chip-warn { background: var(--warning-soft);  color: var(--warning); }
.ctx-chip-bad  { background: var(--danger-soft);   color: var(--danger); }

/* columns */
.ctx-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px 26px;
  align-items: start;
}
.ctx-col { min-width: 0; }
.ctx-sec-title {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 4px;
}

/* label : value — mono label like .system-message, sans value like message text */
.ctx-p {
  display: flex;
  gap: 8px;
  align-items: baseline;
  line-height: 1.75;
  min-width: 0;
}
.ctx-k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  flex-shrink: 0;
  min-width: 58px;
}
.ctx-v {
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ctx-v b { color: var(--text); font-weight: 600; }
.ctx-dim  { color: var(--text-4); }
.ctx-bad  { color: var(--danger); }
.ctx-warn { color: var(--warning); }
.ctx-empty {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  padding: 2px 0 6px;
}

/* live indicator — accent green with the app's glow */
.ctx-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-4);
  vertical-align: middle;
}
.ctx-dot-on {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow-soft);
}

@media (max-width: 768px) {
  #ticket-context-panel { max-height: 42vh; }
  .ctx-head { padding: 10px 14px 0; }
  .ctx-body { padding: 8px 14px 12px; }
  .ctx-cols { grid-template-columns: 1fr 1fr; gap: 10px 16px; }
}
@media (max-width: 430px) {
  .ctx-cols { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Customer Context Panel — v4 additions (2026-08-10)
   Staff actions, richer running-task rows, and the live "updated" stamp.
   Same borrowed language as v3: mono meta, accent for live, semantic tokens.
   ========================================================================== */

/* the head now carries a stamp + refresh, so `auto` moves off .ctx-toggle */
.ctx-toggle { margin-left: 0; }
.ctx-updated {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  color: var(--text-4);
  white-space: nowrap;
}
.ctx-refresh {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ctx-refresh:hover { color: var(--text-2); border-color: var(--border-3); }

/* --- running bots ------------------------------------------------------- */
.ctx-task { line-height: 1.5; margin-bottom: 6px; }
.ctx-task:last-child { margin-bottom: 0; }
.ctx-task-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ctx-task-type {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  flex-shrink: 0;
}
.ctx-task-chan {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ctx-task-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  padding-left: 12px;      /* clears the status dot so the meta hangs under the name */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctx-task-off .ctx-task-chan { color: var(--text-3); font-weight: 500; }
.ctx-task-more {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  padding-left: 12px;
}

/* --- staff actions ------------------------------------------------------ */
.ctx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.ctx-btn {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding: 5px 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ctx-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow-soft);
}
.ctx-btn:disabled { opacity: 0.55; cursor: default; }
.ctx-btn-danger { color: var(--danger); border-color: var(--border-2); }
.ctx-btn-danger:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

@media (max-width: 768px) {
  .ctx-updated { display: none; }   /* head is tight on mobile; refresh button stays */
  .ctx-refresh { margin-left: auto; }   /* the stamp carried `auto`; hand it over */
  .ctx-btn { padding: 8px 12px; font-size: 11px; }   /* 44px-ish touch target */
}

/* Draft greeting - the one action you reach for at the START of a ticket, so it leads
   the row in accent rather than sitting flat with the corrective actions. */
.ctx-btn-go {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-glow-soft);
}
.ctx-btn-go:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

/* Collapsed-panel quick actions ------------------------------------------
   When the panel is hidden the header bar is all that remains, so the two
   composer helpers stay reachable there as compact buttons. Hidden whenever
   the panel is open, since the full-size buttons are already on screen. */
.ctx-mini { display: none; }
#ticket-context-panel.is-collapsed .ctx-mini {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  background: var(--accent-glow-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
#ticket-context-panel.is-collapsed .ctx-mini:hover:not(:disabled) {
  border-color: var(--accent);
}
#ticket-context-panel.is-collapsed .ctx-mini:disabled { opacity: 0.55; cursor: default; }
/* Collapsed means the body has no padding, so the bar needs its own bottom gap. */
#ticket-context-panel.is-collapsed .ctx-head { padding-bottom: 10px; }

@media (max-width: 768px) {
  #ticket-context-panel.is-collapsed .ctx-mini { padding: 7px 10px; font-size: 11px; }
}

/* Prior-contact summary ---------------------------------------------------
   A written note about the customer rather than a data field, so it sits in
   body type with a mono tag, not in the label:value grid. */
.ctx-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  padding: 7px 9px;
  border-left: 2px solid var(--role-support);
  background: var(--surface-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.ctx-summary-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--role-support);
  flex-shrink: 0;
}

/* In-place message editing -----------------------------------------------
   Replaces the browser prompt(). Sits exactly where the message body was so
   the message does not jump when you start editing. */
.msg-edit { margin-top: 2px; }
.msg-edit-input {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  overflow-y: auto;
  min-height: 34px;
  padding: 8px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  /* 16px keeps iOS from zooming the viewport when the field takes focus */
  font-size: 16px;
  line-height: 1.45;
}
@media (min-width: 769px) { .msg-edit-input { font-size: 14px; } }
.msg-edit-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow-soft);
}
.msg-edit-input:disabled { opacity: 0.6; }

.msg-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.msg-edit-hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-4);
  margin-right: auto;
}
.msg-edit-hint b { color: var(--text-3); font-weight: 700; }

.msg-edit-btn {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.msg-edit-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-3); }
.msg-edit-btn:disabled { opacity: 0.55; cursor: default; }
.msg-edit-save {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-glow-soft);
}
.msg-edit-save:hover:not(:disabled) { border-color: var(--accent); }

.msg-edit-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger);
}

/* The hint is the first thing to go when there is no room for it. */
@media (max-width: 520px) {
  .msg-edit-hint { display: none; }
  .msg-edit-btn { flex: 1; padding: 9px 12px; }
}

/* Inline denial note -------------------------------------------------------
   Was a browser prompt(); now sits on the request card so the staff member can
   still see what they are denying while typing the reason. */
.deny-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-2);
}
.deny-note-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 5px;
}
.deny-note-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 46px;
  padding: 7px 9px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;            /* stops iOS zooming the viewport on focus */
  line-height: 1.45;
}
@media (min-width: 769px) { .deny-note-input { font-size: 13px; } }
.deny-note-input:focus {
  outline: none;
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.deny-note-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.deny-note-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  margin-right: auto;
}
.deny-note-hint b { color: var(--text-3); font-weight: 700; }
.deny-note-btn {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 11px;
  cursor: pointer;
}
.deny-note-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-3); }
.deny-note-go {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: var(--danger-soft);
}
.deny-note-go:hover:not(:disabled) { border-color: var(--danger); }
@media (max-width: 520px) {
  .deny-note-hint { display: none; }
  .deny-note-btn { flex: 1; padding: 9px 11px; }
}

/* Confirmation modal -------------------------------------------------------
   Replaces window.confirm(). Matches the existing #modal-channel treatment -
   same backdrop, radius and surface - so it does not read as a second system. */
.kvb-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.kvb-confirm {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  width: min(420px, 92vw);
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: slidein 0.2s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.kvb-confirm-head { padding: 18px 22px 6px; }
.kvb-confirm-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.kvb-confirm.is-danger .kvb-confirm-eyebrow { color: var(--danger); }
.kvb-confirm-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-top: 3px;
}
.kvb-confirm-body {
  padding: 4px 22px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.kvb-confirm-preview {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface-3);
  border-left: 2px solid var(--border-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: auto;
}
.kvb-confirm-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px 18px;
}
.kvb-confirm-btn {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 7px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.kvb-confirm-btn:hover { color: var(--text); border-color: var(--border-3); }
.kvb-confirm-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow-soft);
}
.kvb-confirm-go.is-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: var(--danger-soft);
}
.kvb-confirm-go.is-danger:hover { border-color: var(--danger); }
.kvb-confirm-go.is-danger:focus-visible {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
@media (max-width: 520px) {
  .kvb-confirm-foot { flex-direction: column-reverse; }
  .kvb-confirm-btn { width: 100%; padding: 11px 14px; font-size: 12.5px; }
}

/* Jump-to-message flash ----------------------------------------------------
   Marks the message you landed on after following a reply. Uses an animation
   rather than an inline background so it cannot get stuck on, and an inset
   bar on the left so it still reads for anyone who misses the colour. */
@keyframes kvbMsgFlash {
  0%   { background: var(--accent-glow-soft); box-shadow: inset 2px 0 0 var(--accent); }
  70%  { background: var(--accent-glow-soft); box-shadow: inset 2px 0 0 var(--accent); }
  100% { background: transparent;            box-shadow: inset 2px 0 0 transparent; }
}
.msg-flash {
  animation: kvbMsgFlash 1.8s ease-out;
  border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
  .msg-flash { animation: none; background: var(--accent-glow-soft); }
}
