:root {
  --bg:        #0e0e0d;
  --surface:   #161614;
  --surface2:  #1e1e1b;
  --border:    #2a2a26;
  --border2:   #383834;
  --text:      #e8e4d8;
  --muted:     #6b6860;
  --faint:     #3a3a36;
  --green:     #a8cc5a;
  --green-dim: #2a3318;
  --red:       #cc5a5a;
  --ff-body:   'Syne', sans-serif;
  --ff-disp:   'Playfair Display', serif;
  --sidebar-w: 260px;
}
*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}
html, body { 
    height: 100%; 
    overflow: hidden; 
}
body { 
    font-family: var(--ff-body); 
    background: var(--bg); 
    color: var(--text); 
    display: flex; 
    font-size: 14px; 
    line-height: 1.6; 
    -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
}
button { 
    font-family: var(--ff-body); 
    cursor: pointer; 
}
textarea { font-family: var(--ff-body); }

#loading-screen {
  position: fixed; 
  inset: 0; 
  background: var(--bg); 
  z-index: 9999;
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  gap: 20px;
}
.splash-logo { 
    font-family: var(--ff-disp); 
    font-size: 36px; 
    font-weight: 700; 
    color: var(--text);
}
.splash-logo span { 
    color: var(--green); 
}
.splash-dots { 
    display: flex; 
    gap: 6px; 
    margin-top: 10px;
}
.splash-dot { 
    width: 7px; 
    height: 7px; 
    border-radius: 50%; 
    background: var(--green); 
    opacity: 0.3; 
    animation: pulse 1.3s infinite ease-in-out; 
}
.splash-dot:nth-child(2) { 
    animation-delay: 0.2s; 
}
.splash-dot:nth-child(3) { 
    animation-delay: 0.4s; 
}

#auth-screen {
  position: fixed; 
  inset: 0; 
  background: var(--bg); 
  z-index: 9000;
  display: none; 
  align-items: center; 
  justify-content: center; 
  padding: 20px;
}
#auth-screen.visible { 
    display: flex; 
}
.auth-card {
  width: 100%; 
  max-width: 400px;
  background: var(--surface); 
  border: 1px solid var(--border);
  border-radius: 20px; 
  padding: 40px 36px 36px;
  animation: rise 0.3s cubic-bezier(0.22,1,0.36,1) both;
}
.auth-logo { 
    font-family: var(--ff-disp); 
    font-size: 28px; 
    font-weight: 700; 
    color: var(--text); 
    letter-spacing: -0.5px; 
    margin-bottom: 4px; 
}
.auth-logo span { color: var(--green); }
.auth-tagline { 
    font-size: 11px; 
    font-weight: 500; 
    color: var(--muted); 
    text-transform: uppercase; 
    letter-spacing: 1.8px; 
    margin-bottom: 32px; 
}
.auth-tabs { 
    display: flex; 
    background: var(--surface2); 
    border-radius: 10px; 
    padding: 3px; 
    gap: 3px; 
    margin-bottom: 28px; 
}
.auth-tab {
  flex: 1; 
  padding: 8px; 
  border: none; 
  background: none; 
  color: var(--muted);
  border-radius: 8px; 
  font-family: var(--ff-body); 
  font-size: 13px; 
  font-weight: 600; 
  cursor: pointer; 
  transition: all 0.18s;
}
.auth-tab.active { 
    background: var(--surface); 
    color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.auth-field input {
  width: 100%; 
  background: var(--surface2); 
  border: 1.5px solid var(--border2);
  border-radius: 10px; 
  padding: 11px 14px; 
  color: var(--text);
  font-family: var(--ff-body); 
  font-size: 14px; 
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.auth-field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(168,204,90,0.07); }
.auth-field input::placeholder { color: var(--faint); }
.auth-submit {
  width: 100%; 
  background: var(--green); 
  color: #0e0e0d; 
  border: none;
  border-radius: 10px; 
  padding: 12px; 
  font-family: var(--ff-body);
  font-size: 14px; 
  font-weight: 700; 
  margin-top: 8px;
  cursor: pointer; 
  transition: filter 0.15s, transform 0.12s; position: relative;
}
.auth-submit:hover { filter: brightness(1.08); }
.auth-submit:active { transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.auth-spinner {
  display: none; 
  width: 16px; 
  height: 16px; 
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #0e0e0d; 
  border-radius: 50%;
  animation: spin 0.7s linear infinite; 
  margin: 0 auto;
}
.auth-submit.loading .auth-btn-text { display: none; }
.auth-submit.loading .auth-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-error {
  background: rgba(204,90,90,0.1); border: 1px solid rgba(204,90,90,0.3);
  color: #f0a0a0; border-radius: 8px; padding: 9px 13px;
  font-size: 12.5px; margin-top: 12px; display: none; line-height: 1.5;
}
.auth-error.show { display: block; }
.auth-divider { text-align: center; margin: 16px 0 4px; }
.auth-divider span { font-size: 11.5px; color: var(--faint); }
.auth-note { font-size: 11.5px; color: var(--faint); text-align: center; line-height: 1.5; margin-top: 14px; }
.forgot-link { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: -8px; margin-bottom: 14px; cursor: pointer; text-decoration: underline; transition: color 0.15s; }
.forgot-link:hover { color: var(--green); }

.user-pill {
  display: none; align-items: center; gap: 7px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 100px; padding: 5px 12px 5px 8px;
  max-width: 160px;
}
.user-pill.show { display: flex; }
.user-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green-dim); border: 1px solid rgba(168,204,90,0.3);
  color: var(--green); font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-email-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--muted); }
.btn-signout {
  display: none; 
  background: none; 
  border: 1px solid var(--border2); 
  color: var(--muted);
  border-radius: 6px; 
  padding: 3px 8px; 
  font-size: 11px; 
  font-weight: 500; 
  transition: all 0.15s;
}
.btn-signout.show { display: inline-block; }
.btn-signout:hover { 
  border-color: var(--red); 
  color: var(--red); 
}

.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; transition: transform 0.25s ease, width 0.25s ease, border-color 0.25s ease; z-index: 100; }
.sidebar.collapsed { width: 0; border-right-color: transparent; }
.sidebar-top { padding: 28px 22px 20px; border-bottom: 1px solid var(--border); }
.logo { 
  font-family: var(--ff-disp); 
  font-size: 26px; 
  font-weight: 700; 
  color: var(--text); 
  letter-spacing: -0.5px; 
  line-height: 1; 
  margin-bottom: 4px; 
}
.logo span { color: var(--green); }
.tagline { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 1.8px; }
.sidebar-nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--border); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; background: none; border: none;
  color: var(--muted); border-radius: 8px; padding: 9px 12px;
  font-size: 12.5px; font-weight: 600; font-family: var(--ff-body);
  text-align: left; cursor: pointer; transition: all 0.15s;
}
.nav-item svg { flex-shrink: 0; color: var(--muted); transition: color 0.15s; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item:hover svg { color: var(--green); }
#new-chat.nav-item { color: var(--green); font-weight: 700; }
#new-chat.nav-item svg { color: var(--green); }
.history-label { padding: 14px 22px 8px; font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--faint); text-transform: uppercase; }
.history-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.history-item { 
  padding: 9px 14px; 
  border-radius: 8px; 
  cursor: pointer; 
  font-size: 12.5px; 
  color: var(--muted); 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  transition: all 0.14s; 
  margin-bottom: 2px; 
  border: 1px solid transparent; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 6px; 
}
.history-item:hover { 
  background: var(--surface2); 
  color: var(--text); 
}
.history-item.active { 
  background: var(--green-dim); 
  color: var(--green); 
  border-color: rgba(168,204,90,0.18); 
}
.history-item-title { 
  flex: 1; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap; 
}
.history-delete { 
  opacity: 0; 
  background: none; 
  border: none; 
  color: var(--muted); 
  font-size: 14px; 
  line-height: 1; 
  padding: 2px 4px; 
  border-radius: 4px; 
  flex-shrink: 0; 
  transition: all 0.15s; 
}
.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover { color: var(--red); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar { height: 56px; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 10px; background: var(--surface); flex-shrink: 0; }
.menu-btn { display: flex; background: none; border: 1px solid var(--border2); color: var(--muted); border-radius: 8px; width: 34px; height: 34px; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; }
.menu-btn:hover { border-color: var(--green); color: var(--green); }
.chat-title { flex: 1; font-family: var(--ff-disp); font-style: italic; font-size: 17px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.tb-btn { background: none; border: 1px solid var(--border2); color: var(--muted); border-radius: 8px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.tb-btn:hover { border-color: var(--green); color: var(--green); }
.messages { flex: 1; overflow-y: auto; padding: 32px 0 16px; scroll-behavior: smooth; }
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.msg-wrap { max-width: 720px; margin: 0 auto 24px; padding: 0 20px; animation: rise 0.22s cubic-bezier(0.22,1,0.36,1) both; }
@keyframes rise { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.msg-wrap.user { display: flex; justify-content: flex-end; }
.bubble-user { background: var(--surface2); border: 1px solid var(--border2); color: var(--text); border-radius: 18px 18px 4px 18px; padding: 12px 18px; max-width: 72%; font-size: 14.5px; line-height: 1.65; }
.msg-wrap.ai { display: block; }
.ai-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ai-badge { background: var(--green-dim); border: 1px solid rgba(168,204,90,0.22); color: var(--green); font-size: 9.5px; font-weight: 700; letter-spacing: 1.8px; padding: 3px 9px; border-radius: 100px; text-transform: uppercase; flex-shrink: 0; }
.ai-line { flex: 1; height: 1px; background: var(--border); }
.bubble-ai { font-size: 14.5px; line-height: 1.78; color: var(--text); }
.bubble-ai p { margin-bottom: 12px; } .bubble-ai p:last-child { margin-bottom: 0; }
.bubble-ai strong { color: #fff; font-weight: 600; }
.bubble-ai em { color: var(--green); font-style: italic; }
.bubble-ai h1,.bubble-ai h2,.bubble-ai h3 { font-family: var(--ff-disp); font-weight: 700; margin: 18px 0 8px; color: #fff; line-height: 1.25; }
.bubble-ai h1 { font-size: 21px; } .bubble-ai h2 { font-size: 17px; } .bubble-ai h3 { font-size: 14.5px; }
.bubble-ai ul,.bubble-ai ol { padding-left: 22px; margin-bottom: 12px; }
.bubble-ai li { margin-bottom: 6px; }
.bubble-ai li::marker { color: var(--green); }
.bubble-ai code { background: var(--surface2); border: 1px solid var(--border2); color: var(--green); padding: 2px 7px; border-radius: 4px; font-size: 13px; font-family: 'Courier New', monospace; }
.bubble-ai pre { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin: 10px 0; }
.bubble-ai blockquote { border-left: 3px solid var(--green); padding-left: 16px; color: var(--muted); margin: 12px 0; font-style: italic; }
.bubble-ai hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.typing-wrap { max-width: 720px; margin: 0 auto 24px; padding: 0 20px; }
.typing-inner { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.t-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); opacity: 0.3; animation: pulse 1.3s infinite ease-in-out; }
.t-dot:nth-child(2) { animation-delay: 0.2s; }
.t-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%,100% { opacity:0.2; transform:scale(0.85); } 50% { opacity:1; transform:scale(1.15); } }
.messages:has(.intro-wrap) { display: flex; align-items: center; justify-content: center; }
.intro-wrap { max-width: 620px; margin: 0 auto; padding: 0 20px; text-align: center; animation: rise 0.3s cubic-bezier(0.22,1,0.36,1) both; }
.intro-heading { font-family: var(--ff-body); font-size: clamp(22px,4vw,30px); font-weight: 700; line-height: 1.25; color: #fff; margin-bottom: 10px; letter-spacing: 0.4px; }
.intro-sub { font-size: 13.5px; color: var(--muted); line-height: 1.6; max-width: 420px; margin: 0 auto 24px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { background: var(--surface2); border: 1px solid var(--border2); color: var(--muted); border-radius: 100px; padding: 8px 16px; font-size: 12.5px; font-weight: 500; transition: all 0.15s; }
.chip:hover { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.input-bar { background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.pending-strip { display: none; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid rgba(168,204,90,0.15); background: var(--green-dim); }
.pending-strip.show { display: flex; }
.pending-icon { width: 30px; height: 30px; border-radius: 6px; background: rgba(168,204,90,0.12); border: 1px solid rgba(168,204,90,0.22); display: flex; align-items: center; justify-content: center; color: var(--green); flex-shrink: 0; }
.pending-info { flex: 1; min-width: 0; }
.pending-name { font-size: 12.5px; font-weight: 600; color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending-meta { font-size: 11px; color: rgba(168,204,90,0.45); margin-top: 1px; }
.pending-remove { background: none; border: none; color: rgba(168,204,90,0.45); font-size: 18px; line-height: 1; padding: 4px 6px; cursor: pointer; border-radius: 4px; transition: color 0.15s; flex-shrink: 0; }
.pending-remove:hover { color: var(--green); }
.input-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.textarea-box { display: flex; align-items: flex-end; background: var(--surface2); border: 1.5px solid var(--border2); border-radius: 16px; padding: 10px 10px 10px 16px; transition: border-color 0.18s, box-shadow 0.18s; }
.textarea-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(168,204,90,0.07); }
textarea { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: var(--ff-body); font-size: 14.5px; line-height: 1.6; resize: none; min-height: 24px; max-height: 140px; padding: 2px 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
textarea::placeholder { color: var(--faint); }
.box-actions { display: flex; align-items: flex-end; gap: 6px; padding-left: 8px; flex-shrink: 0; }
.box-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border2); background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.box-btn:hover { border-color: rgba(168,204,90,0.4); color: var(--green); background: var(--green-dim); }
.send-btn { width: 32px; height: 32px; border-radius: 999px; border: none; background: var(--border2); color: var(--faint); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: filter 0.15s, transform 0.12s, background 0.15s; flex-shrink: 0; }
.send-btn:hover { background: var(--green-dim); color: var(--green); }
.send-btn:active { transform: scale(0.93); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.input-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; gap: 8px; }
.toolbar-left { display: flex; align-items: center; gap: 2px; }
.tool-btn { background: none; border: none; color: var(--muted); border-radius: 6px; padding: 5px 8px; font-size: 11.5px; font-family: var(--ff-body); font-weight: 500; display: flex; align-items: center; gap: 5px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.tool-btn:hover { color: var(--green); background: var(--green-dim); }
.tb-div { width: 1px; height: 14px; background: var(--border2); margin: 0 2px; flex-shrink: 0; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stop-pill { display: none; background: none; border: 1px solid var(--border2); color: var(--muted); border-radius: 100px; padding: 4px 14px; font-size: 12px; font-family: var(--ff-body); font-weight: 500; cursor: pointer; transition: all 0.15s; }
.stop-pill:hover { border-color: var(--red); color: var(--red); }
.retry-pill { display: none; background: none; border: 1px solid var(--border2); color: var(--muted); border-radius: 100px; padding: 4px 14px; font-size: 12px; font-family: var(--ff-body); font-weight: 500; cursor: pointer; transition: all 0.15s; }
.retry-pill:hover { border-color: var(--text); color: var(--text); }
.hint-text { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; justify-content: flex-end;
  align-items: flex-end; gap: 10px; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast-card {
  position: relative; pointer-events: auto; overflow: hidden;
  width: 320px; max-width: 100%;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 14px; padding: 13px 30px 15px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
  transform: translateX(120%); opacity: 0;
  transition: transform 0.32s cubic-bezier(0.22,1,0.36,1), opacity 0.32s cubic-bezier(0.22,1,0.36,1);
}
.toast-card.show { transform: translateX(0); opacity: 1; }
.toast-card.hide { transform: translateX(120%); opacity: 0; }
.toast-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  margin-top: 5px; background: var(--muted);
}
.toast-card.toast-success .toast-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(168,204,90,0.18); }
.toast-card.toast-error .toast-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(204,90,90,0.18); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.toast-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.toast-close {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  border: 0; background: none; color: var(--faint); font-size: 15px; line-height: 1;
  border-radius: 6px; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.toast-close:hover { color: var(--text); background: var(--border2); }
.toast-timer {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--border); overflow: hidden;
}
.toast-timer-bar { height: 100%; width: 100%; background: var(--muted); }
.toast-card.toast-success .toast-timer-bar { background: var(--green); }
.toast-card.toast-error .toast-timer-bar { background: var(--red); }

@media (max-width: 520px) {
  .toast-stack { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
  .toast-card { width: 100%; }
}

.toast-confirm { padding: 14px 16px; }
.toast-confirm .toast-dot { background: var(--muted); }
.toast-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.toast-btn {
  border: 1px solid var(--border2); background: none; color: var(--muted);
  border-radius: 8px; padding: 6px 14px; font-size: 12px; font-weight: 600;
  font-family: var(--ff-body); cursor: pointer; transition: all 0.15s;
}
.toast-btn-cancel:hover { border-color: var(--border2); color: var(--text); background: var(--surface); }
.toast-btn-ok { border-color: var(--red); color: var(--red); }
.toast-btn-ok:hover { background: var(--red); color: #fff; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 90; }
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }

@media (max-width: 768px) {
  html, body { height: 100dvh; }
  .sidebar { position: fixed; top:0; left:0; bottom:0; width: min(var(--sidebar-w), 82vw); transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  .overlay.show { display: block; }
  .menu-btn { display: flex; }
}
@media (max-width: 520px) {
  .tool-label { display: none; } .tb-div { display: none; } .hint-text { display: none; }
  .input-inner { padding: 10px 12px 8px; } .textarea-box { border-radius: 14px; padding: 8px 8px 8px 14px; }
  .msg-wrap { padding: 0 14px; } .intro-wrap { padding: 0 16px; } .bubble-user { max-width: 85%; }
  .topbar { padding: 0 14px; } .chips-row { gap: 6px; } .chip { font-size: 12px; padding: 7px 13px; }
  .drop-zone { padding: 28px 16px; } .auth-card { padding: 32px 24px 28px; }
  .pi-frame { padding: 10px 10px 8px; border-radius: 18px; }
  .pi-right { gap: 4px; }
  .pi-pill-btn { padding: 0 10px; font-size: 11.5px; }
  .account-menu { left: 8px; right: 8px; }
  .ai-badge { font-size: 9px; padding: 2px 7px; }
}
.search-box {
  display: none; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.search-box.show { display: block; }
.search-input {
  width: 100%; background: var(--surface2); border: 1.5px solid var(--border2);
  border-radius: 8px; padding: 8px 12px; color: var(--text);
  font-family: var(--ff-body); font-size: 13px; outline: none; transition: border-color 0.18s;
}
.search-input:focus { border-color: var(--green); }
.search-input::placeholder { color: var(--faint); }

.history-item-time {
  font-size: 10px; color: var(--faint); margin-top: 2px; white-space: nowrap;
}
.history-item-inner { flex: 1; overflow: hidden; }

.network-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 100px; padding: 4px 10px; font-size: 11px;
  font-weight: 600; color: var(--muted); transition: all 0.3s;
}
.network-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); transition: background 0.3s;
}
.network-pill.offline { border-color: rgba(204,90,90,0.3); color: var(--red); }
.network-pill.offline .network-dot { background: var(--red); }

.response-timer {
  font-size: 10.5px; color: var(--faint); margin-top: 6px;
  display: flex; align-items: center; gap: 4px;
}

.mic-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border2);
  background: none; color: var(--muted); display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.mic-btn:hover { border-color: rgba(168,204,90,0.4); color: var(--green); background: var(--green-dim); }
.mic-btn.recording { background: rgba(204,90,90,0.15); border-color: var(--red); color: var(--red); animation: micpulse 1s infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(204,90,90,0.4); } 50% { box-shadow: 0 0 0 6px rgba(204,90,90,0); } }

.pin-btn {
  opacity: 0; background: none; border: none; color: var(--muted);
  font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 4px;
  flex-shrink: 0; transition: all 0.15s; cursor: pointer;
}
.history-item:hover .pin-btn { opacity: 1; }
.pin-btn.pinned { opacity: 1; color: var(--green); }
.pin-btn:hover { color: var(--green); }
.pinned-label {
  padding: 14px 22px 8px; font-size: 10px; font-weight: 700;
  letter-spacing: 2px; color: var(--faint); text-transform: uppercase;
}
.pin-divider { height: 1px; background: var(--border); margin: 4px 8px 8px; }


/* ===== Enhanced Input (PromptInput-style) ===== */
.pi-wrap { width: 100%; }
.pi-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: 22px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.pi-frame:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(168,204,90,0.07); }

@property --pi-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.pi-frame[data-enhancing] { border-color: transparent; }
.pi-frame[data-enhancing]::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: 17px;
  border: 1.5px solid transparent;
  background: conic-gradient(from var(--pi-angle), #a8cc5a, #5aa8cc, #cc5aa8, #cccc5a, #a8cc5a) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: pi-border-spin 1.1s linear infinite, pi-border-in 220ms ease both;
  pointer-events: none;
}
@keyframes pi-border-spin { to { --pi-angle: 360deg; } }
@keyframes pi-border-in { from { opacity: 0; } to { opacity: 1; } }

.pi-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pi-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border2);
  color: var(--text); font-size: 11.5px; animation: pi-chip-in 200ms ease both;
}
@keyframes pi-chip-in { from { opacity:0; transform: translateY(4px); } to { opacity:1; transform:translateY(0);} }
.pi-chip-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.pi-chip-remove:hover { background: var(--border2); color: var(--text); }

.pi-editor-wrap { position: relative; }
.pi-field {
  width: 100%; min-height: 24px; max-height: 140px; overflow-y: auto;
  outline: 0; background: transparent; color: var(--text);
  font-family: var(--ff-body); font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; padding: 2px 0;
}
.pi-field[data-empty]::before {
  content: attr(data-placeholder); color: var(--faint); pointer-events: none;
}

.pi-skill-pill {
  display: inline-flex; align-items: center; gap: 2px; height: 20px;
  padding: 0 2px 0 8px; margin: 0 3px; border-radius: 999px;
  background: var(--green-dim); color: var(--green); font-size: 11.5px;
  font-weight: 600; white-space: nowrap; vertical-align: middle;
}
.pi-skill-pill-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border: 0; border-radius: 999px;
  background: transparent; color: inherit; opacity: 0.7; cursor: pointer;
}
.pi-skill-pill-x:hover { opacity: 1; background: rgba(168,204,90,0.18); }

.pi-row { display: flex; align-items: center; justify-content: space-between; }
.pi-plus-wrap, .pi-slash-wrap { position: relative; }
.pi-right { display: flex; align-items: center; gap: 6px; }

.pi-icon-btn {
  width: 30px; height: 30px; border-radius: 999px; border: none;
  background: none; color: var(--muted); display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.pi-icon-btn:hover { color: var(--green); background: var(--green-dim); }
.pi-icon-btn[data-open] { color: var(--green); background: var(--green-dim); }
.pi-plus-icon { transition: transform 200ms cubic-bezier(0.35,1.55,0.65,1); display: inline-flex; }
.pi-icon-btn[data-open] .pi-plus-icon { transform: rotate(45deg); }

.pi-pill-btn {
  height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border2);
  background: none; color: var(--muted); font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.pi-pill-btn:hover { border-color: rgba(168,204,90,0.4); color: var(--green); background: var(--green-dim); }
.pi-pill-btn.pi-pill-active { border-color: var(--green); color: var(--green); background: var(--green-dim); }

.pi-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 25;
  width: 200px; padding: 4px; background: var(--surface); border: 1px solid var(--border2);
  border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: pi-menu-in 180ms ease both;
}
@keyframes pi-menu-in { from { opacity:0; transform: translateY(6px) scale(0.98); } to { opacity:1; transform: translateY(0) scale(1); } }
.pi-menu-label { padding: 6px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 1px; color: var(--faint); text-transform: uppercase; }
.pi-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px;
  padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); font-size: 12.5px; font-weight: 500; text-align: left; cursor: pointer;
}
.pi-menu-item:hover, .pi-menu-item.pi-menu-active { background: var(--surface2); }
.pi-menu-empty { padding: 8px 10px; font-size: 12px; color: var(--faint); }

.pi-enhancing-text {
  font-size: 14.5px; line-height: 1.6; color: transparent;
  background: linear-gradient(90deg, var(--text) 0%, var(--text) 30%, rgba(232,228,216,0.35) 45%, rgba(232,228,216,0.35) 55%, var(--text) 70%, var(--text) 100%);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text;
  animation: pi-shine 2s ease infinite;
}
@keyframes pi-shine { 0%,15% { background-position: 100% 0; } 85%,100% { background-position: 0% 0; } }
.pi-menu-divider { height: 1px; background: var(--border2); margin: 4px 2px; }

.tr {
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto 20px;
  padding: 0 20px;
  font-family: var(--ff-body);
  animation: tr-block-in 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes tr-block-in { from { opacity: 0; } to { opacity: 1; } }
.trHeader {
  display: inline-flex; align-items: center; gap: 6px;
  align-self: flex-start; min-height: 20px; padding: 0; border: 0;
  background: transparent; cursor: default;
}
.trHeader.isClickable { cursor: pointer; }
.trLabel { font-size: 12.5px; line-height: 18px; font-weight: 600; color: var(--muted); letter-spacing: -0.01em; }
.trChevron { color: var(--faint); transition: transform 280ms cubic-bezier(0.22,1,0.36,1); transform: rotate(180deg); }
.trHeader[aria-expanded="true"] .trChevron { transform: rotate(0deg); }
.trHeader.isClickable:hover .trChevron { color: var(--green); }
.trCollapsible { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows 320ms cubic-bezier(0.22,1,0.36,1), opacity 220ms ease; }
.trCollapsible.isCollapsed { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.trInner { min-height: 0; overflow: hidden; }
.trViewport { margin-top: 6px; overflow: hidden; }
.trStream { display: flex; flex-direction: column; gap: 4px; }
.trSentence {
  margin: 0; line-height: 20px; font-size: 12.5px; font-weight: 425;
  color: var(--muted); letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  animation: tr-sentence-in 420ms cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes tr-sentence-in { from { opacity: 0; } to { opacity: 1; } }
.trShimmer {
  color: transparent; -webkit-text-fill-color: transparent;
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 30%, rgba(107,104,96,0.35) 45%, rgba(107,104,96,0.35) 55%, var(--muted) 70%, var(--muted) 100%);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text;
  animation: tr-shine 2.25s cubic-bezier(0.25,0.1,0.25,1) infinite;
}
@keyframes tr-shine { 0%,18% { background-position: 100% 0; } 82%,100% { background-position: 0% 0; } }

.sidebar-bottom {
  margin-top: auto;
  padding: 10px 10px 14px;
  border-top: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.account-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 1px solid transparent; border-radius: 10px;
  padding: 8px 10px; cursor: pointer; transition: all 0.15s; text-align: left;
}
.account-btn:hover { background: var(--surface2); }
.account-btn[data-open] { background: var(--surface2); border-color: var(--border2); }
.account-avatar-lg {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--green-dim); border: 1px solid rgba(168,204,90,0.3);
  color: var(--green); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-sub  { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-chevron { color: var(--muted); transition: transform 0.2s; flex-shrink: 0; }
.account-btn[data-open] .account-chevron { transform: rotate(180deg); }

.account-menu {
  position: absolute; bottom: calc(100% + 8px); left: 10px; right: 10px;
  background: var(--surface); border: 1px solid var(--border2); border-radius: 12px;
  padding: 6px; box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  display: none; z-index: 50; animation: pi-menu-in 180ms ease both;
}
.account-menu.show { display: block; }
.account-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; background: none; border-radius: 8px;
  color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer;
  text-align: left; font-family: var(--ff-body); transition: background 0.12s;
}
.account-menu-item svg { color: var(--muted); flex-shrink: 0; transition: color 0.12s; }
.account-menu-item:hover { background: var(--surface2); }
.account-menu-item:hover svg { color: var(--green); }
.account-menu-item.danger:hover { color: var(--red); background: rgba(204,90,90,0.08); }
.account-menu-item.danger:hover svg { color: var(--red); }
.account-menu-divider { height: 1px; background: var(--border2); margin: 4px 2px; }

/* ===== Onboarding (step wizard) ===== */
#onboarding-screen {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9200;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
#onboarding-screen.visible { display: flex; }

.onboard-card {
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 30px 28px 26px;
  animation: rise 0.3s cubic-bezier(0.22,1,0.36,1) both;
}
.onboard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.onboard-step-label { font-size: 11.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.onboard-title { font-family: var(--ff-disp); font-size: 22px; font-weight: 700; color: var(--text); margin: 20px 0 6px; }
.onboard-sub { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin-bottom: 16px; }
.onboard-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; }
.onboard-nav-btn {
  border: none; border-radius: 10px; padding: 10px 20px;
  font-family: var(--ff-body); font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--green); color: #0e0e0d; transition: filter 0.15s;
}
.onboard-nav-btn:hover { filter: brightness(1.08); }
.onboard-nav-btn.ghost { background: none; border: 1px solid var(--border2); color: var(--muted); }
.onboard-nav-btn.ghost:hover { border-color: var(--text); color: var(--text); }
.onboard-nav-btn:disabled { opacity: 0; pointer-events: none; }

@media (max-width: 520px) {
  .onboard-card { padding: 24px 18px 20px; border-radius: 16px; max-height: 92vh; }
  .onboard-title { font-size: 19px; }
}

/* ===== Settings (full page, Claude/ChatGPT-style) ===== */
#settings-screen {
  position: fixed; inset: 0; background: var(--bg); z-index: 9200; display: none;
}
#settings-screen.visible { display: flex; }
.settings-shell { display: flex; width: 100%; height: 100%; }
.settings-nav {
  width: 260px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--surface); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.settings-nav-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 18px; }
.settings-back {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border2);
  background: none; color: var(--muted); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.settings-back:hover { border-color: var(--green); color: var(--green); }
.settings-nav-title { font-family: var(--ff-disp); font-size: 19px; font-weight: 700; color: var(--text); }
.settings-nav-item {
  text-align: left; background: none; border: none; color: var(--muted);
  border-radius: 8px; padding: 10px 12px; font-family: var(--ff-body);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.settings-nav-item:hover { background: var(--surface2); color: var(--text); }
.settings-nav-item.active { background: var(--green-dim); color: var(--green); }
.settings-content { flex: 1; overflow-y: auto; padding: 48px 32px; }
.settings-panel { max-width: 640px; margin: 0 auto; animation: rise 0.25s cubic-bezier(0.22,1,0.36,1) both; }
.settings-panel-title { font-family: var(--ff-disp); font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.settings-panel-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 24px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.settings-row-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.settings-row-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

@media (max-width: 768px) {
  .settings-shell { flex-direction: column; }
  .settings-nav {
    width: 100%; height: auto; flex-direction: row; align-items: center;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 10px 12px; overflow-x: auto; gap: 6px;
  }
  .settings-nav-head { padding: 0; margin-right: 6px; }
  .settings-nav-title { display: none; }
  .settings-nav-item { white-space: nowrap; }
  .settings-content { padding: 24px 18px; }
}

/* ===== Learning checklist (settings + onboarding) ===== */
#settings-tasks,
#onboard-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#settings-tasks > *,
#onboard-options > * {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}

#settings-tasks > * > :first-child,
#onboard-options > * > :first-child {
  flex: 1 0 100%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

#settings-tasks label,
#onboard-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
#settings-tasks label:hover,
#onboard-options label:hover {
  border-color: rgba(168,204,90,0.4);
  color: var(--text);
}
#settings-tasks label:has(input:checked),
#onboard-options label:has(input:checked) {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
}

#settings-tasks input[type="checkbox"],
#onboard-options input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1.5px solid var(--border2);
  border-radius: 5px;
  background: var(--surface2);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
#settings-tasks input[type="checkbox"]::before,
#onboard-options input[type="checkbox"]::before {
  content: "";
  width: 9px;
  height: 9px;
  transform: scale(0);
  transition: transform 0.12s cubic-bezier(0.22,1,0.36,1);
  box-shadow: inset 1em 1em var(--green);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
#settings-tasks input[type="checkbox"]:checked,
#onboard-options input[type="checkbox"]:checked {
  border-color: var(--green);
  background: var(--green-dim);
}
#settings-tasks input[type="checkbox"]:checked::before,
#onboard-options input[type="checkbox"]:checked::before {
  transform: scale(1);
}

#settings-tasks button,
#onboard-options button {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: 10px;
  padding: 7px 16px;
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
#settings-tasks button:hover,
#onboard-options button:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
}

.checklist-bar-track {
  height: 4px;
  width: 100%;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}
.checklist-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.22,1,0.36,1);
}

.checklist-skip-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
  text-decoration: underline;
  transition: color 0.15s;
}
.checklist-skip-btn:hover { color: var(--text); }

.checklist-finish-btn {
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  background: var(--green);
  color: #0e0e0d;
  font-family: var(--ff-body);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.checklist-finish-btn:hover { filter: brightness(1.08); }
.checklist-finish-btn:active { transform: scale(0.98); }

.checklist-celebrate {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--green-dim);
  border: 1px solid rgba(168,204,90,0.22);
  color: var(--green);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}
.checklist-celebrate.show { display: flex; }

@media (max-width: 520px) {
  #settings-tasks > *,
  #onboard-options > * { padding: 14px; border-radius: 12px; }
  #settings-tasks button,
  #onboard-options button { margin-left: 0; width: 100%; }
}


.check-understanding-btn {
  margin-top: 10px;
  background: none;
  border: 1px solid rgba(168,204,90,0.4);
  color: var(--green);
  border-radius: 999px;
  padding: 7px 16px;
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.check-understanding-btn:hover { background: var(--green-dim); }

.quiz-loading {
  max-width: 720px; margin: 0 auto 20px; padding: 0 20px;
  font-size: 13px; color: var(--muted);
}

.quiz-card {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 18px 20px;
  max-width: 620px;
  margin: 0 auto 24px;
  margin-left: 20px;
}
.quiz-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--green); margin-bottom: 8px;
}
.quiz-question {
  font-size: 14.5px; color: var(--text); line-height: 1.55; margin-bottom: 14px;
}
.quiz-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.quiz-option-btn {
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: var(--ff-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.quiz-option-btn:hover:not(:disabled) { border-color: var(--green); }
.quiz-option-btn:disabled { cursor: default; }
.quiz-option-btn.quiz-picked { border-color: var(--green); }
.quiz-option-btn.quiz-correct { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.quiz-option-btn.quiz-wrong { border-color: var(--red); background: rgba(204,90,90,0.1); color: #f0a0a0; }

.quiz-open-row { display: flex; gap: 8px; margin-bottom: 6px; }
.quiz-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 13px;
  outline: none;
}
.quiz-input:focus { border-color: var(--green); }
.quiz-submit-btn {
  background: var(--green);
  color: #0e0e0d;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font-family: var(--ff-body);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.quiz-submit-btn:hover { filter: brightness(1.08); }
.quiz-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.quiz-feedback {
  font-size: 12.5px;
  line-height: 1.55;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0;
}
.quiz-feedback-loading { color: var(--muted); background: var(--surface); }
.quiz-feedback-correct { color: var(--green); background: var(--green-dim); border: 1px solid rgba(168,204,90,0.22); }
.quiz-feedback-wrong { color: #f0a0a0; background: rgba(204,90,90,0.1); border: 1px solid rgba(204,90,90,0.3); }

.quiz-continue-btn {
  background: var(--green);
  color: #0e0e0d;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-family: var(--ff-body);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.quiz-continue-btn:hover { filter: brightness(1.08); }

@media (max-width: 520px) {
  .quiz-card { padding: 14px 16px; border-radius: 14px; margin-left: 14px; }
  .quiz-open-row { flex-direction: column; }
  .quiz-submit-btn { padding: 10px; }
}

.familiarity-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.familiarity-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.familiarity-options label:hover { border-color: rgba(168,204,90,0.4); color: var(--text); }
.familiarity-options label:has(input:checked) {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
}
.familiarity-options input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  background: var(--surface);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.familiarity-options input[type="checkbox"]::before {
  content: "";
  width: 8px; height: 8px;
  transform: scale(0);
  transition: transform 0.12s ease;
  box-shadow: inset 1em 1em var(--green);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.familiarity-options input[type="checkbox"]:checked { border-color: var(--green); }
.familiarity-options input[type="checkbox"]:checked::before { transform: scale(1); }

.familiarity-custom-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.familiarity-custom-input {
  flex: 1;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 13px;
  outline: none;
}
.familiarity-custom-input:focus { border-color: var(--green); }
.familiarity-custom-add-btn {
  background: var(--green);
  color: #0e0e0d;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-family: var(--ff-body);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.familiarity-custom-add-btn:hover { filter: brightness(1.08); }

.familiarity-custom-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.familiarity-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border-radius: 999px;
  background: var(--green-dim);
  border: 1px solid rgba(168,204,90,0.22);
  color: var(--green);
  font-size: 12px;
  font-weight: 500;
}
.familiarity-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}
.familiarity-chip-remove:hover { opacity: 1; background: rgba(168,204,90,0.18); }

@media (max-width: 520px) {
  .familiarity-custom-row { flex-direction: column; }
  .familiarity-custom-add-btn { padding: 10px; }
}