    :root {
      color-scheme: dark;
      --bg: #080b13;
      --bg2: #111726;
      --surface: #171f31;
      --border: #36405c;
      --border-soft: #6f7cb3;
      --text: #e7ebf5;
      --muted: #9ca8c5;
      --accent: #c8a96b;
      --accent-2: #7d8dff;
      --ok: #82a886;
      --danger: #9f5159;
      --user: #1b2738;
      --assistant: #151f2f;
      --radius: 4px;
    }

    * { box-sizing: border-box; }

    html, body {
      height: 100%;
      background: #080b13;
    }

    body {
      margin: 0;
      min-height: 100vh;
      overflow: hidden;
      background:
        radial-gradient(1200px 500px at 15% -20%, rgba(125, 141, 255, 0.18) 0%, transparent 58%),
        radial-gradient(900px 480px at 90% 115%, rgba(200, 169, 107, 0.14) 0%, transparent 62%),
        linear-gradient(165deg, #060910 0%, #0f1420 55%, #090c15 100%);
      color: var(--text);
      font-family: "Palatino Linotype", "Book Antiqua", "Goudy Old Style", serif;
      padding: 8px;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }

    .app {
      width: 100%;
      height: calc(100vh - 16px);
      max-height: calc(100vh - 16px);
      min-height: 0;
      display: grid;
      grid-template-columns: 220px minmax(0, 1fr) 420px;
      background:
        radial-gradient(120% 80% at 50% -15%, rgba(125, 141, 255, 0.16) 0%, transparent 66%),
        radial-gradient(100% 120% at 100% 120%, rgba(200, 169, 107, 0.11) 0%, transparent 65%),
        var(--bg2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      overflow: hidden;
      box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(125, 141, 255, 0.2);
      animation: appReveal 340ms ease-out;
    }

    .chat-sidebar {
      min-width: 0;
      min-height: 0;
      display: grid;
      grid-template-rows: auto auto minmax(0, 1fr) auto;
      border-right: 1px solid var(--border);
      background: #10151f;
    }

    .chat-sidebar-campaign {
      display: grid;
      grid-template-columns: 1fr auto;
      grid-template-rows: auto auto;
      gap: 6px;
      padding: 8px;
      border-bottom: 1px solid var(--border);
      background: #0e1320;
    }

    .chat-sidebar-campaign-label {
      grid-column: 1;
      grid-row: 1;
      align-self: center;
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      color: #d9bc83;
      font-weight: 700;
    }

    .chat-sidebar-campaign select {
      grid-column: 1 / 3;
      grid-row: 2;
      width: 100%;
      font-size: 0.72rem;
      font-family: inherit;
      background: #141d2e;
      border: 1px solid #3d4a66;
      border-radius: 5px;
      color: var(--text);
      cursor: pointer;
      padding: 5px 8px;
      appearance: none;
      -webkit-appearance: none;
      text-overflow: ellipsis;
      outline: none;
    }

    .chat-sidebar-campaign select:focus {
      color: #fff;
      border-color: #d9bc83;
    }

    .chat-sidebar-campaign-actions {
      grid-column: 2;
      grid-row: 1;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .chat-sidebar-campaign-add,
    .chat-sidebar-campaign-delete {
      flex-shrink: 0;
      width: 18px;
      height: 18px;
      padding: 0;
      font-size: 0.85rem;
      line-height: 1;
      border: 1px solid #3d4a66;
      border-radius: 4px;
      background: #1c2537;
      color: #d9bc83;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .chat-sidebar-campaign-add:hover {
      background: #253045;
      border-color: #d9bc83;
    }

    .chat-sidebar-campaign-delete {
      font-size: 0.68rem;
      color: #c6aab0;
    }

    .chat-sidebar-campaign-delete:hover {
      border-color: #5c3f49;
      background: #2a1a22;
      color: #f1ccd4;
    }

    .chat-sidebar-header {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px;
      border-bottom: 1px solid var(--border);
      background: #121a27;
    }

    .chat-sidebar-title {
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #d9bc83;
      font-weight: 700;
      flex: 1;
      min-width: 0;
    }

    .chat-sidebar .mini {
      height: 28px;
      min-width: 52px;
      padding: 0 10px;
      font-size: 0.66rem;
      border: 1px solid #3d4a66;
      background: #1c2537;
      border-radius: 7px;
    }

    .chat-session-list {
      min-height: 0;
      overflow: auto;
      padding: 6px 5px;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .chat-session-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 26px;
      gap: 3px;
      align-items: stretch;
    }

    .chat-session-item {
      width: 100%;
      min-width: 0;
      height: 30px;
      min-height: 30px;
      display: block;
      padding: 0 9px;
      border: 1px solid transparent;
      background: transparent;
      text-align: left;
      border-radius: 7px;
      color: #d6deef;
      line-height: 28px;
      box-shadow: none;
    }

    .chat-session-item.active {
      border-color: #415170;
      background: #202b40;
      color: #f2f5ff;
    }

    .chat-session-item:hover {
      border-color: #33435f;
      background: #1a2436;
    }

    .chat-session-name {
      display: inline-block;
      max-width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-size: 0.7rem;
      font-weight: 600;
      vertical-align: middle;
    }

    .chat-session-delete {
      min-width: 26px;
      width: 26px;
      height: 30px;
      padding: 0;
      border-radius: 5px;
      border: 1px solid transparent;
      background: transparent;
      color: #8e9bb7;
      font-size: 0.72rem;
      line-height: 1;
      display: grid;
      place-items: center;
      box-shadow: none;
    }

    .chat-session-delete:hover {
      border-color: #5c3f49;
      background: #2a1a22;
      color: #f1ccd4;
    }

    .chat-session-empty {
      border: 1px dashed #3f4f76;
      border-radius: 6px;
      padding: 10px 8px;
      font-size: 0.7rem;
      color: var(--muted);
      text-align: center;
      background: rgba(20, 30, 45, 0.4);
    }

    .workspace {
      min-width: 0;
      min-height: 0;
      display: grid;
      grid-template-rows: auto 1fr auto;
      border-right: 1px solid var(--border);
    }

    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 10px;
      border-bottom: 1px solid var(--border);
      background: linear-gradient(180deg, #1e2740 0%, #151d2e 100%);
    }

    .title h1 {
      margin: 0;
      font-family: "Bookman Old Style", "Palatino Linotype", "Garamond", serif;
      font-size: 1.08rem;
      font-weight: 700;
      letter-spacing: 0.07em;
      text-transform: uppercase;
      color: #d9bc84;
      text-shadow: 0 0 12px rgba(200, 169, 107, 0.18);
    }

    .title small {
      color: var(--muted);
      font-size: 0.71rem;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    .status {
      font-size: 0.74rem;
      color: #f4f7ff;
      border: 1px solid #5f6ead;
      border-radius: 999px;
      padding: 4px 8px;
      background: linear-gradient(180deg, #283657 0%, #1e2943 100%);
      position: relative;
      padding-left: 16px;
    }

    .status::before {
      content: "•";
      position: absolute;
      left: 7px;
      top: 5px;
      font-size: 0.62rem;
      color: var(--accent);
    }

    .llm-controls {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-left: auto;
      margin-right: 8px;
    }

    .llm-controls select {
      background: #1a2440;
      border: 1px solid #3d4f82;
      color: #d7e3ff;
      border-radius: 6px;
      padding: 4px 6px;
      font-size: 0.72rem;
      min-width: 132px;
    }

    #messages {
      min-height: 0;
      overflow: auto;
      padding: 8px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      background: rgba(10, 15, 24, 0.35);
    }

    .chat-empty-state {
      margin: auto 0;
      border: 1px dashed #3f4f76;
      border-radius: 6px;
      padding: 12px 14px;
      color: #9ca8c5;
      font-size: 0.8rem;
      text-align: center;
      background: rgba(20, 30, 47, 0.45);
    }

    .dice-roll-row,
    .damage-roll-row,
    .condition-roll-row {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      align-items: flex-start;
      justify-content: flex-start;
    }

    .dice-roll-row > .msg.tool-card-host,
    .damage-roll-row > .msg.tool-card-host,
    .condition-roll-row > .msg.tool-card-host {
      margin-right: 0;
    }

    .msg {
      max-width: min(90%, 940px);
      border: 1px solid var(--border);
      border-radius: 3px;
      padding: 9px 10px;
      line-height: 1.35;
      font-size: 0.92rem;
      white-space: pre-wrap;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
      animation: msgRise 180ms ease-out;
    }

    .msg.user {
      margin-left: auto;
      background: var(--user);
      border-color: #4c5f86;
    }

    .msg.assistant {
      margin-right: auto;
      background: var(--assistant);
    }

    .msg.assistant .md-content {
      white-space: normal;
      font-size: 0.92rem;
      line-height: 1.4;
      color: #e8edf9;
    }

    .msg.assistant .md-content > *:first-child {
      margin-top: 0;
    }

    .msg.assistant .md-content > *:last-child {
      margin-bottom: 0;
    }

    .msg.assistant .md-content p {
      margin: 0 0 8px;
    }

    .msg.assistant .md-content h2,
    .msg.assistant .md-content h3,
    .msg.assistant .md-content h4 {
      margin: 10px 0 6px;
      color: #f0d7a8;
      line-height: 1.25;
      letter-spacing: 0.01em;
    }

    .msg.assistant .md-content h2 { font-size: 0.92rem; }
    .msg.assistant .md-content h3 { font-size: 0.86rem; }
    .msg.assistant .md-content h4 { font-size: 0.8rem; }

    .msg.assistant .md-content ul {
      margin: 0 0 8px;
      padding-left: 18px;
    }

    .msg.assistant .md-content li + li {
      margin-top: 3px;
    }

    .msg.assistant .md-content code {
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.84em;
      background: #111a2a;
      border: 1px solid #324261;
      border-radius: 4px;
      padding: 1px 4px;
      color: #d7e2fb;
    }

    .msg.assistant .md-content pre {
      margin: 0 0 8px;
      padding: 8px;
      background: #111a2a;
      border: 1px solid #344565;
      border-radius: 6px;
      overflow: auto;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .msg.assistant .md-content pre code {
      background: transparent;
      border: none;
      padding: 0;
      font-size: 0.76rem;
      color: #d4def7;
    }

    .msg.assistant .md-content blockquote {
      margin: 0 0 8px;
      border-left: 3px solid #4f628f;
      padding: 2px 0 2px 8px;
      color: #c2d1ee;
    }

    .book-card {
      margin-top: 7px;
      border: 1px solid #5a6f9f;
      border-radius: 7px;
      background:
        linear-gradient(180deg, rgba(125, 141, 255, 0.1) 0%, transparent 26%),
        linear-gradient(180deg, #1b2539 0%, #151e2f 100%);
      padding: 8px;
    }

    .book-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: baseline;
      border-bottom: 1px solid #3f5074;
      padding-bottom: 5px;
      margin-bottom: 6px;
    }

    .book-head strong {
      color: #edf2ff;
      font-size: 0.8rem;
      letter-spacing: 0.01em;
    }

    .book-meta {
      color: #c2d0ef;
      font-size: 0.66rem;
      white-space: nowrap;
    }

    .book-section + .book-section {
      margin-top: 7px;
    }

    .book-section h4 {
      margin: 0 0 4px;
      font-size: 0.69rem;
      text-transform: uppercase;
      letter-spacing: 0.02em;
      color: #d9bc84;
      border-bottom: 1px solid #3d4f71;
      padding-bottom: 2px;
    }

    .book-section p {
      margin: 0;
      font-size: 0.69rem;
      color: #d2dcf4;
      line-height: 1.34;
      white-space: pre-wrap;
    }

    .book-section ul {
      margin: 0;
      padding-left: 16px;
      color: #d2dcf4;
      font-size: 0.68rem;
      line-height: 1.34;
    }

    .book-section ul li + li {
      margin-top: 3px;
    }

    .rule-card {
      margin-top: 7px;
      border: 1px solid #6075a6;
      border-radius: 7px;
      background:
        linear-gradient(180deg, rgba(125, 141, 255, 0.12) 0%, transparent 28%),
        linear-gradient(180deg, #1a2438 0%, #141d2e 100%);
      padding: 8px;
    }

    .rule-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: baseline;
      border-bottom: 1px solid #3f5074;
      padding-bottom: 5px;
      margin-bottom: 6px;
    }

    .rule-head strong {
      color: #e7ecfb;
      font-size: 0.8rem;
      letter-spacing: 0.01em;
    }

    .rule-meta {
      color: #b7c6e8;
      font-size: 0.66rem;
      white-space: nowrap;
    }

    .rule-body {
      margin: 0 0 4px;
      font-size: 0.69rem;
      color: #d2dcf4;
      line-height: 1.4;
    }

    .rule-section + .rule-section {
      margin-top: 6px;
    }

    .rule-section h4 {
      margin: 0 0 3px;
      font-size: 0.67rem;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      color: #d9bc84;
      border-bottom: 1px solid #3d4f71;
      padding-bottom: 2px;
    }

    .rule-section p,
    .rule-section .rule-body {
      margin: 0;
      font-size: 0.69rem;
      color: #d2dcf4;
      line-height: 1.4;
    }

    .msg.tool {
      margin-right: auto;
      background: #192234;
      border-color: #4d5f8a;
      font-size: 0.78rem;
      padding: 7px 9px;
      max-width: min(92%, 980px);
    }

    .msg.tool-card-host {
      margin-right: auto;
      border: none;
      background: transparent;
      box-shadow: none;
      padding: 0;
      max-width: min(92%, 980px);
    }

    .tool-head {
      display: flex;
      align-items: center;
      gap: 7px;
      margin-bottom: 4px;
      color: #d5b980;
      font-weight: 600;
      font-size: 0.74rem;
      letter-spacing: 0.01em;
    }

    .tool-badge {
      border: 1px solid #5c6ea1;
      border-radius: 999px;
      padding: 1px 6px;
      font-size: 0.66rem;
      color: #e7ecff;
      background: #31456f;
    }

    .tool-badge.err {
      border-color: #6e3840;
      color: #f4d8dc;
      background: #4b2830;
    }

    .tool-body {
      color: #c9d3ef;
      font-size: 0.72rem;
      line-height: 1.35;
      white-space: pre-wrap;
    }

    .tool-meta {
      margin-top: 6px;
      font-size: 0.66rem;
      color: #94a6cf;
      font-variant-numeric: tabular-nums;
    }

    .tool-details {
      margin-top: 7px;
      border-top: 1px solid #3a4968;
      padding-top: 6px;
    }

    .tool-details summary {
      cursor: pointer;
      color: #b7c7ea;
      font-size: 0.68rem;
      user-select: none;
    }

    .tool-json {
      margin: 6px 0 0;
      padding: 6px;
      border: 1px solid #3d4c6f;
      border-radius: 6px;
      background: #11192a;
      color: #c8d2ef;
      font-size: 0.67rem;
      line-height: 1.34;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      max-height: 280px;
      overflow: auto;
    }

    .monster-grid {
      margin-top: 7px;
      display: grid;
      gap: 7px;
    }

    .monster-search-list {
      margin-top: 7px;
      border: 1px solid #4b5f89;
      border-radius: 7px;
      overflow: hidden;
      background: #131d2d;
    }

    .monster-search-row {
      display: grid;
      grid-template-columns: 1fr auto auto;
      gap: 8px;
      align-items: center;
      padding: 6px 8px;
      border-bottom: 1px solid #334562;
      font-size: 0.69rem;
    }

    .monster-search-row:last-child {
      border-bottom: none;
    }

    .monster-search-name {
      color: #e6ecfb;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .monster-search-meta {
      color: #bdd0f3;
      font-size: 0.66rem;
      white-space: nowrap;
    }

    .monster-search-cr {
      color: #d6be8a;
      font-size: 0.66rem;
      white-space: nowrap;
      border: 1px solid #5a6d97;
      border-radius: 999px;
      padding: 1px 6px;
      background: #1d2940;
    }

    .monster-statblock {
      border: 1px solid #6075a6;
      border-radius: 7px;
      background:
        linear-gradient(180deg, rgba(125, 141, 255, 0.12) 0%, transparent 28%),
        linear-gradient(180deg, #1a2438 0%, #141d2e 100%);
      padding: 8px;
    }

    .msb-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: baseline;
      border-bottom: 1px solid #3f5074;
      padding-bottom: 5px;
      margin-bottom: 6px;
    }

    .msb-head strong {
      color: #e7ecfb;
      font-size: 0.82rem;
      letter-spacing: 0.01em;
    }

    .msb-source {
      color: #b7c6e8;
      font-size: 0.66rem;
    }

    .msb-subtitle {
      color: #c7d2ee;
      font-size: 0.68rem;
      margin-bottom: 6px;
      font-style: italic;
    }

    .msb-core {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 4px;
      margin-bottom: 6px;
    }

    .msb-core div {
      border: 1px solid #46597f;
      border-radius: 5px;
      background: #1f2a41;
      text-align: center;
      font-size: 0.66rem;
      color: #d9e2fa;
      padding: 3px 4px;
    }

    .msb-abilities {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 4px;
      margin-bottom: 6px;
    }

    .msb-abilities span {
      border: 1px solid #46597f;
      border-radius: 5px;
      background: #1f2a41;
      text-align: center;
      font-size: 0.66rem;
      color: #d9e2fa;
      padding: 3px 4px;
      font-variant-numeric: tabular-nums;
    }

    .msb-stat-roll {
      cursor: pointer;
      transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
      border-bottom: none;
    }

    .msb-stat-roll:hover {
      border-color: #5a6f9e;
      color: #e6edff;
      background: #202d45;
    }

    .msb-saves {
      margin-bottom: 6px;
      border: 1px solid #46597f;
      border-radius: 5px;
      background: #1f2a41;
      padding: 5px;
      display: grid;
      gap: 4px;
    }

    .msb-saves-title {
      font-size: 0.6rem;
      letter-spacing: 0.03em;
      text-transform: uppercase;
      color: #9fb2de;
    }

    .msb-saves-list {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 4px;
    }

    .msb-save-pill {
      border: 1px solid #4f6290;
      border-radius: 4px;
      background: #182337;
      color: #d8e3fb;
      text-align: center;
      padding: 2px 3px;
      font-size: 0.62rem;
      line-height: 1.1;
      white-space: nowrap;
      border-bottom: none;
      transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
    }

    .msb-save-pill.dice-link {
      color: #d8e3fb;
      border-bottom: none;
    }

    .msb-save-pill:hover {
      color: #e6edff;
      border-color: #5d74a8;
      background: #202d45;
    }

    .msb-save-pill.dice-link:hover {
      color: #e6edff;
      border-color: #5d74a8;
    }

    .msb-meta {
      border-top: 1px solid #3f5074;
      border-bottom: 1px solid #3f5074;
      padding: 5px 0;
      margin-bottom: 6px;
      display: grid;
      gap: 3px;
      font-size: 0.67rem;
      color: #cad5f0;
      line-height: 1.3;
    }

    .msb-section + .msb-section {
      margin-top: 6px;
    }

    .msb-section h4 {
      margin: 0 0 3px;
      font-size: 0.67rem;
      letter-spacing: 0.02em;
      text-transform: uppercase;
      color: #d8bc86;
      border-bottom: 1px solid #3f5074;
      padding-bottom: 2px;
    }

    .msb-list {
      margin: 0;
      padding-left: 15px;
      font-size: 0.68rem;
      color: #d3dcf4;
      line-height: 1.32;
    }

    .msb-list li + li {
      margin-top: 3px;
    }

    .spell-grid {
      margin-top: 7px;
      display: grid;
      gap: 7px;
    }

    .spell-statblock {
      border: 1px solid #6075a6;
      border-radius: 7px;
      background:
        linear-gradient(180deg, rgba(200, 169, 107, 0.1) 0%, transparent 26%),
        linear-gradient(180deg, #1a2438 0%, #141d2e 100%);
      padding: 8px;
    }

    .ssb-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: baseline;
      border-bottom: 1px solid #3f5074;
      padding-bottom: 5px;
      margin-bottom: 6px;
    }

    .ssb-head strong {
      color: #edf2ff;
      font-size: 0.8rem;
      letter-spacing: 0.01em;
    }

    .ssb-source {
      color: #c2d0ef;
      font-size: 0.66rem;
    }

    .ssb-subtitle {
      color: #d8e0f5;
      font-size: 0.68rem;
      margin-bottom: 6px;
      font-style: italic;
    }

    .ssb-core {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 4px;
      margin-bottom: 6px;
    }

    .ssb-core div {
      border: 1px solid #4c5f88;
      border-radius: 5px;
      background: #1f2a41;
      text-align: center;
      font-size: 0.66rem;
      color: #d9e2fa;
      padding: 3px 4px;
    }

    .ssb-meta {
      border-top: 1px solid #3f5074;
      border-bottom: 1px solid #3f5074;
      padding: 5px 0;
      margin-bottom: 6px;
      display: grid;
      gap: 3px;
      font-size: 0.67rem;
      color: #cad5f0;
      line-height: 1.3;
    }

    .ssb-section + .ssb-section {
      margin-top: 6px;
    }

    .ssb-section h4 {
      margin: 0 0 3px;
      font-size: 0.67rem;
      letter-spacing: 0.02em;
      text-transform: uppercase;
      color: #d8bc86;
      border-bottom: 1px solid #3f5074;
      padding-bottom: 2px;
    }

    .ssb-list {
      margin: 0;
      padding-left: 15px;
      font-size: 0.68rem;
      color: #d3dcf4;
      line-height: 1.32;
    }

    .ssb-list li + li {
      margin-top: 3px;
    }

    .typing {
      min-height: 1.1em;
      font-size: 0.77rem;
      color: var(--muted);
      padding: 0 8px 6px;
    }

    .composer {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto auto auto;
      gap: 5px;
      border-top: 1px solid var(--border);
      padding: 6px;
      background: linear-gradient(180deg, #1a2438 0%, #141c2e 100%);
      align-items: center;
    }

    textarea {
      width: 100%;
      height: 40px;
      border: 1px solid #415176;
      border-radius: 7px;
      background: #0d1320;
      color: var(--text);
      font: inherit;
      padding: 7px 9px;
      resize: none;
      outline: none;
      min-width: 0;
    }

    textarea:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(125, 141, 255, 0.22);
    }

    button {
      border-radius: 6px;
      border: 1px solid #5b6c95;
      min-width: 64px;
      height: 40px;
      padding: 0 8px;
      font: inherit;
      font-size: 0.7rem;
      font-weight: 600;
      letter-spacing: 0.01em;
      text-transform: none;
      cursor: pointer;
      color: #e8ecfa;
      background: linear-gradient(180deg, #293650 0%, #1f2940 100%);
      transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, filter 140ms ease;
    }

    #sendBtn {
      min-width: 86px;
      background: linear-gradient(180deg, #394b71 0%, #2b3958 100%);
      border-color: #6a7fae;
      color: #edf2ff;
      text-shadow: none;
    }

    #summarizeBtn {
      min-width: 90px;
      background: linear-gradient(180deg, #2d3e60 0%, #22314e 100%);
      border-color: #5f74a5;
      color: #e9efff;
    }

    #sendBtn:hover { filter: brightness(1.08); border-color: #8295bf; }
    #summarizeBtn:hover { filter: brightness(1.07); border-color: #7c92c4; }

    .sidebar {
      min-width: 0;
      min-height: 0;
      overflow: hidden;
      display: grid;
      grid-template-columns: minmax(0, 1fr) 46px;
      background: #101828;
    }

    .tab-rail {
      border-left: 1px solid var(--border);
      background: linear-gradient(180deg, #101829 0%, #0b1220 100%);
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 6px 4px;
      gap: 6px;
    }

    .tab-rail-divider {
      width: 24px;
      height: 1px;
      margin: 6px 0 4px;
      background: linear-gradient(90deg, transparent 0%, rgba(156, 168, 197, 0.45) 18%, rgba(156, 168, 197, 0.45) 82%, transparent 100%);
      opacity: 0.8;
      pointer-events: none;
    }

    .tab-rail-spacer {
      flex: 1;
      width: 1px;
    }

    .tab-btn {
      width: 36px;
      height: 36px;
      min-width: 36px;
      border: 1px solid #485a81;
      border-radius: 7px;
      background: linear-gradient(180deg, #1f2b43 0%, #172136 100%);
      display: grid;
      place-items: center;
      color: #bec9e4;
      padding: 0;
      transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
    }

    .tab-btn svg {
      width: 16px;
      height: 16px;
      stroke: currentColor;
      fill: none;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .tab-btn.active {
      background: linear-gradient(180deg, #3c4f78 0%, #2b3a5b 100%);
      color: #f5f7ff;
      border-color: #6f84b7;
      box-shadow: 0 0 16px rgba(125, 141, 255, 0.18);
    }
    .tab-btn:hover { transform: translateY(-1px); }

    .side-content {
      min-width: 0;
      min-height: 0;
      display: grid;
      grid-template-rows: auto 1fr;
    }

    .side-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 10px;
      border-bottom: 1px solid var(--border);
      background: linear-gradient(180deg, #1b2439 0%, #141d2f 100%);
      font-size: 0.78rem;
      color: var(--muted);
      font-weight: 600;
    }

    .chip { 
      font-size: 0.72rem;
      border: 1px solid #596c9c;
      border-radius: 6px;
      padding: 2px 6px;
      color: #ebeffd;
      background: #30456d;
    }

    .tab-panel {
      display: none;
      padding: 8px 10px;
      min-height: 0;
      overflow: auto;
    }

    .tab-panel.active {
      display: block;
    }

    .tab-panel[data-panel="combat"] {
      flex: 1;
      height: 100%;
      min-height: 0;
      overflow: hidden;
    }

    .tab-panel[data-panel="combat"].active {
      display: flex;
      flex-direction: column;
    }

    .panel {
      border-bottom: 1px solid var(--border);
      padding: 8px 10px;
    }

    .panel h3 {
      margin: 0 0 7px;
      font-family: "Bookman Old Style", "Palatino Linotype", "Garamond", serif;
      font-size: 0.82rem;
      color: #d9bc83;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .panel h3::after {
      content: "";
      height: 1px;
      flex: 1;
      background: linear-gradient(90deg, rgba(125, 141, 255, 0.65), rgba(125, 141, 255, 0));
    }

    .dice-history-empty {
      font-size: 0.72rem;
      color: var(--muted);
      text-align: center;
      padding: 28px 0 12px;
    }

    .dice-history-list {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .bestiary-header h3 {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--accent);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin: 0 0 8px;
    }

    .bestiary-empty {
      font-size: 0.72rem;
      color: var(--muted);
      text-align: center;
      padding: 28px 0 12px;
    }

    .bestiary-list {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .bestiary-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      background: rgba(255,255,255,0.04);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 6px 8px;
    }

    .bestiary-row-info {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .bestiary-row-info strong {
      font-size: 0.78rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .bestiary-row-meta {
      font-size: 0.68rem;
      color: var(--muted);
    }

    .msb-save-link {
      margin-left: 6px;
      font-size: 0.68rem;
      color: var(--muted);
      cursor: pointer;
      opacity: 0.6;
      transition: opacity 0.15s;
    }

    .msb-save-link:hover { opacity: 1; color: var(--accent); }

    @keyframes dheSlide {
      from { opacity: 0; transform: translateX(10px); }
      to   { opacity: 1; transform: translateX(0); }
    }

    .dhe {
      border: 1px solid #35466a;
      border-radius: 6px;
      background: #131c2c;
      padding: 6px 8px;
      animation: dheSlide 200ms ease-out;
    }

    .dhe-head {
      display: flex;
      align-items: baseline;
      gap: 5px;
      margin-bottom: 4px;
      min-width: 0;
    }

    .dhe-type {
      font-size: 0.58rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: #5b6a8e;
      flex-shrink: 0;
    }

    .dhe-label {
      font-size: 0.71rem;
      color: #d9bc84;
      font-weight: 600;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex: 1;
    }

    .dhe-time {
      font-size: 0.6rem;
      color: #4c5c7e;
      flex-shrink: 0;
    }

    .dhe-body {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-wrap: wrap;
    }

    .dhe .die-face {
      animation: none;
      width: 22px;
      height: 22px;
      font-size: 0.65rem;
    }

    .dhe .die-face[data-die="4"]  .die-num { transform: translateY(16%); }
    .dhe .die-face[data-die="20"] .die-num { transform: translateY(-16%); }

    .dhe-sep {
      font-size: 0.68rem;
      color: #4c5c7e;
    }

    .dhe-math {
      font-size: 0.68rem;
      color: #8a9ac0;
      font-family: monospace;
    }

    .dhe-total {
      font-size: 0.82rem;
      font-weight: 700;
      color: #f0f3ff;
      margin-left: auto;
    }

    .dhe-divider {
      width: 1px;
      height: 14px;
      background: #3a4a6a;
      flex-shrink: 0;
      margin: 0 2px;
    }

    .dhe-badge {
      font-size: 0.58rem;
      font-weight: 700;
      padding: 1px 5px;
      border-radius: 3px;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      flex-shrink: 0;
    }

    .dhe-badge.success { background: #1a3320; border: 1px solid #4a8a5a; color: #82da8f; }
    .dhe-badge.fail    { background: #2a1318; border: 1px solid #8a3040; color: #e07080; }
    .dhe-badge.crit    { background: #271d09; border: 1px solid #c8a96b; color: #f5d87a; }

    .dice-card-fading {
      transition: opacity 500ms ease, transform 500ms ease;
      opacity: 0 !important;
      transform: translateY(-4px) !important;
      pointer-events: none;
    }

    .players-panel h3 {
      margin: 0 0 7px;
      font-family: "Bookman Old Style", "Palatino Linotype", "Garamond", serif;
      font-size: 0.82rem;
      color: #d7b17b;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .players-controls {
      display: grid;
      grid-template-columns: 1fr 56px 56px;
      gap: 6px;
      margin-bottom: 7px;
    }

    .players-controls input {
      border: 1px solid #445577;
      background: #121a2a;
      color: #eadfc8;
      border-radius: 6px;
      padding: 6px 7px;
      font: inherit;
      font-size: 0.72rem;
      min-width: 0;
    }

    .players-controls button {
      height: 30px;
      min-width: 0;
      font-size: 0.7rem;
      padding: 0;
    }

    .players-table {
      width: 100%;
      border-collapse: collapse;
      border: 1px solid #455679;
      border-radius: 6px;
      overflow: hidden;
      font-size: 0.7rem;
      margin-bottom: 7px;
    }

    .players-table th,
    .players-table td {
      border-bottom: 1px solid #384763;
      padding: 5px 6px;
      text-align: left;
      vertical-align: middle;
    }

    .players-table tr:last-child td { border-bottom: none; }
    .players-table th { color: #ecf1ff; font-size: 0.66rem; letter-spacing: 0.03em; text-transform: uppercase; background: #31456f; }
    .players-table td { color: #e7ebf5; background: #182133; }

    .players-table input {
      width: 100%;
      border: 1px solid #445678;
      background: #0f1523;
      color: #e7ebf5;
      border-radius: 5px;
      padding: 3px 4px;
      font: inherit;
      font-size: 0.68rem;
    }

    .player-hp-cell {
      display: flex;
      align-items: center;
      gap: 2px;
    }

    .player-cur-hp-input,
    .player-max-hp-input {
      width: 36px;
      text-align: center;
      -moz-appearance: textfield;
    }

    .player-cur-hp-input::-webkit-inner-spin-button,
    .player-cur-hp-input::-webkit-outer-spin-button,
    .player-max-hp-input::-webkit-inner-spin-button,
    .player-max-hp-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

    .player-hp-sep {
      color: var(--muted);
      font-size: 0.75rem;
      flex-shrink: 0;
    }

    .player-del {
      width: 22px;
      height: 22px;
      min-width: 22px;
      border-radius: 4px;
      border: 1px solid #6f3941;
      background: #47252b;
      color: #f0d4d8;
      font-size: 0.7rem;
      padding: 0;
    }

    .players-help {
      font-size: 0.68rem;
      color: var(--muted);
      line-height: 1.35;
    }

    .account-panel h3 {
      margin: 0 0 8px;
      font-family: "Bookman Old Style", "Palatino Linotype", "Garamond", serif;
      font-size: 0.82rem;
      color: #d7b17b;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .account-card {
      border: 1px solid #3f5074;
      border-radius: 7px;
      background: #182238;
      padding: 10px;
      display: grid;
      gap: 10px;
    }

    .account-row {
      display: grid;
      gap: 4px;
    }

    .account-label {
      font-size: 0.68rem;
      color: #9fb0d4;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .account-username {
      font-size: 0.86rem;
      color: #edf2ff;
      letter-spacing: 0.01em;
      overflow-wrap: anywhere;
    }

    .account-logout-btn {
      width: fit-content;
      min-width: 80px;
      border-color: #5c3f49;
      background: #2a1a22;
      color: #f1ccd4;
    }

    .account-logout-btn:hover {
      border-color: #77525d;
      background: #34202b;
    }

    .combat {
      display: flex;
      flex-direction: column;
      gap: 6px;
      flex: 1;
      min-height: 0;
      overflow: hidden;
      border: 1px solid #3d4f73;
      border-radius: 10px;
      padding: 8px;
      background:
        radial-gradient(140% 90% at 0% 0%, rgba(93, 124, 178, 0.18), transparent 52%),
        radial-gradient(120% 90% at 100% 100%, rgba(117, 92, 63, 0.14), transparent 55%),
        #111a2a;
    }

    .combat-toolbar {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 6px;
      margin-bottom: 7px;
    }

    .combat-toolbar .mini {
      font-size: 0.72rem;
      background: #1d2638;
      border: 1px solid #45587d;
      padding: 5px 6px;
      border-radius: 7px;
      color: #d4ddf4;
      text-align: center;
      cursor: pointer;
      transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
    }

    .combat-toolbar .mini:hover {
      border-color: #6980af;
      background: #24324b;
      transform: translateY(-1px);
    }

    .encounter-meta {
      display: flex;
      gap: 10px;
      font-size: 0.72rem;
      color: var(--muted);
      margin-bottom: 6px;
      flex-wrap: wrap;
    }

    .active-statblock-panel {
      min-height: 0;
      max-height: clamp(170px, 35vh, 420px);
      overflow-y: auto;
      padding-right: 2px;
      margin-bottom: 6px;
    }

    .tracker {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      border: 1px solid #46597e;
      border-radius: 6px;
      background: #141d2f;
      box-shadow: inset 0 0 0 1px rgba(126, 154, 205, 0.08);
    }

    #trackerRows {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      overflow-x: hidden;
    }

    .tracker-head {
      display: grid;
      grid-template-columns: 42px 1fr 62px 26px;
      gap: 8px;
      align-items: center;
      padding: 5px 8px;
      font-size: 0.66rem;
      letter-spacing: 0.03em;
      text-transform: uppercase;
      color: #edf2ff;
      border-bottom: 1px solid #465981;
      background: #2f436a;
    }

    .row {
      display: grid;
      grid-template-columns: 42px 1fr 62px 26px;
      gap: 8px;
      align-items: center;
      padding: 5px 8px;
      border-bottom: 1px solid #34435f;
      font-size: 0.75rem;
    }

    .row:last-child { border-bottom: none; }
    .row.active-turn { background: #24324d; }
    .row.inspected { box-shadow: inset 3px 0 0 #d5b980; }
    .row.active-turn.inspected {
      background: linear-gradient(90deg, rgba(213, 185, 128, 0.12), #24324d 26%);
    }
    .row:hover { background: #1c2942; }

    .init-input {
      width: 100%;
      color: #f7e9ce;
      font-weight: 700;
      text-align: center;
      border: 1px solid #5a6d98;
      border-radius: 5px;
      padding: 1px 0;
      background: #3d5078;
      font: inherit;
      font-size: 0.75rem;
      -moz-appearance: textfield;
    }

    .init-input::-webkit-inner-spin-button,
    .init-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

    .init-input:focus {
      outline: none;
      border-color: #a0b4e8;
      background: #4a5f90;
    }

    .name {
      display: flex;
      flex-direction: column;
      gap: 1px;
      min-width: 0;
    }

    .name strong {
      font-size: 0.76rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .name small { color: var(--muted); font-size: 0.67rem; }

    .tracker-condition-pills {
      display: flex;
      flex-wrap: wrap;
      gap: 3px;
      margin-top: 2px;
      min-width: 0;
    }

    .tracker-cond-pill {
      font-size: 0.6rem;
      line-height: 1.1;
      padding: 1px 5px;
      border-radius: 999px;
      border: 1px solid #5873a7;
      background: #283957;
      color: #dfe9ff;
      white-space: nowrap;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .tracker-cond-pill.spell {
      border-color: #a07bb3;
      background: #3c2d4a;
      color: #f0dcff;
    }

    .tracker-cond-pill.cond-concentration {
      border-color: #b88f52;
      background: #453522;
      color: #f4e0b8;
    }

    .tracker-cond-pill.cond-frightened,
    .tracker-cond-pill.cond-charmed {
      border-color: #8b638e;
      background: #3d2c44;
      color: #efd8f3;
    }

    .tracker-cond-pill.cond-paralyzed,
    .tracker-cond-pill.cond-petrified,
    .tracker-cond-pill.cond-incapacitated {
      border-color: #6a6f8a;
      background: #2f3445;
      color: #d9deef;
    }

    .hp {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 1px;
      color: #e8ecf8;
      font-size: 0.7rem;
      font-variant-numeric: tabular-nums;
    }

    .hp-input {
      width: 38px;
      text-align: right;
      border: 1px solid transparent;
      border-radius: 4px;
      background: transparent;
      color: inherit;
      font: inherit;
      font-size: 0.7rem;
      padding: 1px 2px;
      -moz-appearance: textfield;
    }

    .hp-input::-webkit-inner-spin-button,
    .hp-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

    .hp-input:hover {
      border-color: #445678;
      background: #0f1523;
    }

    .hp-input:focus {
      outline: none;
      border-color: #a0b4e8;
      background: #0f1523;
    }

    .hp-max-label {
      color: var(--muted);
      font-size: 0.65rem;
      white-space: nowrap;
    }

    .row-actions {
      display: flex;
      justify-content: flex-end;
    }

    .tracker-remove {
      width: 20px;
      height: 20px;
      min-width: 20px;
      border-radius: 4px;
      border: 1px solid #6f3941;
      background: #47252b;
      color: #f0d4d8;
      font-size: 0.68rem;
      padding: 0;
      cursor: pointer;
    }

    .tracker-remove:hover {
      border-color: #a54f5c;
      background: #5a2c35;
    }

    .enc-build-difficulty {
      font-weight: 700;
      font-size: 0.66rem;
      padding: 1px 6px;
      border-radius: 999px;
      border: 1px solid currentColor;
    }

    .enc-build-warn {
      padding: 4px 8px;
      font-size: 0.67rem;
      color: #c89a5a;
    }

    .enc-diff-trivial  { color: #7a9a7a; border-color: #4a6a4a; }
    .enc-diff-easy     { color: #7aba7a; border-color: #4a8a4a; }
    .enc-diff-low      { color: #7aba7a; border-color: #4a8a4a; }
    .enc-diff-medium   { color: #c8b84a; border-color: #8a7a2a; }
    .enc-diff-moderate { color: #c8b84a; border-color: #8a7a2a; }
    .enc-diff-hard     { color: #d48a3a; border-color: #9a5a1a; }
    .enc-diff-high     { color: #d48a3a; border-color: #9a5a1a; }
    .enc-diff-deadly   { color: #d45a4a; border-color: #8a2a1a; }
    .enc-diff-absurd   { color: #e04040; border-color: #a01010; }

    .enc-display-card {
      border: 1px solid #4b5f89;
      border-radius: 7px;
      overflow: hidden;
      background: #131d2d;
      font-size: 0.69rem;
    }

    .enc-display-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 6px 8px;
      border-bottom: 1px solid #334562;
      background: #1a2640;
    }

    .enc-display-title {
      color: #d5b980;
      font-weight: 600;
      font-size: 0.74rem;
      letter-spacing: 0.01em;
    }

    .enc-display-party {
      color: #94a6cf;
      font-size: 0.66rem;
    }

    .enc-display-rows { display: flex; flex-direction: column; }

    .enc-display-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px;
      align-items: center;
      padding: 6px 8px;
      border-bottom: 1px solid #334562;
    }

    .enc-display-row:last-child { border-bottom: none; }

    .enc-display-name {
      color: #e6ecfb;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .enc-display-badges {
      display: flex;
      gap: 4px;
      flex-shrink: 0;
    }

    .enc-display-badge {
      color: #d6be8a;
      font-size: 0.66rem;
      white-space: nowrap;
      border: 1px solid #5a6d97;
      border-radius: 999px;
      padding: 1px 6px;
      background: #1d2940;
    }

    .enc-display-footer {
      padding: 6px 8px;
      border-top: 1px solid #334562;
    }

    .enc-display-add-btn {
      height: 28px;
      min-width: 0;
      width: 100%;
      font-size: 0.69rem;
      font-weight: 600;
      border: 1px solid #5b6c95;
      border-radius: 5px;
      background: linear-gradient(180deg, #293650 0%, #1f2940 100%);
      color: #e8ecfa;
      cursor: pointer;
      letter-spacing: 0.01em;
      transition: filter 120ms ease, border-color 120ms ease;
    }

    .enc-display-add-btn:hover:not(:disabled) {
      filter: brightness(1.15);
      border-color: #7a90c0;
    }

    .enc-display-add-btn:disabled {
      opacity: 0.6;
      cursor: default;
    }

    .msg.encounter-event {
      margin-right: auto;
      background: #1b2539;
      border: 1px solid #4b618d;
      padding: 6px 9px;
      font-size: 0.72rem;
      max-width: min(92%, 760px);
      color: #d8e2fb;
      box-shadow: 0 4px 18px rgba(8, 12, 20, 0.35);
      white-space: normal;
    }

    .encounter-event-title {
      font-weight: 700;
      color: #f2d9a2;
      margin-bottom: 3px;
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .encounter-event-count {
      font-size: 0.62rem;
      border: 1px solid #677fae;
      border-radius: 999px;
      padding: 1px 6px;
      color: #dbe6ff;
      background: #2a3a58;
    }

    .encounter-event-body {
      color: #d8e2fb;
      line-height: 1.3;
    }

    .notes {
      font-size: 0.7rem;
      color: var(--muted);
      line-height: 1.35;
      border-top: 1px solid #394864;
      padding-top: 6px;
      margin-top: 6px;
    }

    .statblock {
      margin-top: 7px;
      border: 1px solid #485b84;
      border-radius: 6px;
      background: #192335;
      padding: 7px;
      font-size: 0.72rem;
      line-height: 1.3;
      box-shadow: inset 0 0 0 1px rgba(126, 154, 205, 0.08);
    }

    .sb-head {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: 8px;
      margin-bottom: 6px;
      padding-bottom: 5px;
      border-bottom: 1px solid #3c4c69;
    }

    .sb-head strong {
      font-size: 0.77rem;
      color: #d9bc84;
    }

    .sb-meta {
      color: var(--muted);
      font-size: 0.68rem;
    }

    .sb-quick {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 5px;
      margin-bottom: 6px;
    }

    .sb-pill {
      border: 1px solid #44577d;
      background: #212b40;
      border-radius: 5px;
      padding: 3px 5px;
      color: #d9e1f8;
      font-size: 0.68rem;
      display: flex;
      justify-content: space-between;
      gap: 6px;
    }

    .sb-abilities {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 4px;
      margin-bottom: 6px;
    }

    .sb-abilities span {
      border: 1px solid #44577d;
      border-radius: 5px;
      padding: 3px 0;
      text-align: center;
      background: #202b41;
      color: #dbe3fa;
      font-size: 0.66rem;
      font-variant-numeric: tabular-nums;
    }

    .sb-section + .sb-section {
      margin-top: 5px;
    }

    .sb-section h4 {
      margin: 0 0 3px;
      font-size: 0.67rem;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: #d9bd86;
    }

    .sb-list {
      margin: 0;
      padding-left: 15px;
      color: #d5def5;
      font-size: 0.69rem;
    }

    @media (max-width: 1050px) {
      .app { grid-template-columns: 180px minmax(0, 1fr) 360px; }
    }

    @media (max-width: 840px) {
      body {
        padding: 0;
        min-height: 100dvh;
        overflow: hidden;
      }

      .app {
        height: 100dvh;
        max-height: 100dvh;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        border-radius: 0;
        border-left: none;
        border-right: none;
      }
      .chat-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
      }
      .workspace { border-right: none; }
      .sidebar {
        border-top: 1px solid var(--border);
        grid-template-columns: minmax(0, 1fr) 40px;
      }
      .tab-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
      }
      .tab-rail-divider {
        width: 20px;
        margin: 5px 0 3px;
      }
      .composer { grid-template-columns: 1fr; }
      button { height: 44px; }

      /* Prevent iOS Safari focus-zoom on form controls */
      input,
      select,
      textarea {
        font-size: 16px;
      }

      .llm-controls,
      .header,
      #summarizeBtn {
        display: none !important;
      }

      .app.mobile-swipe {
        display: grid;
        grid-template-columns: repeat(3, 100%);
        grid-template-rows: 1fr;
        width: 100vw;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
      }

      .app.mobile-swipe::-webkit-scrollbar {
        display: none;
      }

      .app.mobile-swipe > .chat-sidebar,
      .app.mobile-swipe > .workspace,
      .app.mobile-swipe > .sidebar {
        min-width: 0;
        min-height: 0;
        height: 100dvh;
        max-height: 100dvh;
        scroll-snap-align: start;
        overflow: hidden;
      }

      .app.mobile-swipe > .chat-sidebar {
        grid-column: 1;
        border-right: 1px solid var(--border);
        border-bottom: none;
        max-height: none;
      }

      .app.mobile-swipe > .workspace {
        grid-column: 2;
        border-right: 1px solid var(--border);
        min-height: 0;
        height: 100%;
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto;
        overflow: hidden;
      }

      .app.mobile-swipe > .workspace #messages {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
      }

      .app.mobile-swipe > .sidebar {
        grid-column: 3;
        border-top: none;
        grid-template-columns: minmax(0, 1fr) 40px;
        overflow: hidden;
      }

      .app.mobile-swipe > .sidebar .side-content {
        min-height: 0;
        height: 100%;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
      }

      .app.mobile-swipe > .sidebar .tab-panel {
        min-height: 0;
        height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
      }

      .app.mobile-swipe > .sidebar .tab-panel[data-panel="combat"],
      .app.mobile-swipe > .sidebar .combat {
        min-height: 0;
        height: auto;
      }

      .app.mobile-swipe > .sidebar .combat {
        display: block;
        overflow: visible;
      }

      .app.mobile-swipe > .sidebar .active-statblock-panel {
        max-height: none;
        overflow: visible;
        margin-bottom: 8px;
      }

      .app.mobile-swipe > .sidebar .tracker {
        display: block;
        min-height: 0;
        height: auto;
        flex: none;
        overflow: visible;
      }

      .app.mobile-swipe > .sidebar #trackerRows {
        display: block;
        flex: none;
        min-height: 0;
        overflow: visible;
      }

    }

    @media (max-width: 640px) {
      body {
        padding: 4px;
        overflow: hidden;
      }

      .app {
        height: calc(100dvh - 8px);
        max-height: calc(100dvh - 8px);
        min-height: 0;
      }

      .chat-sidebar {
        max-height: min(36dvh, 280px);
      }

      .header {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 6px;
      }

      .title {
        min-width: 0;
      }

      .llm-controls {
        width: 100%;
        margin: 0;
      }

      .llm-controls select {
        min-width: 0;
        flex: 1;
      }

      .status {
        margin-left: auto;
      }

      .msg,
      .msg.tool,
      .msg.tool-card-host,
      .msg.encounter-event {
        max-width: 100%;
      }

      .sidebar {
        max-height: none;
        grid-template-columns: minmax(0, 1fr) 40px;
        grid-template-rows: 1fr;
      }

      .tab-rail {
        border-left: 1px solid var(--border);
        border-top: none;
        flex-direction: column;
        justify-content: flex-start;
        overflow: hidden;
        padding: 6px 4px;
      }

      .tab-rail-divider,
      .tab-rail-spacer {
        display: block;
      }

      .tab-btn {
        flex: 0 0 auto;
      }

      .combat-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .players-controls {
        grid-template-columns: 1fr;
      }

      .players-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
      }

      .picker-modal,
      .auth-modal {
        min-width: 0;
        width: calc(100vw - 20px);
        max-width: 100%;
        padding: 16px;
      }
    }

    @keyframes appReveal {
      from { opacity: 0; transform: translateY(3px); }
      to { opacity: 1; transform: translateY(0); }
    }

    @keyframes msgRise {
      from { opacity: 0; transform: translateY(2px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* ===== Dice Tool Cards ===== */

    @keyframes diceCardReveal {
      from { opacity: 0; transform: translateY(6px) scale(0.97); }
      to   { opacity: 1; transform: translateY(0)   scale(1);    }
    }

    @keyframes dieRoll {
      0%   { transform: rotate(-22deg) scale(0.55); opacity: 0; }
      55%  { transform: rotate(6deg)   scale(1.1);  opacity: 1; }
      75%  { transform: rotate(-3deg)  scale(0.97); }
      100% { transform: rotate(0deg)   scale(1);    }
    }

    @keyframes critFlash {
      0%, 100% { filter: none; }
      40%      { filter: drop-shadow(0 0 5px rgba(200, 169, 107, 0.85)); }
    }

    .dice-roll-card,
    .dice-check-card,
    .dice-attack-card {
      display: inline-block;
      width: fit-content;
      max-width: min(100%, 520px);
      border: 1px solid #5a6d9e;
      border-radius: 7px;
      background: linear-gradient(180deg, rgba(125, 141, 255, 0.07) 0%, #131c2c 100%);
      padding: 7px 9px;
      animation: diceCardReveal 340ms cubic-bezier(0.2, 0.8, 0.3, 1);
    }

    .encounter-damage-card {
      display: inline-block;
      width: fit-content;
      max-width: min(100%, 360px);
      border: 1px solid #7b4a4f;
      border-radius: 7px;
      background: linear-gradient(180deg, rgba(142, 70, 76, 0.14) 0%, #1a1f2b 100%);
      padding: 7px 9px;
      min-height: 76px;
      animation: diceCardReveal 300ms cubic-bezier(0.2, 0.8, 0.3, 1);
    }

    .encounter-heal-card {
      display: inline-block;
      width: fit-content;
      max-width: min(100%, 360px);
      border: 1px solid #3f7758;
      border-radius: 7px;
      background: linear-gradient(180deg, rgba(72, 144, 96, 0.16) 0%, #172521 100%);
      padding: 7px 9px;
      min-height: 76px;
      animation: diceCardReveal 300ms cubic-bezier(0.2, 0.8, 0.3, 1);
    }

    .encounter-condition-card {
      display: inline-block;
      width: fit-content;
      max-width: min(100%, 360px);
      border: 1px solid #4d6d8f;
      border-radius: 7px;
      background: linear-gradient(180deg, rgba(86, 130, 172, 0.15) 0%, #182534 100%);
      padding: 7px 9px;
      min-height: 76px;
      animation: diceCardReveal 300ms cubic-bezier(0.2, 0.8, 0.3, 1);
    }

    .encounter-damage-head {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: 8px;
      border-bottom: 1px solid #5a353a;
      padding-bottom: 4px;
      margin-bottom: 5px;
    }

    .encounter-damage-title {
      font-size: 0.72rem;
      font-weight: 700;
      color: #f0cfa0;
      letter-spacing: 0.01em;
      text-transform: uppercase;
    }

    .encounter-damage-amount {
      font-size: 0.68rem;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      color: #ffb4bb;
      font-weight: 700;
    }

    .encounter-damage-body {
      color: #e9eefc;
      line-height: 1.25;
      white-space: normal;
      display: flex;
      flex-direction: column;
      gap: 2px;
      align-items: center;
      justify-content: center;
      position: relative;
      min-height: 38px;
    }

    .encounter-damage-value {
      font-size: 1.14rem;
      font-weight: 800;
      color: #ffd0d6;
      font-variant-numeric: tabular-nums;
      line-height: 1.05;
    }

    .encounter-heal-value {
      font-size: 1.14rem;
      font-weight: 800;
      color: #c6f0d0;
      font-variant-numeric: tabular-nums;
      line-height: 1.05;
    }

    .encounter-damage-status {
      font-size: 0.64rem;
      color: #cbbec2;
      text-transform: lowercase;
      letter-spacing: 0.01em;
    }

    .encounter-condition-body {
      color: #e7eefc;
      line-height: 1.25;
      white-space: normal;
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 4px;
      min-height: 38px;
    }

    .encounter-condition-value {
      font-size: 0.9rem;
      font-weight: 700;
      color: #dde9ff;
      font-variant-numeric: tabular-nums;
      line-height: 1.05;
      text-transform: lowercase;
    }

    .encounter-condition-status {
      font-size: 0.64rem;
      color: #c4d3ea;
      text-transform: uppercase;
      letter-spacing: 0.03em;
    }

    .encounter-damage-total {
      position: absolute;
      right: 0;
      bottom: -1px;
      font-size: 0.66rem;
      color: #d8cdd0;
      font-variant-numeric: tabular-nums;
    }

    .encounter-damage-meta {
      margin-top: 4px;
      border-top: 1px solid #513237;
      padding-top: 4px;
      font-size: 0.64rem;
      color: #d3c7ca;
      line-height: 1.2;
      white-space: normal;
    }

    .encounter-damage-con {
      margin-top: 4px;
      font-size: 0.66rem;
      line-height: 1.2;
      border-top: 1px solid #513237;
      padding-top: 4px;
      color: #d7c0c4;
    }

    .encounter-damage-con.success { color: #b6ddb3; }
    .encounter-damage-con.fail { color: #efb2b8; }

    .dice-card-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: baseline;
      padding-bottom: 4px;
      margin-bottom: 6px;
      border-bottom: 1px solid #3a4a75;
    }

    .dice-label {
      font-size: 0.74rem;
      font-weight: 700;
      color: #d9bc84;
      letter-spacing: 0.01em;
    }

    .dice-expr {
      font-size: 0.64rem;
      color: #9ca8c5;
      font-family: monospace;
    }

    .die-tray {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-bottom: 6px;
      align-items: center;
    }

    .die-face {
      width: 28px;
      height: 28px;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 0.76rem;
      color: #edf2ff;
      flex-shrink: 0;
      animation: dieRoll 420ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
      overflow: visible;
    }

    .die-num {
      position: relative;
      z-index: 1;
      line-height: 1;
    }

    /* nudge number to the visual centroid of asymmetric shapes */
    .die-face[data-die="4"]  .die-num { transform: translateY(16%); }
    .die-face[data-die="20"] .die-num { transform: translateY(-16%); }

    .die-face.crit {
      color: #f5d87a;
      animation: dieRoll 420ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both,
                 critFlash 1s 420ms ease;
    }

    .die-face.minroll { color: #f4aaaa; }

    .die-separator {
      color: #6b7fc2;
      font-size: 0.72rem;
      padding: 0 1px;
      flex-shrink: 0;
    }

    .dice-total-row {
      display: flex;
      justify-content: flex-end;
      align-items: baseline;
      gap: 4px;
    }

    .dice-modifier-chip {
      color: #c8a96b;
      font-size: 0.7rem;
      font-family: monospace;
    }

    .dice-total-label {
      color: #9ca8c5;
      font-size: 0.66rem;
    }

    .dice-total {
      font-size: 0.92rem;
      font-weight: 700;
      color: #f5f7ff;
      line-height: 1;
    }

    .dice-roll-type-chip {
      display: inline-block;
      margin-bottom: 6px;
      font-size: 0.58rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      border: 1px solid #4c6092;
      border-radius: 4px;
      padding: 1px 6px;
      color: #c8d3f0;
      background: #1f2e4a;
    }

    .check-d20-wrap {
      display: flex;
      gap: 7px;
      align-items: center;
      margin-bottom: 6px;
    }

    .check-d20 {
      width: 44px;
      height: 44px;
      border: 2px solid #7d8dff;
      border-radius: 8px;
      background: linear-gradient(180deg, #1f2a4f, #141d30);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      animation: dieRoll 500ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
      gap: 1px;
    }

    .check-d20 .d20-num {
      font-size: 1.24rem;
      font-weight: 700;
      color: #f5f7ff;
      line-height: 1;
    }

    .check-d20 .d20-tag {
      font-size: 0.46rem;
      color: #6b7fc2;
      letter-spacing: 0.03em;
      text-transform: uppercase;
    }

    .check-d20.crit {
      border-color: #c8a96b;
      background: linear-gradient(180deg, #271d09, #1a1206);
      animation: dieRoll 500ms cubic-bezier(0.2, 0.8, 0.3, 1) both,
                 critFlash 1s 500ms ease;
    }

    .check-d20.minroll {
      border-color: #9f5159;
      background: linear-gradient(180deg, #2a0e12, #1a0b0d);
    }

    .check-d20.crit .d20-num,
    .check-d20.crit .d20-tag    { color: #f5d87a; }

    .check-d20.minroll .d20-num,
    .check-d20.minroll .d20-tag { color: #f4aaaa; }

    .check-d20-secondary {
      width: 32px;
      height: 32px;
      flex-shrink: 0;
      animation-delay: 80ms;
    }

    .check-d20-secondary .d20-num { font-size: 0.98rem; }

    .check-adv-arrow {
      color: #6b7fc2;
      font-size: 0.9rem;
      flex-shrink: 0;
    }

    .check-meta {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .check-meta-row {
      font-size: 0.66rem;
      color: #b0bcdc;
    }

    .check-total-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-top: 1px solid #3a4a75;
      padding-top: 4px;
      gap: 6px;
    }

    .check-total-calc {
      font-size: 0.66rem;
      color: #9ca8c5;
      font-family: monospace;
    }

    .check-badge {
      font-size: 0.66rem;
      font-weight: 700;
      padding: 2px 7px;
      border-radius: 5px;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    .check-badge.success { background: #1a3320; border: 1px solid #4a8a5a; color: #82da8f; }
    .check-badge.fail    { background: #2a1318; border: 1px solid #8a3040; color: #e07080; }
    .check-badge.no-dc   { color: #9ca8c5; font-weight: 400; font-size: 0.66rem; }

    .attack-sequence {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
    }

    .attack-section,
    .damage-section {
      border: 1px solid #3a4a75;
      border-radius: 6px;
      background: #131c2c;
      padding: 6px;
    }

    .attack-section-head,
    .damage-section-head {
      font-size: 0.58rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #6b7fc2;
      margin-bottom: 4px;
    }

    .attack-hit-badge {
      font-size: 0.72rem;
      font-weight: 700;
      padding: 2px 8px;
      border-radius: 5px;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      margin-bottom: 5px;
      display: inline-block;
    }

    .attack-hit-badge.crit { background: #271d09; border: 1px solid #c8a96b; color: #f5d87a; }

    .attack-roll-row {
      display: flex;
      align-items: center;
      gap: 4px;
      font-size: 0.66rem;
      color: #9ca8c5;
    }

    .attack-roll-num {
      font-size: 0.95rem;
      font-weight: 700;
      color: #f5f7ff;
    }

    .attack-die {
      width: 26px;
      height: 26px;
      font-size: 0.68rem;
    }

    .damage-type-chip {
      font-size: 0.58rem;
      padding: 1px 5px;
      border-radius: 4px;
      border: 1px solid #4c6092;
      background: #1f2e4a;
      color: #c8d3f0;
      display: inline-block;
      margin-bottom: 4px;
    }

    .crit-banner {
      font-size: 0.58rem;
      color: #f5d87a;
      background: rgba(200, 169, 107, 0.09);
      border: 1px solid rgba(200, 169, 107, 0.24);
      border-radius: 4px;
      padding: 2px 6px;
      margin-top: 4px;
      text-align: center;
      letter-spacing: 0.03em;
    }

    .dmg-die-tray {
      display: flex;
      flex-wrap: wrap;
      gap: 3px;
      margin-bottom: 4px;
      align-items: center;
    }

    .dmg-die {
      width: 24px;
      height: 24px;
      font-size: 0.64rem;
    }

    .dice-link {
      color: #7d8dff;
      border-bottom: 1px dashed rgba(125, 141, 255, 0.6);
      cursor: pointer;
      white-space: nowrap;
      transition: color 120ms ease, border-color 120ms ease;
    }

    .dice-link:hover {
      color: #c8a96b;
      border-color: rgba(200, 169, 107, 0.7);
    }

    /* ── Player picker modal ─────────────────────────────────────── */
    .picker-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.65);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }

    .picker-overlay[hidden] { display: none; }

    .picker-modal {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 20px 24px;
      min-width: 320px;
      max-width: 480px;
      width: 100%;
      box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    }

    .picker-modal h3 {
      margin: 0 0 4px;
      font-size: 1rem;
      color: var(--accent);
    }

    .picker-hint {
      margin: 0 0 14px;
      font-size: 0.75rem;
      color: var(--muted);
    }

    .picker-rows {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-bottom: 16px;
    }

    .picker-row {
      display: grid;
      grid-template-columns: auto 1fr 72px;
      align-items: center;
      gap: 10px;
    }

    .picker-row input[type="checkbox"] {
      width: 16px;
      height: 16px;
      accent-color: var(--accent);
      cursor: pointer;
    }

    .picker-row label {
      font-size: 0.82rem;
      color: var(--text);
      cursor: pointer;
      user-select: none;
    }

    .picker-row label .picker-mod {
      font-size: 0.7rem;
      color: var(--muted);
      margin-left: 4px;
    }

    .picker-row input[type="number"] {
      border: 1px solid var(--border);
      background: #121a2a;
      color: var(--text);
      border-radius: 5px;
      padding: 5px 7px;
      font: inherit;
      font-size: 0.8rem;
      width: 100%;
      text-align: center;
    }

    .picker-row input[type="number"]:disabled {
      opacity: 0.3;
    }

    .picker-actions {
      display: flex;
      gap: 8px;
      justify-content: flex-end;
    }

    .picker-actions button {
      padding: 7px 16px;
      border-radius: 5px;
      border: 1px solid var(--border);
      background: #1e2d4a;
      color: var(--text);
      font: inherit;
      font-size: 0.8rem;
      cursor: pointer;
      transition: background 120ms;
    }

    .picker-actions button:hover { background: #2a3e60; }

    .picker-actions button:first-child {
      background: #2a3e20;
      border-color: #4a6a3a;
    }

    .picker-actions button:first-child:hover { background: #35502a; }

    .picker-cancel {
      color: var(--muted) !important;
    }

    /* ── Sub-agent loading / error cards ─────────────────────────── */
    .subagent-card {
      border: 1px solid #6075a6;
      border-radius: 7px;
      background:
        linear-gradient(180deg, rgba(125, 141, 255, 0.12) 0%, transparent 28%),
        linear-gradient(180deg, #1a2438 0%, #141d2e 100%);
      padding: 8px;
    }

    .subagent-card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
      border-bottom: 1px solid #3f5074;
      padding-bottom: 5px;
      margin-bottom: 0;
    }

    .subagent-card-header-left {
      display: flex;
      align-items: center;
      gap: 7px;
    }

    .subagent-card-header .subagent-icon {
      font-size: 0.9rem;
      line-height: 1;
    }

    .subagent-card-header strong {
      color: #e7ecfb;
      font-size: 0.82rem;
      letter-spacing: 0.01em;
    }

    .subagent-card-prompt {
      margin-top: 5px;
      font-size: 0.68rem;
      color: #c7d2ee;
      font-style: italic;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .subagent-spinner {
      display: inline-block;
      width: 12px;
      height: 12px;
      border: 2px solid #3a4e6a;
      border-top-color: #7d8dff;
      border-radius: 50%;
      animation: subagent-spin 0.7s linear infinite;
      flex-shrink: 0;
    }

    @keyframes subagent-spin {
      to { transform: rotate(360deg); }
    }

    .subagent-card.is-error {
      border-color: #7a3a3a;
      background:
        linear-gradient(180deg, rgba(255, 100, 100, 0.08) 0%, transparent 28%),
        linear-gradient(180deg, #1a2438 0%, #141d2e 100%);
    }

    .subagent-card.is-error .subagent-card-header {
      border-bottom-color: #5a3030;
    }

    .subagent-card.is-error .subagent-card-header strong {
      color: #e08080;
    }

    .subagent-card.is-error .subagent-spinner {
      display: none;
    }

    /* ── Auth overlay ─────────────────────────────────────────────── */
    .auth-overlay {
      position: fixed;
      inset: 0;
      background: rgba(10, 15, 25, 0.96);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 2000;
    }

    .auth-overlay[hidden] { display: none; }

    .auth-modal {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 28px 32px;
      min-width: 320px;
      max-width: 400px;
      width: 100%;
      box-shadow: 0 12px 48px rgba(0,0,0,0.7);
    }

    .auth-title {
      text-align: center;
      font-size: 1.5rem;
      margin: 0 0 20px;
      color: var(--accent, #c8a96b);
    }

    .auth-tabs {
      display: flex;
      gap: 0;
      margin-bottom: 20px;
      border-bottom: 1px solid var(--border);
    }

    .auth-tab {
      flex: 1;
      background: none;
      border: none;
      padding: 8px 0;
      color: var(--text-muted, #8899aa);
      cursor: pointer;
      font-size: 0.9rem;
      border-bottom: 2px solid transparent;
      margin-bottom: -1px;
      pointer-events: auto;
      touch-action: manipulation;
      position: relative;
      z-index: 1;
    }

    .auth-tab.active {
      color: var(--text, #e8e0d4);
      border-bottom-color: var(--accent, #c8a96b);
    }

    .auth-form { display: flex; flex-direction: column; gap: 14px; }

    .auth-label {
      display: flex;
      flex-direction: column;
      gap: 5px;
      font-size: 0.82rem;
      color: var(--text-muted, #8899aa);
    }
    .auth-label[hidden] { display: none !important; }

    .auth-input {
      padding: 8px 10px;
      background: var(--bg, #0d1522);
      border: 1px solid var(--border);
      border-radius: 5px;
      color: var(--text, #e8e0d4);
      font-size: 0.9rem;
    }

    .auth-input:focus { outline: none; border-color: var(--accent, #c8a96b); }

    .auth-error {
      color: #e07070;
      font-size: 0.82rem;
      padding: 6px 8px;
      background: rgba(200, 80, 80, 0.1);
      border-radius: 4px;
    }

    .auth-submit {
      padding: 9px;
      background: var(--accent, #c8a96b);
      color: #0d1522;
      border: none;
      border-radius: 5px;
      font-weight: 600;
      cursor: pointer;
      font-size: 0.9rem;
    }

    .auth-submit:hover { opacity: 0.9; }
    .auth-submit:disabled { opacity: 0.5; cursor: default; }

    /* ── Archived sessions section ────────────────────────────────── */
    .archived-section {
      border-top: 1px solid var(--border);
      margin-top: 4px;
      background: #10151f;
    }

    .archived-summary {
      padding: 6px 10px;
      font-size: 0.75rem;
      color: var(--text-muted, #8899aa);
      cursor: pointer;
      user-select: none;
      list-style: none;
    }

    .archived-summary::-webkit-details-marker { display: none; }
    .archived-summary::before { content: '▸ '; font-size: 0.65rem; }
    details[open] .archived-summary::before { content: '▾ '; }

    .archived-list {
      opacity: 0.7;
      max-height: 160px;
      overflow: auto;
    }

    .archived-name {
      font-style: italic;
      color: var(--text-muted, #8899aa);
    }
