:root {
  --bg: #0a0a0b; --s1: #111113; --s2: #1a1a1e; --bd: #28282e; --text: #e4e2da; --m: #4e4e58; --m2: #6e6e7a;
  --gold: #c8a86a; --gold2: #e6c88a; --gold-bg: rgba(200,168,106,0.08); --green: #5db87a; --red: #c0605a;
  --orb-g1: #d4c090; --orb-g2: #9a7a3a; --orb-g3: #3a2a0a;
}
body.theme-light {
  --bg: #fdfaf5; --s1: #fffdfa; --s2: #f5f0e8; --bd: #e8e2d0; --text: #3c3836; --m: #a89984; --m2: #928374;
  --gold: #b57614; --gold2: #d79921; --gold-bg: rgba(181,118,20,0.06); --green: #427b58; --red: #9d0006;
  --orb-g1: #fbf1c7; --orb-g2: #d79921; --orb-g3: #b57614;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "Noto Sans SC", "PingFang SC", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 20px;
  transition: background 0.3s, color 0.3s;
}

/* Nav */
.nav { position: fixed; top: 0; left: 0; right: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--bg); border-bottom: 1px solid var(--bd); }
.nav-brand { font-weight: 900; letter-spacing: 2px; font-size: 12px; color: var(--gold); }
.nav-actions { display: flex; gap: 8px; }
.nav-btn { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--bd); background: var(--s1); color: var(--text); font-size: 11px; cursor: pointer; transition: all 0.2s; }
.nav-btn:hover { border-color: var(--gold); }
.nav-btn.active { border-color: var(--gold); color: var(--gold); }

/* Stage */
.stage { display: none; width: 100%; max-width: 420px; margin-top: 60px; flex-direction: column; align-items: center; animation: fadeIn 0.4s ease; }
.stage.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Orb */
.orb-wrap { position: relative; }
.orb { border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--orb-g1), var(--orb-g2), var(--orb-g3)); }
.orb-wrap.orb-proc { width: 60px; height: 60px; }
.orb-wrap.orb-proc .orb { width: 52px; height: 52px; position: absolute; top: 4px; left: 4px; animation: breathe 2s infinite ease-in-out; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* Input */
.input-area { width: 100%; position: relative; }
.ta {
  width: 100%; background: var(--s1); border: 1px solid var(--bd); border-radius: 16px;
  padding: 16px 90px 16px 16px; color: var(--text); font-size: 15px; line-height: 1.6;
  outline: none; resize: none; min-height: 180px; font-family: inherit; transition: border-color 0.2s;
}
.ta:focus { border-color: var(--gold); }
.input-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; align-items: center; }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--gold); color: var(--bg);
  font-size: 20px; cursor: pointer; transition: opacity 0.2s;
}
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.input-meta { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 8px; padding: 0 4px; }
.input-hint { font-size: 11px; color: var(--m); }
.input-hint.listening { color: var(--red); }
.model-status { font-size: 11px; color: var(--m2); }

/* Style chips */
.style-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.style-chip {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--bd);
  background: transparent; color: var(--m2); font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.style-chip.active { border-color: var(--gold); color: var(--gold); background: var(--gold-bg); }

/* Processing */
.proc-text { text-align: center; line-height: 1.8; font-size: 14px; color: var(--m2); margin-top: 10px; }
.proc-text .highlight { color: var(--gold); }

/* Plan cards */
.plan-summary {
  background: var(--s1); border: 1px solid var(--gold); border-radius: 14px;
  padding: 18px; width: 100%; margin-bottom: 18px; font-size: 14px; line-height: 1.8; color: var(--text);
}
.plan-summary strong { color: var(--gold); }

.task-card {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 14px;
  padding: 16px; width: 100%; margin-bottom: 10px; display: flex; gap: 14px; transition: border-color 0.2s;
}
.task-card:hover { border-color: var(--m); }
.t-idx { width: 26px; height: 26px; border-radius: 8px; background: var(--bd); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; color: var(--text); }
.t-idx.top { background: var(--gold); color: var(--bg); }
.t-body { flex: 1; }
.t-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.t-title { font-weight: 700; font-size: 15px; }
.t-tag { font-size: 11px; color: var(--gold); background: var(--gold-bg); padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.t-time { font-size: 12px; color: var(--m2); margin-bottom: 4px; }
.t-reason { font-size: 12px; color: var(--m2); line-height: 1.6; }

/* Buttons */
.btn-group { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 15px; }
.btn { width: 100%; padding: 15px; border-radius: 12px; border: none; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.btn-primary { background: var(--gold); color: var(--bg); }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; border: 1px solid var(--bd); color: var(--m2); }
.btn-ghost:hover { border-color: var(--m2); }
.btn-sm { padding: 10px 16px; font-size: 13px; width: auto; border-radius: 10px; }
.btn-danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(192,96,90,0.1); }

/* Negotiate */
.negotiate-area { width: 100%; margin-top: 15px; }
.nego-input-wrap { width: 100%; position: relative; display: none; }
.nego-input-wrap.show { display: block; }
.nego-ta {
  width: 100%; background: var(--s1); border: 1px solid var(--bd); border-radius: 12px;
  padding: 14px 50px 14px 14px; color: var(--text); font-size: 14px; line-height: 1.5;
  outline: none; resize: none; min-height: 70px; font-family: inherit;
}
.nego-ta:focus { border-color: var(--gold); }
.nego-send {
  position: absolute; right: 10px; bottom: 10px; width: 32px; height: 32px;
  border-radius: 50%; border: none; background: var(--gold); color: var(--bg);
  font-size: 16px; cursor: pointer;
}
.ai-reply {
  background: var(--s2); border: 1px solid var(--bd); border-radius: 12px;
  padding: 14px; width: 100%; margin-top: 10px; font-size: 13px; line-height: 1.7; color: var(--text); display: none;
}
.ai-reply.show { display: block; }

/* Settings */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; display: none; align-items: center; justify-content: center; }
.settings-overlay.show { display: flex; }
.settings-panel {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 18px;
  padding: 28px 24px; width: 90%; max-width: 400px; max-height: 85vh; overflow-y: auto;
}
.settings-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; color: var(--gold); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--m2); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--bd);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--gold); }
.field .hint { font-size: 11px; color: var(--m); margin-top: 4px; }
.settings-actions { display: flex; gap: 10px; margin-top: 20px; }
.settings-actions .btn { flex: 1; padding: 12px; font-size: 14px; }

/* Error toast */
.error-toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: white; padding: 12px 24px; border-radius: 10px;
  font-size: 13px; z-index: 300; display: none; max-width: 90%; text-align: center;
}
.error-toast.show { display: block; animation: fadeIn 0.3s ease; }

/* Loader */
.loader { display: flex; gap: 6px; margin: 20px 0; }
.dot { width: 10px; height: 10px; background: var(--gold); border-radius: 50%; animation: jump 0.6s infinite alternate; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes jump { from { transform: translateY(0); opacity: 0.3; } to { transform: translateY(-10px); opacity: 1; } }

.hint { font-size: 11px; color: var(--m); text-align: center; margin-top: 18px; line-height: 1.6; }
.api-hint { font-size: 11px; color: var(--m2); }
.api-hint a { color: var(--gold); cursor: pointer; text-decoration: underline; }
.api-hint.configured { color: var(--green); }

/* ========== Morning Push ========== */
.morning-card {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 18px;
  padding: 28px 22px; width: 100%; text-align: center;
}
.morning-greeting { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.morning-date { font-size: 12px; color: var(--m2); margin-bottom: 20px; }
.morning-stats {
  background: var(--s2); border-radius: 12px; padding: 16px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.8; color: var(--m2); text-align: left;
}
.morning-stats strong { color: var(--gold); }
.morning-suggestion {
  background: var(--gold-bg); border: 1px solid var(--gold); border-radius: 12px;
  padding: 14px; font-size: 14px; line-height: 1.7; color: var(--text); margin-bottom: 20px; text-align: left;
}

/* ========== Focus Mode ========== */
.focus-current {
  background: var(--s1); border: 1px solid var(--gold); border-radius: 18px;
  padding: 24px; width: 100%; text-align: center; margin-bottom: 16px;
}
.focus-task-name { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.focus-task-tag { display: inline-block; font-size: 11px; color: var(--gold); background: var(--gold-bg); padding: 3px 10px; border-radius: 4px; }

/* Timer */
.timer-ring {
  width: 160px; height: 160px; border-radius: 50%; margin: 24px auto;
  border: 4px solid var(--bd); display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: border-color 0.3s;
}
.timer-ring.overtime { border-color: var(--red); }
.timer-elapsed { font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer-ring.overtime .timer-elapsed { color: var(--red); }
.timer-suggest-label { font-size: 11px; color: var(--m2); margin-top: 4px; }

/* Focus actions */
.focus-actions { display: flex; gap: 10px; width: 100%; margin-bottom: 16px; }
.focus-actions .btn { flex: 1; padding: 14px 8px; font-size: 14px; }

/* Focus task list */
.focus-task-list { width: 100%; margin-bottom: 16px; }
.focus-task-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 10px; margin-bottom: 6px;
  font-size: 13px; transition: all 0.2s;
}
.focus-task-item.active { border-color: var(--gold); background: var(--gold-bg); }
.focus-task-item.done { opacity: 0.5; text-decoration: line-through; }
.focus-task-item.skipped { opacity: 0.4; }
.fti-status { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--bd); display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }
.focus-task-item.active .fti-status { border-color: var(--gold); background: var(--gold); color: var(--bg); }
.focus-task-item.done .fti-status { border-color: var(--green); background: var(--green); color: white; }
.focus-task-item.skipped .fti-status { border-color: var(--m); background: var(--m); color: white; }
.fti-name { flex: 1; }
.fti-time { font-size: 11px; color: var(--m2); }

/* Focus alert (overtime / idle) */
.focus-alert {
  background: var(--s2); border: 1px solid var(--red); border-radius: 14px;
  padding: 16px; width: 100%; margin-bottom: 14px; display: none; animation: fadeIn 0.3s;
}
.focus-alert.show { display: block; }
.focus-alert-msg { font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
.focus-alert-actions { display: flex; gap: 8px; }
.focus-alert-actions .btn-sm { flex: 1; text-align: center; }

/* Task feedback toast */
.focus-feedback {
  background: var(--gold-bg); border: 1px solid var(--gold); border-radius: 12px;
  padding: 14px; width: 100%; margin-bottom: 14px; font-size: 14px; line-height: 1.6;
  display: none; animation: fadeIn 0.3s;
}
.focus-feedback.show { display: block; }

/* ========== Stuck Overlay ========== */
.stuck-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; display: none; align-items: center; justify-content: center; }
.stuck-overlay.show { display: flex; }
.stuck-panel {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 18px;
  padding: 28px 24px; width: 90%; max-width: 400px;
}
.stuck-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--gold); }
.stuck-subtitle { font-size: 13px; color: var(--m2); margin-bottom: 16px; }
.stuck-types { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.stuck-type-btn {
  padding: 12px 16px; border-radius: 10px; border: 1px solid var(--bd);
  background: transparent; color: var(--text); font-size: 14px; cursor: pointer;
  text-align: left; transition: all 0.2s; font-family: inherit;
}
.stuck-type-btn.selected { border-color: var(--gold); background: var(--gold-bg); color: var(--gold); }
.stuck-desc-wrap { margin-bottom: 16px; display: none; }
.stuck-desc-wrap.show { display: block; }
.stuck-desc {
  width: 100%; background: var(--bg); border: 1px solid var(--bd); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 13px; outline: none; resize: none;
  min-height: 60px; font-family: inherit;
}
.stuck-ai-reply {
  background: var(--s2); border: 1px solid var(--bd); border-radius: 12px;
  padding: 14px; font-size: 13px; line-height: 1.7; margin-bottom: 16px; display: none;
}
.stuck-ai-reply.show { display: block; }

/* ========== Checkout ========== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-bottom: 18px; }
.stat-card {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 12px;
  padding: 16px; text-align: center;
}
.stat-value { font-size: 28px; font-weight: 800; color: var(--gold); }
.stat-label { font-size: 11px; color: var(--m2); margin-top: 4px; }

.checkout-section { width: 100%; margin-bottom: 16px; }
.checkout-section-title { font-size: 13px; font-weight: 700; color: var(--m2); margin-bottom: 10px; }
.unfinished-item {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 10px;
  padding: 12px; margin-bottom: 8px;
}
.unfinished-name { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.unfinished-actions { display: flex; gap: 6px; }
.unfinished-actions .btn-sm { font-size: 12px; padding: 6px 12px; }

.checkout-ai-summary {
  background: var(--s1); border: 1px solid var(--gold); border-radius: 14px;
  padding: 18px; width: 100%; font-size: 14px; line-height: 1.8; margin-bottom: 16px;
}

/* ========== Reflection ========== */
.reflect-prompt {
  font-size: 15px; line-height: 1.7; color: var(--m2); text-align: center; margin-bottom: 18px;
}
.dimension-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-bottom: 18px; }
.dimension-card {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 12px;
  padding: 14px;
}
.dimension-title { font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 6px; }
.dimension-content { font-size: 13px; line-height: 1.6; color: var(--text); }

/* ========== Completion screen ========== */
.completion-screen { text-align: center; padding: 40px 0; }
.completion-icon { font-size: 48px; margin-bottom: 16px; }
.completion-title { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.completion-subtitle { font-size: 14px; color: var(--m2); line-height: 1.6; margin-bottom: 24px; }

/* Stage indicator */
.stage-indicator { display: flex; gap: 6px; margin-bottom: 16px; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bd); transition: background 0.3s; }
.stage-dot.active { background: var(--gold); }
.stage-dot.done { background: var(--green); }
