      :root {
        color-scheme: light;
        --ink: #111118;
        --paper: #f7f1e6;
        --sand: #efe3d2;
        --terra: #d88f6a;
        --sage: #5e7c73;
        --charcoal: #1d232b;
        --fog: rgba(255, 255, 255, 0.6);
        --shadow: 0 24px 60px rgba(15, 20, 28, 0.16);
        --radius-xl: 26px;
        --radius-lg: 18px;
        --radius-md: 12px;
        --radius-sm: 8px;
      }

      * {
        box-sizing: border-box;
      }

      body {
        margin: 0;
        min-height: 100vh;
        background: radial-gradient(circle at top, #fff1d6 0%, #f2e6d5 40%, #e3d6c5 80%);
        color: var(--ink);
        font-family: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
      }

      .page {
        display: grid;
        gap: 0.8rem;
        padding: 0.9rem clamp(0.8rem, 2.5vw, 1.6rem);
      }


      .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        border: 0;
      }

      .primary-button {
        border: none;
        padding: 0.45rem 1rem;
        border-radius: 999px;
        background: var(--charcoal);
        color: #fff8ef;
        cursor: pointer;
        font-size: 0.85rem;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
      }

      .primary-button:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 20px rgba(24, 33, 44, 0.2);
      }

      .auth-shell {
        display: none;
        justify-content: center;
        align-items: flex-start;
        padding-top: 1rem;
        min-height: 60vh;
      }

      .auth-shell.active {
        display: flex;
      }

      .auth-card {
        width: min(420px, 100%);
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
      }

      .shell.hidden {
        display: none;
      }


      .shell {
        display: grid;
        grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
        grid-template-areas: "sidebar main";
        gap: 0.9rem;
      }

      .shell .sidebar-panel {
        grid-area: sidebar;
      }

      .shell .main-panel {
        grid-area: main;
      }

      @media (max-width: 960px) {
        .page {
          min-height: 100dvh;
          grid-template-rows: auto minmax(0, 1fr);
          gap: 0.7rem;
          padding: 0.9rem clamp(0.8rem, 3vw, 1.2rem);
        }

        .shell {
          grid-template-columns: minmax(0, 1fr);
          grid-template-areas:
            "main"
            "sidebar";
          min-height: 0;
        }

        .panel {
          padding: 1rem;
        }

        .main-panel {
          display: flex;
          flex-direction: column;
          min-height: 0;
        }

        .stream {
          flex: 1;
          min-height: 0;
          max-height: none;
        }

        .composer {
          position: sticky;
          bottom: 0;
          background: #fff8ef;
          padding-bottom: calc(0.8rem + env(safe-area-inset-bottom));
        }
      }

      .panel {
        background: #fff8ef;
        border-radius: var(--radius-xl);
        padding: 1.1rem;
        border: 1px solid #ecdcc7;
        box-shadow: var(--shadow);
      }

      .panel-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.7rem;
        padding-bottom: 0.6rem;
        border-bottom: 1px solid #ecdcc7;
      }

      .panel-title {
        margin: 0;
        font-size: 1.35rem;
        font-weight: 600;
      }

      .panel-title-row {
        display: inline-flex;
        align-items: center;
        gap: 0.6rem;
      }

      .panel-actions {
        display: inline-flex;
        align-items: center;
        gap: 0.6rem;
      }

      .sidebar-title {
        margin: 0 0 0.5rem;
        font-size: 1.1rem;
        font-weight: 600;
        color: #8a7f6f;
      }

      .auth-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        margin-bottom: 0.6rem;
      }

      .auth-status {
        font-size: 0.8rem;
        color: #7b6f63;
        margin-bottom: 0.6rem;
      }

      .auth-message {
        font-size: 0.75rem;
        color: #b5651d;
        margin-bottom: 0.6rem;
      }

      .auth-message.success {
        color: #2f7a46;
      }

      .auth-banner {
        display: none;
        margin-bottom: 0.8rem;
        padding: 0.7rem 0.75rem;
        border-radius: 0.8rem;
        border: 1px solid #f0d2a4;
        background: #fff4dd;
        color: #7a4a1c;
        font-size: 0.75rem;
        line-height: 1.4;
      }

      .auth-banner.active {
        display: block;
      }

      .auth-banner-actions {
        margin-top: 0.6rem;
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
      }

      .auth-banner-actions button {
        border-radius: 999px;
        border: 1px solid #d7b48c;
        background: #fff;
        color: #7a4a1c;
        padding: 0.25rem 0.7rem;
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
      }

      .auth-banner-actions button.dismiss {
        background: transparent;
      }

      .auth-panel {
        display: none;
        flex-direction: column;
        gap: 0.6rem;
        padding: 0.75rem;
        border: 1px solid #ecdcc7;
        border-radius: var(--radius-md);
        background: #fff;
        margin-bottom: 0.8rem;
      }

      .auth-panel.active {
        display: flex;
      }

      .auth-panel h3 {
        margin: 0;
        font-size: 0.95rem;
        color: #3f342b;
      }

      .auth-panel label {
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.12em;
        color: #8a7f6f;
        display: block;
      }

      .auth-panel input {
        padding: 0.45rem 0.6rem;
        border-radius: 0.6rem;
        border: 1px solid #ecdcc7;
        background: #fff8ef;
        color: #2f2620;
        width: 100%;
        box-sizing: border-box;
      }

      .auth-panel input.input-error {
        border-color: #b23b2b;
        background: #fff2f0;
      }

      .field-error {
        min-height: 0.9rem;
        font-size: 0.65rem;
        color: #b23b2b;
      }

      .auth-panel button {
        padding: 0.5rem 0.7rem;
        border-radius: 999px;
        border: 1px solid #dfc4a7;
        background: #2f2620;
        color: #fff8ef;
        font-weight: 600;
        cursor: pointer;
      }

      .auth-panel button.secondary {
        background: transparent;
        color: #2f2620;
      }

      .auth-panel button[disabled] {
        opacity: 0.6;
        cursor: not-allowed;
      }

      .conversation-list {
        display: flex;
        flex-direction: column;
        gap: 0.6rem;
        max-height: 55vh;
        overflow-y: auto;
      }

      .conversation-list.loading {
        opacity: 0.7;
        pointer-events: none;
      }

      .conversation-item {
        position: relative;
        display: flex;
        align-items: stretch;
        gap: 0.4rem;
      }

      .conversation-button {
        flex: 1;
        border: 1px solid transparent;
        background: #fff;
        border-radius: var(--radius-md);
        padding: 0.7rem 0.8rem;
        text-align: left;
        cursor: pointer;
        transition: border 0.2s ease, box-shadow 0.2s ease;
      }

      .conversation-button:hover {
        border-color: #e6d4bc;
        box-shadow: 0 6px 14px rgba(51, 33, 21, 0.08);
      }

      .conversation-button.active {
        border-color: var(--terra);
        box-shadow: 0 8px 16px rgba(216, 143, 106, 0.2);
      }

      .conversation-name {
        display: block;
        font-weight: 600;
        color: #3f342b;
        margin-bottom: 0.2rem;
      }

      .conversation-meta {
        font-size: 0.75rem;
        color: #7b6f63;
      }

      .conversation-menu-button {
        border: 1px solid transparent;
        background: #fff;
        border-radius: var(--radius-md);
        padding: 0 0.65rem;
        font-size: 1rem;
        cursor: pointer;
        color: #7b6f63;
        transition: border 0.2s ease, box-shadow 0.2s ease;
      }

      .conversation-menu-button:hover {
        border-color: #e6d4bc;
        box-shadow: 0 6px 14px rgba(51, 33, 21, 0.08);
      }

      .conversation-menu {
        position: absolute;
        right: 0;
        top: calc(100% + 0.35rem);
        min-width: 150px;
        width: 180px;
        max-width: calc(100vw - 16px);
        background: #fff;
        border: 1px solid #ecdcc7;
        border-radius: var(--radius-md);
        box-shadow: 0 10px 22px rgba(51, 33, 21, 0.12);
        padding: 0.3rem;
        display: none;
        z-index: 5;
      }

      .conversation-menu.open {
        display: block;
      }

      .conversation-menu-item {
        width: 100%;
        border: none;
        background: transparent;
        text-align: left;
        padding: 0.5rem 0.6rem;
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: 0.85rem;
        color: #4c3a2e;
      }

      .conversation-menu-item:hover {
        background: #f4e5d6;
      }

      .conversation-menu-item--delete::before {
        content: "\1F5D1";
        margin-right: 0.45rem;
      }

      .stream.loading {
        position: relative;
        opacity: 0.75;
      }

      .stream.loading::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(
          110deg,
          rgba(255, 248, 239, 0.2) 8%,
          rgba(255, 248, 239, 0.6) 18%,
          rgba(255, 248, 239, 0.2) 33%
        );
        background-size: 200% 100%;
        animation: shimmer 1.2s ease-in-out infinite;
        border-radius: var(--radius-lg);
        pointer-events: none;
      }

      .model-select {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.3rem 0.7rem;
        border-radius: 999px;
        border: 1px solid #ead9c3;
        background: #fff;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
      }

      .model-select label {
        color: #6b6357;
      }

      .model-select select {
        border: 1px solid #e6d4bc;
        border-radius: 999px;
        padding: 0.2rem 0.6rem;
        background: #fff;
        color: #3f342b;
        font-size: 0.75rem;
        text-transform: none;
        letter-spacing: 0;
      }

      .ghost-button {
        border: none;
        padding: 0.45rem 0.9rem;
        border-radius: 999px;
        background: #f1e3cf;
        color: #5a4c40;
        cursor: pointer;
        font-size: 0.85rem;
        transition: background 0.2s ease, color 0.2s ease;
      }

      .ghost-button:hover {
        background: #e6d4bc;
        color: #3f342b;
      }

      .sidebar-new-chat {
        width: 100%;
        margin-bottom: 0.9rem;
      }

      .stream {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        padding: 1.4rem 0;
        min-height: 380px;
        max-height: 56vh;
        overflow-y: auto;
      }

      .message {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        animation: rise 0.35s ease;
      }

      .message.user {
        align-items: flex-end;
      }

      .message .label {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.12em;
        color: #736a5f;
      }

      .bubble {
        max-width: min(82%, 520px);
        padding: 0.9rem 1.1rem;
        border-radius: var(--radius-lg);
        background: var(--sand);
        color: var(--charcoal);
        line-height: 1.55;
        font-size: 0.98rem;
        white-space: pre-wrap;
      }

      .message.user .bubble {
        background: var(--sand);
        color: var(--charcoal);
        border-top-right-radius: 6px;
      }

      .message.bot .bubble {
        border-top-left-radius: 6px;
      }

      .message.bot-plain {
        color: var(--charcoal);
        line-height: 1.55;
        font-size: 0.98rem;
        white-space: pre-wrap;
      }

      .composer {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.8rem;
        align-items: center;
        padding-top: 1rem;
        border-top: 1px solid #ecdcc7;
      }

      .composer textarea {
        width: 100%;
        border: 1px solid #e6d4bc;
        border-radius: var(--radius-md);
        padding: 0.85rem 1rem;
        font-size: 1rem;
        background: #fff;
        resize: none;
        line-height: 1.45;
        max-height: 200px;
        overflow-y: auto;
      }

      .composer button {
        padding: 0.85rem 1.4rem;
        border: none;
        border-radius: var(--radius-md);
        background: var(--terra);
        color: #fff;
        font-weight: 600;
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
      }

      .composer button:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 20px rgba(24, 33, 44, 0.16);
      }

      .helper-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        font-size: 0.85rem;
        color: #6b6357;
      }

      .pill {
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
        padding: 0.35rem 0.7rem;
        border-radius: 999px;
        border: 1px solid #ead9c3;
        background: #fff;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
      }

      .footer {
        font-size: 0.75rem;
        color: #6b6357;
        text-align: right;
      }

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

      @keyframes shimmer {
        0% {
          background-position: -200% 0;
        }
        100% {
          background-position: 200% 0;
        }
      }
    
