    :root {
      /* Matching main landing page colors */
      --primary: oklch(70% 0.22 145);
      --primary-light: oklch(75% 0.22 145);
      --secondary: oklch(65% 0.22 245);
      --bg-dark: #22252b;
      --bg-card: rgba(42, 47, 56, 0.4);
      --bg-input: rgba(42, 47, 56, 0.6);
      --text-primary: #f8fafc;
      --text-secondary: #cbd5e1;
      --text-muted: #64748b;
      --border: rgba(148, 163, 184, 0.1);
      --border-focus: rgba(16, 185, 129, 0.5);
      --light-subtle: rgba(255, 255, 255, 0.05);
      --shadow-deep: rgba(0, 0, 0, 0.6);
      --messages-fade: rgba(12, 16, 22, 0.9);
      --text-shadow-soft: 0 1px 0 rgba(0, 0, 0, 0.35);

      /* Accent colors */
      --accent-cyan: oklch(75% 0.18 195);
      --accent-purple: oklch(65% 0.25 295);
      --accent-green: oklch(70% 0.22 145);
      --accent-blue: oklch(65% 0.22 245);
      --state-input: oklch(80% 0.18 140);
      --state-processing: oklch(78% 0.2 205);
      --state-inference: oklch(76% 0.23 318);
      --state-returning: oklch(78% 0.2 185);
      --assistant-accent: var(--accent-green);
      --user-accent: var(--accent-blue);
      --in-transit-accent: oklch(72% 0.24 318);
      --app-height: 100svh;
      --kbd: 0px;
      --composer-h: 72px;
      --header-h: 64px;
    }

    html[data-theme="light"] {
      --bg-dark: #f8fafc;
      --bg-card: rgba(255, 255, 255, 0.85);
      --bg-input: rgba(248, 250, 252, 0.9);
      --text-primary: #0f172a;
      --text-secondary: #334155;
      --text-muted: #64748b;
      --border: rgba(15, 23, 42, 0.12);
      --border-focus: rgba(16, 185, 129, 0.45);
      --light-subtle: rgba(15, 23, 42, 0.04);
      --shadow-deep: rgba(15, 23, 42, 0.15);
      --messages-fade: rgba(248, 250, 252, 0.95);
      --text-shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.7);
      --state-input: oklch(60% 0.22 150);
      --state-processing: oklch(62% 0.24 205);
      --state-inference: oklch(64% 0.24 318);
      --state-returning: oklch(60% 0.22 185);
      --assistant-accent: var(--accent-green);
      --user-accent: var(--accent-blue);
      --in-transit-accent: oklch(62% 0.26 318);
    }
    @supports (color: oklch(0% 0 0)) {
      :root {
        --primary: oklch(70% 0.27 145);
        --primary-light: oklch(75% 0.27 145);
        --secondary: oklch(65% 0.27 245);
      }
    }

    @supports (height: 100dvh) {
      :root {
        --app-height: 100dvh;
      }
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    html,
    body {
      height: 100%;
      overflow-x: hidden;
    }

    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      background: var(--bg-dark);
      color: var(--text-primary);
      line-height: 1.6;
      height: var(--app-height);
      display: flex;
      flex-direction: column;
      overflow-x: hidden;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      /* Safe area insets for edge-to-edge devices */
      padding-left: env(safe-area-inset-left, 0px);
      padding-right: env(safe-area-inset-right, 0px);
    }

    html.keyboard-open body {
      overflow: hidden;
    }

    html.keyboard-open .site-footer {
      display: none;
    }

    .container {
      max-width: clamp(320px, 92vw, 1180px);
      margin: 0 auto;
      width: 100%;
      padding: 0 1rem;
    }

    /* Subtle background */
    body::before {
      content: '';
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background:
        radial-gradient(ellipse at 20% 20%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(14, 165, 233, 0.04) 0%, transparent 50%);
      pointer-events: none;
      z-index: -1;
    }

    html[data-theme="light"] body::before {
      background:
        radial-gradient(ellipse at 20% 20%, rgba(16, 185, 129, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(14, 165, 233, 0.08) 0%, transparent 50%);
    }

    /* Header */
    header {
      padding: 1rem 1.5rem;
      background: rgba(34, 37, 43, 0.8);
      -webkit-backdrop-filter: blur(16px) saturate(180%);
      backdrop-filter: blur(16px) saturate(180%);
      border-bottom: 1px solid var(--border);
      box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: center;
      gap: 0.75rem;
      position: sticky;
      top: 0;
      z-index: 100;
    }

    html[data-theme="light"] header {
      background: rgba(248, 250, 252, 0.9);
    }

    .back-link {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      color: var(--text-secondary);
      text-decoration: none;
      font-size: 0.9rem;
      background-image: linear-gradient(90deg, var(--primary), var(--secondary));
      background-size: 0% 100%;
      background-repeat: no-repeat;
      background-position: 0 100%;
      -webkit-background-clip: text;
      background-clip: text;
      transition: color 0.3s ease, text-shadow 0.3s ease, background-size 0.6s ease;
      flex-shrink: 0;
      text-shadow: var(--text-shadow-soft);
    }

    .back-link:hover {
      color: transparent;
      -webkit-text-fill-color: transparent;
      background-size: 100% 100%;
      text-shadow:
        0 0 12px color-mix(in oklch, var(--primary) 50%, transparent),
        0 0 22px color-mix(in oklch, var(--secondary) 40%, transparent);
    }

    .back-link svg {
      width: 18px;
      height: 18px;
      color: var(--text-secondary);
      transition: color 0.3s ease, filter 0.3s ease;
    }

    .back-link:hover svg {
      color: var(--primary);
      filter: drop-shadow(0 0 8px color-mix(in oklch, var(--primary) 60%, transparent));
    }

    .header-title {
      font-size: clamp(1.6rem, 4.6vw, 2.8rem);
      font-weight: 700;
      letter-spacing: -0.02em;
      text-align: center;
      min-width: 0;
      display: flex;
      align-items: baseline;
      justify-content: center;
      white-space: nowrap;
      padding-bottom: 0.2rem;
      text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(59, 130, 246, 0.3);
    }

    .title-lock {
      position: relative;
      display: inline-block;
      width: max-content;
      padding-right: clamp(2.2rem, 6vw, 3.6rem);
    }

    .title-strong {
      font-size: clamp(2.2rem, 6.4vw, 3.6rem);
      font-weight: 900;
      letter-spacing: -0.03em;
      background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
      background-size: 200% 200%;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      transform: rotate(-1deg);
      display: inline-block;
      text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.35);
    }

    .title-script {
      font-family: 'Caveat', 'Segoe Script', cursive;
      font-weight: 600;
      font-size: clamp(1.7rem, 5.2vw, 2.8rem);
      color: color-mix(in oklch, var(--accent-cyan) 70%, #fff 10%);
      position: absolute;
      left: 50%;
      top: 72%;
      width: max-content;
      transform: translate(-14%, -46%) rotate(-10deg);
      text-shadow:
        0 0 12px color-mix(in oklch, var(--accent-cyan) 55%, transparent),
        0 3px 8px rgba(9, 17, 28, 0.4);
      pointer-events: none;
      white-space: nowrap;
    }

    .header-title:hover .title-strong,
    .header-title:focus-within .title-strong,
    .header-title.is-active .title-strong {
      animation: headerShimmer 2.6s ease-in-out infinite;
    }

    @keyframes headerShimmer {
      0%, 100% {
        background-position: 0% 50%;
      }
      50% {
        background-position: 100% 50%;
      }
    }

    html[data-theme="light"] .header-title {
      text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.5),
        0 2px 6px rgba(15, 23, 42, 0.15);
    }

    html[data-theme="light"] .title-script {
      color: color-mix(in oklch, var(--accent-cyan) 70%, #0f172a 15%);
    }

    .header-spacer {
      width: 80px;
    }

    /* Environment Badge */
    .env-badge {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.5rem 1rem;
      background: rgba(148, 163, 184, 0.1);
      border: 1px solid rgba(148, 163, 184, 0.3);
      border-radius: 1rem;
      font-size: 0.85rem;
      color: var(--text-muted);
      animation: fadeIn 0.4s ease-out;
      transition: all 0.3s ease;
      flex-shrink: 0;
    }

    .env-badge.active {
      background: rgba(16, 185, 129, 0.1);
      border-color: rgba(16, 185, 129, 0.3);
      color: var(--primary);
    }

    .env-badge.connecting {
      background: rgba(59, 130, 246, 0.12);
      border-color: rgba(59, 130, 246, 0.35);
      color: var(--secondary);
    }

    .env-badge.disconnected {
      background: rgba(239, 68, 68, 0.12);
      border-color: rgba(239, 68, 68, 0.35);
      color: #ef4444;
    }

    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: currentColor;
      opacity: 0.5;
      transition: all 0.3s ease;
    }

    .env-badge.active .status-dot,
    .env-badge.connecting .status-dot {
      opacity: 1;
      animation: pulse 2s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }

    /* ========================================================================
       Tier Selector - 3/4-tier toggle system with optional Custom dropdown
       ======================================================================== */

    /* Tier Selector Panel (collapsible container below header) */
    .tier-selector-panel {
      height: 0;
      overflow: visible;
      transition: opacity 0.3s ease;
      background: rgba(34, 37, 43, 0.4);
      border-bottom: 1px solid transparent;
      position: relative;
      z-index: 90;
      pointer-events: none;
      visibility: hidden;
    }

    html[data-theme="light"] .tier-selector-panel {
      background: rgba(248, 250, 252, 0.6);
    }

    .tier-selector-panel.open {
      border-bottom-color: var(--border);
      z-index: 110;
      pointer-events: auto;
      visibility: visible;
    }

    .tier-selector {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.75rem;
      padding: 1rem 1.5rem;
      position: absolute;
      left: 50%;
      top: 0.75rem;
      transform: translateX(-50%);
      width: min(980px, calc(100% - 2rem));
      background: rgba(34, 37, 43, 0.5);
      border: 1px solid rgba(148, 163, 184, 0.2);
      border-radius: 1rem;
      box-shadow:
        0 16px 30px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
      backdrop-filter: blur(18px) saturate(165%);
    }

    html[data-theme="light"] .tier-selector {
      background: rgba(248, 250, 252, 0.82);
      border-color: rgba(15, 23, 42, 0.12);
      box-shadow:
        0 12px 22px rgba(15, 23, 42, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    }
    /* Tier Buttons Container */
    .tier-buttons {
      display: flex;
      gap: 0.25rem;
      padding: 0.25rem;
      background: rgba(148, 163, 184, 0.08);
      border: 1px solid rgba(148, 163, 184, 0.2);
      border-radius: 0.75rem;
      backdrop-filter: blur(8px);
    }

    html[data-theme="light"] .tier-buttons {
      background: rgba(15, 23, 42, 0.05);
      border-color: rgba(15, 23, 42, 0.12);
    }

    /* Individual Tier Button */
    .tier-button {
      display: flex;
      align-items: center;
      gap: 0.375rem;
      padding: 0.5rem 0.875rem;
      background: transparent;
      border: none;
      border-radius: 0.5rem;
      font-size: 0.85rem;
      font-weight: 500;
      color: var(--text-muted);
      cursor: pointer;
      transition: all 0.2s ease;
      white-space: nowrap;
      position: relative;
      text-shadow: var(--text-shadow-soft);
    }

    .tier-button:hover:not(:disabled) {
      background: rgba(148, 163, 184, 0.15);
      color: var(--text-secondary);
    }

    .tier-button.active {
      background: rgba(16, 185, 129, 0.15);
      color: var(--primary);
      box-shadow:
        inset 0 0 0 1px rgba(16, 185, 129, 0.3),
        0 2px 6px rgba(16, 185, 129, 0.2);
    }

    .tier-button.unavailable {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .tier-button:disabled {
      cursor: not-allowed;
    }

    .tier-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 1.1rem;
      height: 1.1rem;
      flex-shrink: 0;
    }

    .tier-icon svg {
      width: 100%;
      height: 100%;
      stroke: currentColor;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .tier-label {
      font-size: 0.85rem;
    }

    /* Custom Tier Button - special styling for dropdown arrow */
    .tier-button.custom-tier .dropdown-arrow {
      width: 14px;
      height: 14px;
      margin-left: -0.125rem;
      transition: transform 0.2s ease;
    }

    .tier-button.custom-tier.dropdown-open .dropdown-arrow {
      transform: rotate(180deg);
    }

    /* Tier Status Badge */
    .tier-status-badge {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.45rem 0.75rem;
      background: rgba(148, 163, 184, 0.1);
      border: 1px solid rgba(148, 163, 184, 0.3);
      border-radius: 1rem;
      font-size: 0.85rem;
      color: var(--text-muted);
      transition: all 0.3s ease;
      cursor: pointer;
      width: max-content;
      max-width: 100%;
      min-width: 0;
      flex-wrap: nowrap;
      text-shadow: var(--text-shadow-soft);
    }

    .tier-status-badge:hover {
      background: rgba(148, 163, 184, 0.15);
      border-color: rgba(148, 163, 184, 0.4);
    }

    .tier-toggle-arrow {
      width: 1rem;
      height: 1rem;
      transition: transform 0.2s ease;
    }

    .tier-status-badge[aria-expanded="true"] .tier-toggle-arrow {
      transform: rotate(180deg);
    }

    .tier-status-badge.active {
      background: rgba(16, 185, 129, 0.12);
      border-color: rgba(16, 185, 129, 0.35);
      color: var(--primary);
    }

    .tier-status-badge.connecting {
      background: rgba(56, 189, 248, 0.12);
      border-color: rgba(56, 189, 248, 0.35);
      color: var(--accent-cyan);
    }

    .tier-status-badge.disconnected {
      background: rgba(248, 113, 113, 0.12);
      border-color: rgba(248, 113, 113, 0.35);
      color: #f87171;
    }

    .tier-model-name {
      min-width: 0;
      max-width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .tier-status-badge .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: currentColor;
      opacity: 0.5;
      transition: all 0.3s ease;
    }

    .tier-status-badge.active .status-dot,
    .tier-status-badge.connecting .status-dot {
      opacity: 1;
      animation: pulse 2s ease-in-out infinite;
    }

    .tier-env-label {
      font-size: 0.75rem;
      opacity: 0.7;
      margin-left: -0.25rem;
      text-shadow: var(--text-shadow-soft);
    }

    /* Custom Dropdown Panel */
    .custom-dropdown {
      position: absolute;
      top: calc(100% + 0.75rem);
      right: 0;
      width: min(360px, calc(100vw - 2rem));
      max-height: 0;
      overflow: hidden;
      background: rgba(22, 26, 33, 0.94);
      border: 1px solid rgba(148, 163, 184, 0.28);
      border-radius: 0.75rem;
      backdrop-filter: blur(22px) saturate(170%);
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
      opacity: 0;
      transform: translateY(-8px);
      transition: all 0.25s ease;
      z-index: 1000;
    }

    html[data-theme="light"] .custom-dropdown {
      background: rgba(255, 255, 255, 0.92);
      border-color: rgba(15, 23, 42, 0.18);
      box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
    }

    .custom-dropdown.open {
      max-height: 400px;
      overflow-y: auto;
      opacity: 1;
      transform: translateY(0);
    }

    .dropdown-header {
      padding: 0.875rem 1rem;
      border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    }

    .dropdown-title {
      font-size: 0.875rem;
      font-weight: 600;
      color: var(--text-primary);
    }

    /* Custom Model List */
    .custom-model-list {
      padding: 0.5rem;
      max-height: 340px;
      overflow-y: auto;
    }

    .custom-model-item {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.75rem;
      border-radius: 0.5rem;
      cursor: pointer;
      transition: all 0.15s ease;
      border: 1px solid transparent;
      text-shadow: var(--text-shadow-soft);
    }

    .custom-model-item:hover {
      background: rgba(148, 163, 184, 0.1);
    }

    .custom-model-item.selected {
      background: rgba(16, 185, 129, 0.1);
      border-color: rgba(16, 185, 129, 0.3);
    }

    .custom-model-item .model-check {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
      color: var(--primary);
      opacity: 0;
    }

    .custom-model-item.selected .model-check {
      opacity: 1;
    }

    .custom-model-item .model-info {
      flex: 1;
      min-width: 0;
    }

    .custom-model-item .model-name {
      font-size: 0.875rem;
      font-weight: 500;
      color: var(--text-primary);
      margin-bottom: 0.125rem;
    }

    .custom-model-item .model-provider {
      font-size: 0.75rem;
      color: var(--text-muted);
    }

    .custom-model-item .model-badges {
      display: flex;
      gap: 0.25rem;
      flex-shrink: 0;
    }

    .custom-model-item .model-badge {
      padding: 0.125rem 0.375rem;
      border-radius: 0.25rem;
      font-size: 0.7rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.025em;
    }

    .model-badge.fast {
      background: rgba(34, 197, 94, 0.15);
      color: #22c55e;
    }

    .model-badge.medium {
      background: rgba(59, 130, 246, 0.15);
      color: #3b82f6;
    }

    .model-badge.slow {
      background: rgba(168, 85, 247, 0.15);
      color: #a855f7;
    }

    .model-badge.hq {
      background: rgba(251, 191, 36, 0.15);
      color: #fbbf24;
    }

    /* Responsive - Mobile */
    @media (max-width: 640px) {
      header {
        row-gap: 0.6rem;
        grid-template-columns: auto minmax(0, 1fr);
        padding-bottom: 0.95rem;
      }

      .back-link {
        order: 1;
      }

      .header-title {
        order: 1;
        grid-column: 1 / -1;
      }

      .tier-status-badge {
        order: 2;
        grid-column: 1 / -1;
        justify-content: center;
        margin: 0.35rem auto 0;
        flex-wrap: wrap;
      }

      .tier-selector {
        flex-direction: column;
        gap: 0.5rem;
        width: calc(100% - 1.5rem);
        padding: 0.85rem 1rem;
        top: 0.5rem;
      }

      .tier-buttons {
        width: 100%;
        justify-content: space-between;
      }

      .tier-button {
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.5rem;
      }

      .tier-label {
        display: none; /* Show icons only on mobile */
      }

      .tier-icon {
        width: 1.3rem;
        height: 1.3rem;
      }

      .tier-status-badge {
        font-size: 0.75rem;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        row-gap: 0.25rem;
      }

      .tier-model-name {
        white-space: normal;
        text-align: center;
      }

      .custom-dropdown {
        left: 0;
        right: 0;
        width: auto;
      }
    }

    @media (max-width: 420px) {
      header {
        gap: 0.5rem;
        row-gap: 0.5rem;
        padding: 0.7rem 0.85rem;
        padding-bottom: 0.9rem;
      }

      .back-link {
        font-size: 0.78rem;
      }

      .back-link svg {
        width: 16px;
        height: 16px;
      }

      .header-title {
        font-size: clamp(1.5rem, 6vw, 2.2rem);
      }

      .title-strong {
        font-size: clamp(1.9rem, 7vw, 2.7rem);
      }

      .title-script {
        font-size: clamp(1.4rem, 5.8vw, 2.1rem);
        left: 36%;
        top: 78%;
      }

      .tier-status-badge {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        align-self: center;
        flex-basis: auto;
        max-width: 100%;
        padding: 0.4rem 0.6rem;
        flex-wrap: wrap;
        row-gap: 0.25rem;
        margin: 0 auto;
      }

      .tier-model-name {
        white-space: normal;
        max-width: 100%;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }

    /* Responsive - Tablet */
    @media (max-width: 768px) and (min-width: 641px) {
      .tier-button {
        padding: 0.5rem 0.75rem;
      }

      .tier-label {
        font-size: 0.8rem;
      }
    }

    /* Accessibility - Reduced Motion */
    @media (prefers-reduced-motion: reduce) {
      .tier-button,
      .tier-status-badge,
      .custom-dropdown,
      .custom-model-item {
        transition: none;
      }

      .tier-status-badge .status-dot {
        animation: none !important;
      }
    }

    /* Main Chat Area */
    main {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      max-width: clamp(320px, 92vw, 1180px);
      width: 100%;
      margin: 0 auto;
      overflow: hidden;
      overflow-x: hidden;
      padding: 0.9rem clamp(0.85rem, 2vw, 1rem) 0;
      position: relative;
      min-height: 0;
      box-sizing: border-box;
    }

    /* Messages Container */
    #messages {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding: clamp(1.4rem, 2.4vw, 1.9rem);
      padding-top: calc(clamp(1.4rem, 2.4vw, 1.9rem) + 2.4rem);
      display: flex;
      flex-direction: column;
      gap: 1rem;
      position: relative;
      padding-bottom: clamp(1.1rem, 2vw, 1.6rem);
      scroll-padding-bottom: calc(var(--composer-h) + 1rem + env(safe-area-inset-bottom, 0px) + var(--kbd));
      border-radius: 1.25rem;
      overflow-x: hidden;
      background: rgba(255, 255, 255, 0.012);
      border: 1px solid rgba(255, 255, 255, 0.02);
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.02),
        0 4px 10px rgba(0, 0, 0, 0.12);
    }

    #messages {
      background: rgba(15, 23, 42, 0.03);
      border-color: rgba(15, 23, 42, 0.05);
    }

    #messages::before,
    #messages::after {
      content: '';
      position: sticky;
      left: 0;
      right: 0;
      height: clamp(2.25rem, 6vh, 3.5rem);
      display: block;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.25s ease;
      z-index: 2;
    }

    #messages::before {
      top: 0;
      background: linear-gradient(180deg, var(--messages-fade) 0%, transparent 100%);
    }

    #messages::after {
      bottom: 0;
      background: linear-gradient(0deg, var(--messages-fade) 0%, transparent 100%);
    }

    #messages.has-top-fade::before {
      opacity: 1;
    }

    #messages.has-bottom-fade::after {
      opacity: 1;
    }

    .scroll-latest {
      position: absolute;
      left: 50%;
      bottom: 7.5rem;
      transform: translate(-50%, 8px);
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.65rem 1rem;
      border-radius: 999px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: linear-gradient(135deg, rgba(15, 23, 42, 0.72), rgba(30, 41, 59, 0.7));
      color: var(--text-primary);
      font-size: 0.85rem;
      font-weight: 600;
      letter-spacing: 0.01em;
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 16px 28px rgba(0, 0, 0, 0.35);
      backdrop-filter: blur(16px) saturate(160%);
      -webkit-backdrop-filter: blur(16px) saturate(160%);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease, transform 0.2s ease;
      z-index: 5;
    }

    .scroll-latest svg {
      width: 18px;
      height: 18px;
    }

    .scroll-latest.is-visible {
      opacity: 1;
      transform: translate(-50%, 0);
      pointer-events: auto;
    }

    html[data-theme="light"] .scroll-latest {
      background: linear-gradient(135deg, rgba(248, 250, 252, 0.92), rgba(226, 232, 240, 0.9));
      color: var(--text-primary);
      border-color: rgba(15, 23, 42, 0.15);
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.65),
        0 10px 18px rgba(15, 23, 42, 0.12);
    }

    /* Welcome State */
    .welcome {
      text-align: center;
      padding: clamp(2.5rem, 6vh, 3.25rem) 1.25rem;
      animation: fadeIn 0.4s ease-out;
    }

    .welcome h2 {
      font-size: clamp(1.5rem, 2.8vw, 2.1rem);
      font-weight: 700;
      margin-bottom: 0.85rem;
      letter-spacing: -0.015em;
      background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      color: transparent;
      text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.5),
        0 10px 24px rgba(15, 23, 42, 0.18);
    }

    html[data-theme="light"] .welcome h2 {
      background: linear-gradient(
        135deg,
        oklch(48% 0.26 245),
        oklch(52% 0.22 190)
      );
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      color: transparent;
      text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.5),
        0 12px 26px rgba(15, 23, 42, 0.24);
    }

    .welcome p {
      color: var(--text-secondary);
      margin-bottom: 1.5rem;
      max-width: 460px;
      margin-left: auto;
      margin-right: auto;
      line-height: 1.6;
    }

    .suggestions {
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem;
      justify-content: center;
    }

    .suggestion {
      background: var(--bg-card);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 2rem;
      padding: 0.625rem 1.25rem;
      font-size: 0.875rem;
      color: var(--text-secondary);
      cursor: pointer;
      transition: all 0.2s;
      -webkit-backdrop-filter: blur(16px) saturate(180%);
      backdrop-filter: blur(16px) saturate(180%);
      box-shadow: inset 0 1px 0 var(--light-subtle), 0 2px 8px rgba(0, 0, 0, 0.18);
      text-shadow: var(--text-shadow-soft);
    }

    .suggestion:hover {
      background: rgba(16, 185, 129, 0.1);
      border-color: var(--primary);
      color: var(--text-primary);
      transform: translateY(-2px);
    }

    /* Messages */
    .message {
      display: flex;
      gap: 0.75rem;
      animation: slideIn 0.3s ease-out;
      min-width: 0;
      align-items: flex-start;
    }

    .message.user {
      flex-direction: row-reverse;
    }

    .avatar {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      margin-top: 0.2rem;
      margin-right: 0;
      margin-left: 0;
      position: relative;
      overflow: hidden;
      border: 1px solid color-mix(in oklch, currentColor 30%, transparent);
      box-shadow:
        0 8px 18px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    }

    .avatar::before {
      content: '';
      position: absolute;
      inset: 4px;
      border-radius: 50%;
      background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.65), transparent 55%);
      opacity: 0.6;
      pointer-events: none;
    }

    .avatar svg {
      width: 22px;
      height: 22px;
      stroke: currentColor;
      filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
    }

    .message.user .avatar {
      background: linear-gradient(135deg, var(--user-accent), color-mix(in oklch, var(--user-accent) 70%, #3b82f6));
      color: #f8fafc;
      box-shadow:
        0 10px 18px rgba(0, 0, 0, 0.32),
        0 0 16px color-mix(in oklch, var(--user-accent) 45%, transparent);
      animation: userIdle 5.5s ease-in-out infinite;
    }

    .message.assistant .avatar {
      background: linear-gradient(135deg, var(--assistant-accent), var(--primary-light));
      color: #0a0f1a;
      box-shadow:
        0 10px 18px rgba(0, 0, 0, 0.32),
        0 0 16px color-mix(in oklch, var(--assistant-accent) 45%, transparent);
      animation: assistantIdle 6s ease-in-out infinite;
    }

    .message.assistant .avatar::after {
      content: '';
      position: absolute;
      inset: -25%;
      background: radial-gradient(circle, color-mix(in oklch, var(--in-transit-accent) 35%, transparent) 0%, transparent 60%);
      opacity: 0;
      transition: opacity 0.2s ease;
      pointer-events: none;
    }

    body.assistant-thinking .message.assistant .avatar {
      animation: assistantGlow 1.6s ease-in-out infinite;
    }

    body.assistant-thinking .message.assistant .avatar::after {
      opacity: 1;
    }

    body.user-typing .message.user:last-of-type .avatar {
      animation: userTyping 2.8s ease-in-out infinite;
      box-shadow: 0 0 14px color-mix(in oklch, var(--in-transit-accent) 45%, transparent);
    }

    .content {
      max-width: min(82%, 760px);
      padding: 0.85rem 1.05rem;
      border-radius: 1.1rem;
      font-size: 0.94rem;
      background: var(--bg-card);
      border: 1px solid rgba(255, 255, 255, 0.12);
      -webkit-backdrop-filter: blur(16px) saturate(180%);
      backdrop-filter: blur(16px) saturate(180%);
      box-shadow:
        inset 0 1px 0 var(--light-subtle),
        0 4px 16px rgba(0, 0, 0, 0.3);
      overflow-wrap: anywhere;
      word-break: break-word;
      min-width: 0;
    }

    @media (min-width: 700px) {
      header {
        padding-bottom: clamp(1.2rem, 1.6vw, 1.6rem);
      }
    }

    @media (min-width: 900px) {
      header {
        padding-top: 1.15rem;
        padding-bottom: clamp(1.35rem, 1.8vw, 1.75rem);
      }
    }

    @media (max-width: 420px) and (max-height: 740px) {
      header {
        padding: 0.55rem 0.75rem;
        padding-bottom: 0.75rem;
      }

      .header-title {
        font-size: clamp(1.35rem, 5vw, 2rem);
      }

      .title-strong {
        font-size: clamp(1.7rem, 6vw, 2.4rem);
      }

      .title-script {
        font-size: clamp(1.25rem, 4.8vw, 1.8rem);
        top: 70%;
      }

      .title-lock {
        padding-right: clamp(1.6rem, 5vw, 2.4rem);
      }

      main {
        padding: 0.5rem 0.45rem 0;
      }

      #messages {
        padding: 0.65rem;
        padding-top: calc(0.65rem + 1.05rem);
      }

      .input-area {
        padding: 0.5rem 0.45rem 0.8rem;
      }
    }

    @media (max-width: 430px) and (max-height: 860px) {
      header {
        row-gap: 0.45rem;
        padding: 0.65rem 0.8rem;
        padding-bottom: 0.85rem;
      }

      .header-title {
        font-size: clamp(1.4rem, 5vw, 2.2rem);
      }

      .title-strong {
        font-size: clamp(1.75rem, 6.2vw, 2.5rem);
      }

      .title-script {
        font-size: clamp(1.3rem, 5vw, 1.95rem);
        top: 78%;
      }

      .title-lock {
        padding-right: clamp(1.8rem, 5vw, 2.6rem);
      }

      .tier-status-badge {
        padding: 0.4rem 0.7rem;
      }

      main {
        padding: 0.5rem 0.45rem 0;
      }

      #messages {
        padding: 0.65rem;
        padding-top: calc(0.65rem + 1.1rem);
      }

      .input-area {
        padding: 0.5rem 0.45rem 0.8rem;
      }
    }

    @media (min-width: 1100px) {
      main {
        max-width: clamp(980px, 88vw, 1280px);
      }

      #messages {
        background: transparent;
        border-color: transparent;
        box-shadow: none;
      }

      .content {
        max-width: min(82%, 860px);
      }
    }

    .message.user .content {
      background: rgba(14, 165, 233, 0.15);
      border-color: rgba(14, 165, 233, 0.2);
      border-bottom-right-radius: 0.25rem;
    }

    .message.assistant .content {
      border-bottom-left-radius: 0.25rem;
      border-left: 1px solid color-mix(in oklch, var(--assistant-accent) 35%, transparent);
      box-shadow:
        inset 0 1px 0 var(--light-subtle),
        0 4px 16px rgba(0, 0, 0, 0.3),
        0 0 18px color-mix(in oklch, var(--assistant-accent) 18%, transparent);
    }

    html[data-theme="light"] .message.assistant .content {
      border-left: 1px solid rgba(15, 23, 42, 0.06);
    }

    /* Markdown Styling */
    .content h1, .content h2, .content h3 {
      margin-top: 1rem;
      margin-bottom: 0.5rem;
      font-weight: 650;
      line-height: 1.3;
      color: var(--text-primary);
      display: block;
      width: 100%;
      padding-left: 0.6rem;
      border-left: 3px solid var(--primary);
    }

    .content h1 { font-size: clamp(1.3rem, 2.2vw, 1.6rem); }
    .content h2 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
    .content h3 { font-size: clamp(1.05rem, 1.8vw, 1.25rem); }

    .content p {
      margin-bottom: 0.75rem;
    }

    .content strong {
      font-weight: 600;
      color: var(--text-primary);
    }

    .content em {
      font-style: italic;
      color: var(--text-secondary);
    }

    .content code {
      background: rgba(16, 185, 129, 0.1);
      border: 1px solid rgba(16, 185, 129, 0.2);
      border-radius: 0.25rem;
      padding: 0.125rem 0.375rem;
      font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
      font-size: 0.875em;
      color: var(--primary-light);
    }

    .content pre {
      background: rgba(0, 0, 0, 0.3);
      border: 1px solid var(--border);
      border-radius: 0.5rem;
      padding: 1rem;
      overflow-x: auto;
      margin: 0.75rem 0;
    }

    .content pre code {
      background: none;
      border: none;
      padding: 0;
      color: var(--text-primary);
      font-size: 0.875rem;
      line-height: 1.5;
    }

    .content ul, .content ol {
      margin: 0.75rem 0 0.75rem 0.5rem;
      padding-left: 0.75rem;
      list-style-position: inside;
    }

    .content ul {
      list-style-type: disc;
    }

    .content ol {
      list-style-type: decimal;
    }

    .content > ul,
    .content > ol {
      margin-left: 0;
    }

    .content ul ul,
    .content ol ol,
    .content ul ol,
    .content ol ul {
      margin-top: 0.5rem;
      margin-bottom: 0.5rem;
      padding-left: 0.85rem;
      list-style-position: inside;
    }

    .content li {
      margin-bottom: 0.375rem;
      line-height: 1.5;
      padding-left: 0.35rem;
      list-style-position: inside;
    }

    /* Footer */
    .site-footer {
      padding: 0.75rem 0 0.85rem;
      border-top: 1px solid var(--border);
      background: rgba(34, 37, 43, 0.6);
    }

    html[data-theme="light"] .site-footer {
      background: rgba(248, 250, 252, 0.9);
    }

    .footer-content {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.9rem 1rem;
      margin-bottom: 0.45rem;
    }

    .footer-privacy {
      display: block;
      margin-top: 0.35rem;
      scroll-margin-top: calc(var(--header-h) + 0.75rem);
    }

    .footer-links {
      display: flex;
      flex-wrap: wrap;
      gap: 1rem;
      list-style: none;
      margin: 0;
      padding: 0;
      flex: 1 1 220px;
    }

    .footer-links a {
      color: var(--text-muted);
      text-decoration: none;
      font-size: 0.75rem;
      font-weight: 500;
      opacity: 0.85;
      text-shadow: none;
    }

    .footer-links a:hover {
      color: var(--text-secondary);
    }

    .theme-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      position: relative;
      width: 40px;
      height: 40px;
      padding: 0;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(15, 23, 42, 0.35);
      color: var(--text-secondary);
      font-size: 0.8rem;
      cursor: pointer;
      text-shadow: var(--text-shadow-soft);
      margin-left: auto;
      order: 3;
    }

    @media (min-width: 700px) {
      .footer-content {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
        gap: 1rem;
        row-gap: 0.6rem;
      }

      .footer-links {
        grid-column: 1;
      }

      .privacy-inline-summary {
        grid-column: 2;
        justify-self: center;
      }

      .theme-toggle {
        margin-left: 0;
        grid-column: 3;
        justify-self: end;
      }
    }

    html[data-theme="light"] .theme-toggle {
      background: rgba(255, 255, 255, 0.8);
    }

    .theme-toggle-icon {
      display: inline-flex;
      position: relative;
      width: 18px;
      height: 18px;
    }

    .theme-toggle-icon svg {
      position: absolute;
      inset: 0;
      width: 18px;
      height: 18px;
      transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .theme-toggle-icon .icon-sun {
      opacity: 0;
      transform: rotate(-90deg);
    }

    html[data-theme="light"] .theme-toggle-icon .icon-sun {
      opacity: 1;
      transform: rotate(0deg);
    }

    html[data-theme="light"] .theme-toggle-icon .icon-moon {
      opacity: 0;
      transform: rotate(90deg);
    }

    .theme-toggle-label {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    .footer-copy {
      color: var(--text-muted);
      font-size: 0.7rem;
      margin: 0;
      opacity: 0.8;
      letter-spacing: 0.01em;
    }

    .footer-meta {
      display: flex;
      justify-content: center;
      margin-top: 0.45rem;
    }

    @media (max-width: 640px) {
      .footer-content {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.75rem;
      }

      .footer-links {
        gap: 0.65rem;
      }
    }

    .content a {
      color: var(--secondary);
      text-decoration: none;
      border-bottom: 1px solid rgba(14, 165, 233, 0.3);
      transition: border-color 0.2s;
    }

    .content a:hover {
      border-bottom-color: var(--secondary);
    }

    .content table {
      width: max-content;
      min-width: 100%;
      border-collapse: collapse;
      margin: 0.75rem 0;
      font-size: 0.9rem;
      display: block;
      overflow-x: auto;
      max-width: 100%;
      table-layout: auto;
    }

    .content th, .content td {
      padding: 0.5rem 0.75rem;
      border: 1px solid var(--border);
      text-align: left;
      min-width: 140px;
    }

    .content th {
      background: rgba(16, 185, 129, 0.1);
      font-weight: 600;
      color: var(--primary);
    }

    .content tr:nth-child(even) {
      background: rgba(255, 255, 255, 0.02);
    }

    /* Thinking Section */
    .thinking-section {
      margin-top: 0.75rem;
      border-top: 1px solid var(--border);
      padding-top: 0.75rem;
    }

    .thinking-toggle {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      color: var(--text-muted);
      font-size: 0.85rem;
      cursor: pointer;
      user-select: none;
      transition: color 0.2s;
    }

    .thinking-toggle:hover {
      color: var(--text-secondary);
    }

    .thinking-toggle svg {
      width: 14px;
      height: 14px;
      transition: transform 0.2s;
    }

    .thinking-toggle.expanded svg {
      transform: rotate(90deg);
    }

    .thinking-content {
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.3s ease-out;
      margin-top: 0.5rem;
      color: var(--text-muted);
      font-size: 0.875rem;
      line-height: 1.6;
      font-style: italic;
      opacity: 0.7;
    }

    .thinking-content.expanded {
      max-height: 500px;
      overflow-y: auto;
    }

    /* Hide thinking output in production while keeping it available in the DOM */
    .thinking-section {
      display: none;
    }

    /* State Tracker */
    .state-tracker {
      display: none;
      align-items: center;
      gap: 0.75rem;
      padding: 0.6rem 1.1rem;
      background: linear-gradient(135deg, color-mix(in oklch, var(--assistant-accent) 22%, transparent), color-mix(in oklch, var(--assistant-accent) 8%, transparent));
      border: 1px solid color-mix(in oklch, var(--assistant-accent) 35%, transparent);
      border-radius: 1rem;
      font-size: 0.875rem;
      color: var(--in-transit-accent);
      position: absolute;
      top: clamp(1rem, 3vw, 1.75rem);
      left: 50%;
      transform: translate(-50%, -6px);
      width: fit-content;
      max-width: min(92%, 560px);
      justify-content: center;
      white-space: nowrap;
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 12px 24px rgba(0, 0, 0, 0.25);
      -webkit-backdrop-filter: blur(18px) saturate(160%);
      backdrop-filter: blur(18px) saturate(160%);
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.2s ease, transform 0.2s ease;
      z-index: 4;
    }

    .state-tracker.active {
      display: flex;
      opacity: 1;
      transform: translate(-50%, 0);
    }

    html[data-theme="light"] .state-tracker {
      background: linear-gradient(135deg, color-mix(in oklch, var(--assistant-accent) 18%, transparent), color-mix(in oklch, var(--assistant-accent) 8%, transparent));
      border-color: color-mix(in oklch, var(--assistant-accent) 35%, transparent);
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        0 10px 20px rgba(15, 23, 42, 0.12);
    }

    .state-icon {
      width: 18px;
      height: 18px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: currentColor;
      flex-shrink: 0;
      animation: pulse 1.4s ease-in-out infinite;
      filter: drop-shadow(0 0 8px color-mix(in oklch, currentColor 60%, transparent));
    }

    .state-icon svg {
      width: 18px;
      height: 18px;
    }

    .state-text {
      font-weight: 600;
      text-shadow:
        var(--text-shadow-soft),
        0 0 8px color-mix(in oklch, currentColor 35%, transparent);
    }

    .response-badge {
      margin-top: 0.85rem;
      padding-top: 0.75rem;
      border-top: 1px solid color-mix(in oklch, var(--assistant-accent) 30%, transparent);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      color: var(--text-secondary);
    }

    .model-badge {
      display: inline-flex;
      align-items: center;
      gap: 0.45rem;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--assistant-accent);
      line-height: 1;
    }

    .model-icon {
      display: inline-flex;
      align-items: center;
    }

    .model-icon svg {
      width: 16px;
      height: 16px;
      display: block;
    }

    .model-name {
      display: inline-flex;
      align-items: center;
    }

    .copy-button {
      border: 1px solid var(--border);
      background: rgba(15, 23, 42, 0.35);
      color: var(--text-secondary);
      width: 32px;
      height: 32px;
      border-radius: 10px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    }

    html[data-theme="light"] .copy-button {
      background: rgba(255, 255, 255, 0.75);
    }

    .copy-button:hover {
      color: var(--text-primary);
      border-color: rgba(14, 165, 233, 0.3);
    }

    .copy-button:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .copy-icon {
      width: 18px;
      height: 18px;
    }


    /* Typing Indicator */
    .typing {
      display: flex;
      gap: 0.3rem;
      padding: 0.5rem 0;
    }

    .typing span {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--text-muted);
      animation: pulse 1.4s infinite;
    }

    .typing span:nth-child(2) { animation-delay: 0.2s; }
    .typing span:nth-child(3) { animation-delay: 0.4s; }

    @keyframes pulse {
      0%, 60%, 100% { opacity: 0.3; }
      30% { opacity: 1; }
    }

    @keyframes assistantGlow {
      0%, 100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 0 14px color-mix(in oklch, var(--assistant-accent) 45%, transparent);
      }
      50% {
        transform: translateY(-2px) scale(1.03);
        box-shadow:
          0 0 18px color-mix(in oklch, var(--assistant-accent) 55%, transparent),
          0 0 26px color-mix(in oklch, var(--in-transit-accent) 35%, transparent);
      }
    }

    @keyframes assistantIdle {
      0%, 100% {
        transform: translateY(0);
      }
      50% {
        transform: translateY(-1px);
      }
    }

    @keyframes userTyping {
      0%, 100% {
        transform: translateY(0) scale(1);
      }
      50% {
        transform: translateY(-2px) scale(1.06);
      }
    }

    @keyframes userIdle {
      0%, 100% {
        transform: translateY(0);
      }
      50% {
        transform: translateY(-1.5px);
      }
    }

    /* Input Area */
    .input-area {
      padding: 0.85rem 1.1rem calc(1.15rem + env(safe-area-inset-bottom, 0px) + var(--kbd));
      background: transparent;
      position: sticky;
      bottom: 0;
      z-index: 5;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      overflow: hidden;
    }

    html.keyboard-open .input-area {
      position: fixed;
      left: env(safe-area-inset-left, 0px);
      right: env(safe-area-inset-right, 0px);
      bottom: calc(env(safe-area-inset-bottom, 0px) + var(--kbd));
      width: auto;
      max-width: 100vw;
      transform: none;
      box-sizing: border-box;
    }

    .input-container {
      display: flex;
      gap: 0.75rem;
      width: 100%;
      max-width: min(800px, 100%);
      margin: 0 auto;
      padding: 0.5rem;
      border-radius: 1rem;
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: rgba(34, 37, 43, 0.7);
      -webkit-backdrop-filter: blur(16px) saturate(180%);
      backdrop-filter: blur(16px) saturate(180%);
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
      box-sizing: border-box;
      overflow: hidden;
    }

    .input-container:focus-within {
      border-color: color-mix(in oklch, var(--user-accent) 55%, transparent);
      box-shadow:
        0 0 0 1px color-mix(in oklch, var(--user-accent) 25%, transparent),
        0 10px 30px rgba(0, 0, 0, 0.2);
    }

    html[data-theme="light"] .input-container {
      background: rgba(255, 255, 255, 0.9);
      border-color: rgba(15, 23, 42, 0.08);
      box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
    }

    #input {
      flex: 1 1 0;
      min-width: 0;
      max-width: 100%;
      background: transparent;
      border: none;
      border-radius: 0.75rem;
      padding: 0.85rem 1rem;
      color: var(--text-primary);
      font-size: 0.95rem;
      font-family: inherit;
      outline: none;
      transition: border-color 0.2s;
      box-sizing: border-box;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #input:focus {
      box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--user-accent) 65%, transparent);
    }

    #input::placeholder {
      color: var(--text-muted);
    }

    #send {
      background: linear-gradient(135deg, color-mix(in oklch, var(--user-accent) 70%, #3b82f6), color-mix(in oklch, var(--user-accent) 55%, #1d4ed8));
      color: #eef7ff;
      text-shadow: 0 1px 0 rgba(7, 16, 35, 0.5), 0 0 6px rgba(255, 255, 255, 0.35);
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        inset 0 0 0 1px rgba(0, 0, 0, 0.12);
      border: none;
      border-radius: 0.75rem;
      padding: 0.85rem 1.5rem;
      font-size: 0.95rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-shrink: 0;
    }

    #send:hover:not(:disabled) {
      transform: translateY(-2px);
      box-shadow: 0 6px 18px color-mix(in oklch, var(--user-accent) 45%, transparent);
    }

    #send:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    html[data-theme="light"] #send {
      background: linear-gradient(135deg, color-mix(in oklch, var(--user-accent) 65%, #60a5fa), color-mix(in oklch, var(--user-accent) 55%, #2563eb));
      color: #f8fbff;
      text-shadow: 0 1px 0 rgba(7, 16, 35, 0.35), 0 0 6px rgba(255, 255, 255, 0.35);
      box-shadow: 0 6px 16px color-mix(in oklch, var(--user-accent) 30%, transparent);
    }

    #send svg {
      width: 18px;
      height: 18px;
    }

    /* Animations */
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

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

    /* Responsive */
    @media (max-width: 640px) {
      .content {
        max-width: 90%;
        padding: 0.75rem 0.95rem;
        font-size: 0.92rem;
        line-height: 1.5;
      }

      .header-title {
        font-size: 0.95rem;
        min-width: 120px;
      }

      .env-badge {
        max-width: 200px;
        font-size: 0.75rem;
      }

      .env-badge .status-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .header-spacer {
        display: none;
      }

      main {
        padding: 0.55rem 0.5rem 0;
      }

      #messages {
        padding: 0.7rem;
        padding-top: calc(0.7rem + 1.1rem);
        padding-bottom: 0.9rem;
      }

      .message {
        gap: 0.55rem;
      }

      .avatar {
        width: 38px;
        height: 38px;
      }

      .avatar svg {
        width: 19px;
        height: 19px;
      }

      .input-area {
        padding: 0.55rem 0.5rem 0.85rem;
      }

      .input-container {
        max-width: 100%;
        margin: 0;
        gap: 0.45rem;
        padding: 0.35rem;
        border-radius: 0.85rem;
      }

      #input {
        padding: 0.7rem 0.85rem;
        font-size: 0.9rem;
      }

      #send {
        padding: 0.7rem 1rem;
        font-size: 0.88rem;
      }

      .content p {
        margin-bottom: 0.6rem;
      }
    }

    /* ============================================================================
       Privacy Inline Section
       ============================================================================ */

    .privacy-inline {
      margin: 0;
      padding: 0;
      border: none;
      background: transparent;
      width: auto;
      max-width: none;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      margin-left: auto;
      margin-right: auto;
      scroll-margin-top: calc(var(--header-h) + 0.75rem);
    }

    html[data-theme="light"] .privacy-inline {
      background: transparent;
    }

    .privacy-inline-summary {
      width: auto;
      list-style: none;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.55rem;
      padding: 0.55rem 1.05rem;
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid rgba(148, 163, 184, 0.16);
      border-radius: 999px;
      font-size: 0.8rem;
      font-weight: 500;
      color: var(--text-muted);
      cursor: pointer;
      box-shadow: none;
      text-shadow: none;
    }

    html[data-theme="light"] .privacy-inline-summary {
      background: rgba(15, 23, 42, 0.03);
      border-color: rgba(15, 23, 42, 0.1);
      box-shadow: none;
    }

    .privacy-inline-title {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      min-width: 0;
    }

    .privacy-inline-heading {
      font-size: 0.8rem;
      font-weight: 500;
      color: var(--text-muted);
    }

    .privacy-inline-toggle {
      position: relative;
      width: 22px;
      height: 22px;
      border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.3);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: transparent;
      color: var(--text-secondary);
      flex-shrink: 0;
    }

    html[data-theme="light"] .privacy-inline-toggle {
      background: rgba(255, 255, 255, 0.75);
    }

    .privacy-inline-toggle svg {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 14px;
      height: 14px;
      transform: translate(-50%, -50%);
      transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .privacy-inline-toggle .icon-collapse {
      opacity: 0;
      transform: translate(-50%, -50%) rotate(-90deg);
    }

    .privacy-inline-summary[aria-expanded="true"] .icon-expand {
      opacity: 0;
      transform: translate(-50%, -50%) rotate(90deg);
    }

    .privacy-inline-summary[aria-expanded="true"] .icon-collapse {
      opacity: 1;
      transform: translate(-50%, -50%) rotate(0deg);
    }

    .privacy-inline-summary[aria-expanded="true"] {
      border-radius: 999px;
    }

    .privacy-inline-inner {
      width: 100%;
      margin: 0.6rem 0 0;
      background: transparent;
      border: none;
      border-radius: 0;
      padding: 0.6rem 0.85rem 0.35rem 0.5rem;
      box-shadow: none;
      max-height: none;
      overflow: visible;
    }

    html[data-theme="light"] .privacy-inline-inner {
      background: transparent;
      box-shadow: none;
    }

    .privacy-inline.is-open .privacy-inline-inner {
      animation: privacyRise 0.25s ease-out;
      transform-origin: bottom center;
    }

    .privacy-inline-lede {
      margin: 0 0 1rem 0;
      color: var(--text-muted);
      font-size: 0.85rem;
    }

    .privacy-inline-body section {
      margin-bottom: 1.5rem;
    }

    .privacy-inline-body h3 {
      margin: 0 0 0.75rem 0;
      color: var(--text-primary);
      font-size: 0.95rem;
      font-weight: 600;
    }

    .privacy-inline-body p {
      margin: 0 0 0.75rem 0;
      color: var(--text-secondary);
      line-height: 1.55;
      font-size: 0.9rem;
    }

    .privacy-inline-body ul {
      margin: 0 0 0.75rem 1.25rem;
      padding: 0;
    }

    .privacy-inline-body li {
      margin-bottom: 0.5rem;
      color: var(--text-secondary);
      line-height: 1.55;
      font-size: 0.9rem;
    }

    .privacy-inline-body code {
      background: rgba(16, 185, 129, 0.1);
      color: var(--primary);
      padding: 0.125rem 0.375rem;
      border-radius: 3px;
      font-family: 'Courier New', monospace;
      font-size: 0.9em;
    }

    .privacy-inline-body a {
      color: var(--primary);
      text-decoration: none;
      border-bottom: 1px solid transparent;
    }

    .privacy-inline-body a:hover {
      border-bottom-color: var(--primary);
    }

    .privacy-inline-footer-note {
      margin-top: 1.25rem;
      padding-top: 1rem;
      border-top: 1px solid var(--border);
    }

    .privacy-inline-footer-note small {
      color: var(--text-muted);
      line-height: 1.6;
      font-size: 0.75rem;
    }

    @keyframes privacyRise {
      0% {
        opacity: 0;
        transform: translateY(8px);
      }
      100% {
        opacity: 1;
        transform: translateY(0);
      }
    }

    @media (max-width: 640px) {
      main {
        max-width: 100%;
        padding: 0.75rem 0.75rem 0;
      }

      .footer-links {
        flex-basis: 100%;
      }

      .privacy-inline {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
      }

      .privacy-inline-summary {
        gap: 0.5rem;
        padding: 0.5rem 0.85rem;
      }

      .privacy-inline-inner {
        border-radius: 14px;
        width: 100%;
        padding: 0.6rem 0.35rem 0.35rem 0.35rem;
      }

      .privacy-inline-body p,
      .privacy-inline-body li {
        font-size: 0.8rem;
        line-height: 1.4;
      }

      .privacy-inline-body section {
        margin-bottom: 0.85rem;
      }

      .privacy-inline-body ul {
        margin: 0 0 0.5rem 1rem;
      }

      .privacy-inline-body li {
        margin-bottom: 0.35rem;
      }

      .privacy-inline-footer-note {
        margin-top: 0.85rem;
        padding-top: 0.75rem;
      }
    }

    @media (max-width: 640px) and (max-height: 760px) {
      .privacy-inline-lede {
        margin-bottom: 0.6rem;
        font-size: 0.78rem;
      }

      .privacy-inline-body h3 {
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
      }
    }

    @media (max-width: 520px) {
      main {
        max-width: 100%;
      }

      .content {
        max-width: min(94%, 100%);
      }
    }

    @media (max-width: 420px) {
      header {
        padding: 0.75rem 1rem;
      }

      main {
        padding: 0.5rem 0.45rem 0;
      }

      #messages {
        padding: 0.65rem;
        padding-top: calc(0.65rem + 1.1rem);
        padding-bottom: 0.95rem;
        border-radius: 0.9rem;
      }

      .message {
        gap: 0.5rem;
      }

      .avatar {
        width: 36px;
        height: 36px;
      }

      .avatar svg {
        width: 18px;
        height: 18px;
      }

      .input-area {
        padding: 0.5rem 0.45rem 0.85rem;
      }

      .input-container {
        gap: 0.4rem;
        padding: 0.3rem;
        border-radius: 0.8rem;
      }

      #input {
        padding: 0.65rem 0.8rem;
        font-size: 0.88rem;
      }

      #send {
        padding: 0.65rem 0.95rem;
        font-size: 0.86rem;
      }

      .privacy-inline {
        max-width: 100%;
      }

      .container {
        max-width: 100%;
        padding: 0 0.75rem;
      }
    }

    /* ============================================================================
       Scrollbars
       ============================================================================ */

    :root {
      --scrollbar-thumb: rgba(148, 163, 184, 0.5);
      --scrollbar-track: rgba(15, 23, 42, 0.12);
    }

    html[data-theme="light"] {
      --scrollbar-thumb: rgba(15, 23, 42, 0.35);
      --scrollbar-track: rgba(15, 23, 42, 0.08);
    }

    * {
      scrollbar-width: thin;
      scrollbar-color: var(--scrollbar-thumb) transparent;
    }

    *::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    *::-webkit-scrollbar-track {
      background: transparent;
    }

    *::-webkit-scrollbar-thumb {
      background-color: var(--scrollbar-thumb);
      border-radius: 999px;
      border: 2px solid transparent;
      background-clip: content-box;
    }

    #messages::-webkit-scrollbar {
      width: 6px;
    }
