  :root {
    --bg: #0a0906;
    --surface: #12100d;
    --surface2: #1c1915;
    --border: #2a2520;
    --gold: #c9933a;
    --gold-dim: #7a5820;
    --gold-light: #e8b86d;
    --text: #e8e0d4;
    --text-dim: #7a7168;
    --text-mid: #b0a898;
    --red: #c94a3a;
    --green: #4a9a6a;
    --radius: 6px;
  }

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

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: manipulation;
  }

  /* ── Header ── */
  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    position: relative;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .btn-back {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    display: none;
    transition: color 0.15s;
    position: absolute;
    left: 8px;
  }
  .btn-back:hover { color: var(--gold); }
  .btn-back.visible { display: block; }

  .logo-mark {
    width: 32px; height: 32px;
    background: var(--gold);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--bg);
    letter-spacing: -1px;
  }

  .logo-text {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.02em;
  }

  .logo-sub {
    font-size: 11px;
    color: var(--text-dim);
    font-family: 'DM Mono', monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .phase-badge {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--gold);
    background: rgba(201,147,58,0.1);
    border: 1px solid var(--gold-dim);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.05em;
  }

  .btn-reset {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
  }
  .btn-reset:hover { border-color: var(--gold-dim); color: var(--gold); }

  .btn-api-key {
    background: rgba(201,147,58,0.08);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 11px;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    transition: all 0.15s;
  }
  .btn-api-key:hover { background: rgba(201,147,58,0.15); }

  /* ── Main Layout ── */
  main {
    flex: 1;
    display: flex;
    overflow: hidden;
  }

  /* ── Chat Column ── */
  .chat-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }

  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
  }

  .messages::-webkit-scrollbar { width: 4px; }
  .messages::-webkit-scrollbar-track { background: transparent; }
  .messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  /* ── Message Bubbles ── */
  .msg {
    display: flex;
    gap: 12px;
    animation: fadeUp 0.3s ease forwards;
    max-width: 680px;
  }

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

  .msg.user { align-self: flex-end; flex-direction: row-reverse; }

  .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    margin-top: 2px;
  }

  .avatar.yc {
    background: var(--gold);
    color: var(--bg);
  }

  .avatar.human {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-mid);
  }

  .bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.65;
    font-size: 14px;
  }

  .msg.assistant .bubble {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-top-left-radius: 2px;
  }

  .msg.user .bubble {
    background: rgba(201,147,58,0.12);
    border: 1px solid rgba(201,147,58,0.25);
    color: var(--text);
    border-top-right-radius: 2px;
  }

  .bubble strong { color: var(--gold-light); font-weight: 500; }
  .bubble em { color: var(--text-mid); font-style: italic; }

  .bubble p { margin-bottom: 8px; }
  .bubble p:last-child { margin-bottom: 0; }
  .bubble ul, .bubble ol { padding-left: 18px; margin-bottom: 8px; }
  .bubble li { margin-bottom: 4px; }
  .bubble pre { background: var(--bg); padding: 12px; border-radius: 4px; overflow-x: auto; margin: 8px 0; border: 1px solid var(--border); }
  .bubble code { font-family: 'DM Mono', monospace; font-size: 13px; background: rgba(0,0,0,0.2); padding: 2px 4px; border-radius: 3px; }
  .bubble pre code { background: none; padding: 0; }
  .bubble blockquote {
    border-left: 2px solid var(--gold-dim);
    padding-left: 12px;
    color: var(--text-mid);
    font-style: italic;
    margin: 8px 0;
  }
  .bubble hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 10px 0;
  }

  /* Design doc styles */
  .bubble .design-doc {
    background: var(--bg);
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    padding: 16px;
    margin-top: 12px;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text-mid);
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
  }

  .copy-btn {
    margin-top: 8px;
    background: rgba(201,147,58,0.1);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    transition: all 0.15s;
  }
  .copy-btn:hover { background: rgba(201,147,58,0.2); }

  /* Streaming indicator */
  .bubble.streaming::after {
    content: '▌';
    animation: blink 1s step-end infinite;
    color: var(--gold);
    margin-left: 4px;
  }
  @keyframes blink { 50% { opacity: 0; } }

  /* ── Input Bar ── */
  .input-bar {
    padding: 16px 24px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
  }

  textarea {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    padding: 10px 14px;
    resize: none;
    outline: none;
    line-height: 1.5;
    min-height: 44px;
    max-height: 140px;
    transition: border-color 0.15s;
  }

  textarea::placeholder { color: var(--text-dim); }
  textarea:focus { border-color: var(--gold-dim); }

  .send-btn {
    width: 44px; height: 44px;
    background: var(--gold);
    border: none;
    border-radius: var(--radius);
    color: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    font-size: 18px;
  }
  .send-btn:hover { background: var(--gold-light); }
  .send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

  /* ── Sidebar ── */
  .sidebar {
    width: 260px;
    border-left: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
  }

  .sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 12px;
  }

  .progress-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .progress-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-dim);
    transition: color 0.2s;
  }

  .progress-item.active { color: var(--text); }
  .progress-item.done { color: var(--green); }

  .pip {
    width: 8px; height: 8px;
    border-radius: 50%;
    border: 1px solid var(--text-dim);
    flex-shrink: 0;
    transition: all 0.2s;
  }

  .progress-item.active .pip {
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(201,147,58,0.6);
  }

  .progress-item.done .pip {
    background: var(--green);
    border-color: var(--green);
  }

  .principles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    padding: 20px;
  }

  .principle {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.55;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.2s;
  }

  .principle.highlight {
    color: var(--text-mid);
    border-color: var(--border);
    background: var(--surface2);
  }

  .principle .p-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold-dim);
    margin-bottom: 4px;
  }

  .principle.highlight .p-title { color: var(--gold); }

  /* ── Welcome Screen ── */
  .welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    padding: 40px 24px;
    text-align: center;
    gap: 32px;
    overflow-y: auto;
  }

  .welcome-title {
    font-family: 'Playfair Display', serif;
    font-size: 36px;
    font-weight: 400;
    color: var(--text);
    line-height: 1.2;
  }

  .welcome-title span { color: var(--gold); }

  .welcome-sub {
    font-size: 15px;
    color: var(--text-dim);
    max-width: 440px;
    line-height: 1.7;
  }

  .mode-cards {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 560px;
  }

  .mode-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    width: 240px;
  }

  .mode-card:hover {
    border-color: var(--gold-dim);
    background: rgba(201,147,58,0.04);
    transform: translateY(-2px);
  }

  .mode-card-icon {
    font-size: 24px;
    margin-bottom: 10px;
  }

  .mode-card-title {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
  }

  .mode-card-desc {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.6;
  }

  /* ── Idea Input Screen ── */
  .idea-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    gap: 24px;
  }

  .idea-label {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    color: var(--text);
    text-align: center;
  }

  .idea-label span { color: var(--gold); }

  .idea-input {
    width: 100%;
    max-width: 540px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    padding: 16px;
    resize: none;
    outline: none;
    height: 120px;
    line-height: 1.6;
    transition: border-color 0.15s;
  }

  .idea-input::placeholder { color: var(--text-dim); }
  .idea-input:focus { border-color: var(--gold-dim); }

  .start-btn {
    background: var(--gold);
    border: none;
    border-radius: var(--radius);
    color: var(--bg);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 28px;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: all 0.15s;
  }
  .start-btn:hover { background: var(--gold-light); }

  /* ── Error ── */
  .error-msg {
    color: var(--red);
    font-size: 13px;
    font-family: 'DM Mono', monospace;
    padding: 8px 12px;
    background: rgba(201,74,58,0.08);
    border: 1px solid rgba(201,74,58,0.2);
    border-radius: 4px;
    margin: 0 24px 12px;
  }

  /* ── Settings Modal ── */
  .settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    animation: fadeIn 0.2s ease;
  }
  .settings-overlay.open { display: flex; }

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

  .settings-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 28px;
    animation: slideUp 0.25s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }

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

  .settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
  }

  .settings-title {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
  }

  .settings-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 32px; height: 32px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  .settings-close:hover { border-color: var(--gold-dim); color: var(--gold); }

  .btn-settings {
    background: rgba(201,147,58,0.08);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .btn-settings:hover { background: rgba(201,147,58,0.15); }

  /* ── Provider Config Panel (multi-provider settings) ── */
  .settings-panel--wide {
    max-width: 780px;
    padding: 0;
    overflow: hidden;
  }

  .settings-panel--wide .settings-header {
    padding: 20px 24px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
  }

  .provider-config-layout {
    display: flex;
    min-height: 400px;
    max-height: calc(85vh - 80px);
  }

  /* ── Sidebar ── */
  .provider-sidebar {
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    overflow-y: auto;
    background: var(--surface);
  }

  .provider-group {
    margin-bottom: 20px;
  }

  .provider-group:last-child {
    margin-bottom: 0;
  }

  .provider-group-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 8px;
    padding: 0 8px;
  }

  .provider-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
  }

  .provider-item:hover {
    background: var(--surface2);
  }

  .provider-item.selected {
    background: var(--surface2);
  }

  .provider-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .provider-dot.online {
    background: var(--green);
  }

  .provider-dot.offline {
    background: var(--text-dim);
    opacity: 0.4;
  }

  .provider-name {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .provider-item.selected .provider-name {
    font-weight: 500;
  }

  /* ── Form Panel ── */
  .provider-form {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: var(--surface);
  }

  .pf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
  }

  .pf-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .pf-provider-name {
    font-family: 'DM Sans', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
  }

  .pf-delete-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }

  .pf-delete-btn:hover {
    border-color: var(--red);
    color: var(--red);
  }

  /* ── Segmented Control ── */
  .segmented-control {
    display: inline-flex;
    background: var(--surface2);
    border-radius: 6px;
    padding: 2px;
    gap: 0;
  }

  .seg-option {
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
  }

  .seg-option.seg-active {
    background: var(--green);
    color: #fff;
  }

  .seg-option:not(.seg-active):hover {
    color: var(--text);
  }

  /* ── Form Fields ── */
  .pf-fields {
    margin-bottom: 24px;
  }

  .pf-field {
    margin-bottom: 16px;
  }

  .pf-field:last-child {
    margin-bottom: 0;
  }

  .pf-label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
  }

  .pf-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
  }

  .pf-input:focus {
    border-color: var(--gold-dim);
  }

  .pf-input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
  }

  .pf-select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    padding: 10px 12px;
    outline: none;
    cursor: pointer;
    appearance: auto;
    box-sizing: border-box;
  }

  .pf-select:focus {
    border-color: var(--gold-dim);
  }

  .pf-password-wrap {
    position: relative;
  }

  .pf-password-input {
    padding-right: 38px;
  }

  .pf-eye-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    line-height: 1;
    color: var(--text-dim);
    transition: color 0.15s;
  }

  .pf-eye-btn:hover {
    color: var(--text);
  }

  /* ── Model List ── */
  .pf-models-section {
    border-top: 1px solid var(--border);
    padding-top: 20px;
  }

  .pf-models-label {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 12px;
  }

  .pf-model-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .pf-model-item {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    gap: 12px;
  }

  .pf-model-name {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .pf-model-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .pf-context-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-dim);
    background: var(--surface2);
    border-radius: 12px;
    padding: 2px 10px;
    white-space: nowrap;
  }

  .pf-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    color: var(--text-dim);
    transition: color 0.15s;
    line-height: 1;
    border-radius: 4px;
  }

  .pf-action-btn:hover {
    color: var(--text);
  }

  .pf-action-danger:hover {
    color: var(--red);
  }

  .pf-add-model-btn {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface2);
    border: none;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.15s;
  }

  .pf-add-model-btn:hover {
    background: var(--border);
    color: var(--text);
  }

  /* ── Mobile responsive ── */
  @media (max-width: 768px) {
    .settings-panel--wide {
      max-width: 100%;
    }

    .provider-config-layout {
      flex-direction: column;
      max-height: none;
    }

    .provider-sidebar {
      width: 100%;
      border-right: none;
      border-bottom: 1px solid var(--border);
      padding: 12px;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      overflow-x: auto;
    }

    .provider-group {
      margin-bottom: 0;
    }

    .provider-group-label {
      display: none;
    }

    .provider-item {
      padding: 6px 10px;
      margin-bottom: 0;
      white-space: nowrap;
    }

    .provider-form {
      padding: 16px;
    }

    .pf-header {
      flex-wrap: wrap;
      gap: 12px;
    }

    .pf-header-left {
      flex-wrap: wrap;
      gap: 10px;
    }

    .pf-provider-name {
      font-size: 17px;
    }

    .pf-model-item {
      flex-wrap: wrap;
      gap: 8px;
    }

    .pf-model-actions {
      margin-left: 0;
    }
  }

  /* ── Mobile Drawer (sidebar) ── */
  .drawer-fab {
    display: none;
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 44px; height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--gold);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: all 0.2s;
  }
  .drawer-fab:hover { border-color: var(--gold-dim); }

  .drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 60;
    animation: fadeIn 0.2s ease;
  }
  .drawer-overlay.open { display: block; }

  .drawer-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    max-height: 55vh;
    overflow-y: auto;
    z-index: 61;
    padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: sheetUp 0.25s ease;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
  }
  .drawer-sheet.open { display: block; }

  .drawer-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
  }

  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* Responsive: hide sidebar on small screens */
  @media (max-width: 768px) {
    .sidebar { display: none !important; }
    .drawer-fab.visible { display: flex; align-items: center; justify-content: center; }

    /* Session Mode Mobile UI */
    body.in-session .header-right { display: none; }
    body.in-session header { justify-content: center; }

    /* Header */
    header { padding: 10px 16px; }
    .logo-sub { display: none; }
    .phase-badge { font-size: 10px; padding: 2px 8px; }
    .btn-reset, .btn-settings { font-size: 11px; padding: 4px 8px; }

    /* Welcome screen */
    .welcome { padding: 24px 16px; gap: 20px; }
    .welcome-title { font-size: 28px; }
    .welcome-sub { font-size: 14px; }
    .mode-cards { flex-direction: column; align-items: center; max-width: 100%; }
    .mode-card { width: 100%; max-width: 360px; padding: 16px 18px; }

    /* Idea input screen */
    .idea-screen { padding: 24px 16px; gap: 16px; }
    .idea-label { font-size: 20px; }
    .idea-input { max-width: 100%; height: 100px; padding: 14px; }

    /* Chat */
    .messages { padding: 16px; gap: 14px; }
    .msg { gap: 8px; max-width: 100%; }
    .bubble { padding: 10px 14px; font-size: 14px; }
    .avatar { width: 28px; height: 28px; font-size: 11px; }

    /* Input bar */
    .input-bar { padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
    textarea { font-size: 16px; } /* Prevent iOS zoom on focus */

    /* Settings modal — bottom sheet style */
    .settings-overlay { align-items: flex-end; padding: 0; }
    .settings-panel {
      border-radius: 16px 16px 0 0;
      max-width: 100%;
      max-height: 85vh;
      padding: 20px;
      padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
  }

  /* ── History Modal ── */
  .history-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: all 0.2s; position: relative; text-align: left; }
  .history-item:hover { border-color: var(--gold-dim); background: rgba(201,147,58,0.04); }
  .history-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
  .history-item-date { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text-dim); }
  .history-item-mode { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--gold); border: 1px solid var(--gold-dim); padding: 2px 6px; border-radius: 12px; background: rgba(201,147,58,0.1); }
  .history-item-idea { font-size: 13px; color: var(--text); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 30px; }
  .btn-delete-hist { position: absolute; bottom: 12px; right: 12px; background: none; border: none; color: var(--red); font-size: 16px; cursor: pointer; opacity: 0.6; padding: 4px; }
  .btn-delete-hist:hover { opacity: 1; }
  .empty-history { text-align: center; color: var(--text-dim); font-size: 13px; padding: 20px 0; }
