/* track.moser.ai — Dark/Lila-Theme */
:root {
  --bg:          #0c1117;
  --bg-2:        #131a24;
  --surface:     #1a2230;
  --surface-2:   #232c3d;
  --accent:      #7c6aff;
  --accent-2:    #5d4fdc;
  --accent-dim:  rgba(124, 106, 255, 0.18);
  --text:        #e8eaf0;
  --muted:       #9098ad;
  --border:      #2a3344;
  --danger:      #e35d5d;
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.30);
  --shadow:      0 6px 20px rgba(0,0,0,0.35);
  --shadow-accent: 0 4px 18px rgba(124,106,255,0.35);
  --radius:      14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  font-family: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  overscroll-behavior: none;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 80% 0%, rgba(124,106,255,0.08), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(124,106,255,0.05), transparent 50%),
    var(--bg);
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  padding-top: calc(env(safe-area-inset-top) + 12px);
  background: rgba(12, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.burger {
  width: 40px; height: 40px;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms;
}
.burger:hover { background: var(--accent-dim); }
.burger span {
  display: block;
  width: 18px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 200ms;
}

/* ===== Main ===== */
.main {
  flex: 1 1 auto;
  padding: 20px 16px 110px;
  overflow-y: auto;
}
.recent-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}
.recent-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recent-empty {
  color: var(--muted);
  font-size: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.recent-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.metric-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
}
.metric-sleep    { background: rgba( 96, 165, 250, 0.20); color: #8cb8fc; }
.metric-mood     { background: rgba(244, 114, 182, 0.20); color: #f7a1ce; }
.metric-energy   { background: rgba(251, 191,  36, 0.20); color: #fcd45c; }
.metric-food     { background: rgba(248, 113, 113, 0.20); color: #fa9999; }
.metric-sport    { background: rgba( 52, 211, 153, 0.20); color: #6fe0b9; }
.metric-money    { background: rgba(168, 162, 158, 0.20); color: #cfc8c4; }
.metric-symptom  { background: rgba(239,  68,  68, 0.22); color: #f47979; }
.metric-habit    { background: rgba(167, 139, 250, 0.22); color: #b9a3ff; }
.metric-feeling  { background: rgba(236,  72, 153, 0.20); color: #f48bbc; }
.metric-weight   { background: rgba(165, 180, 252, 0.22); color: #c1cdfd; }
.metric-water    { background: rgba(56, 189, 248, 0.20); color: #7dd3fc; }
.metric-productivity { background: rgba(34, 197, 94, 0.20); color: #6ed699; }
.metric-social   { background: rgba(251, 146, 60, 0.20); color: #fcb98d; }
.metric-observation  { background: rgba(148, 163, 184, 0.20); color: #b8c2d2; }
.metric-generic  { background: var(--accent-dim); color: var(--accent); }

.metric-value { font-weight: 600; color: var(--text); font-size: 13px; min-width: 0; }
.metric-text {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ===== Composer ===== */
.composer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(12, 17, 23, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 5;
}
.msg-input {
  flex: 1 1 auto;
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 150ms, background 150ms;
}
.msg-input:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}
.msg-input::placeholder { color: var(--muted); }
.btn-send, .btn-mic {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 100ms, background 150ms;
  box-shadow: var(--shadow-accent);
}
.btn-send:hover, .btn-mic:hover { background: var(--accent-2); }
.btn-send:active, .btn-mic:active { transform: scale(0.94); }
.btn-send:disabled { opacity: 0.5; cursor: default; }
.btn-mic.is-recording { background: var(--danger); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 93, 93, 0.55); }
  50%      { box-shadow: 0 0 0 12px rgba(227, 93, 93, 0); }
}

/* ===== Drawer ===== */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(380px, 88vw);
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,0.5);
  transform: translateX(100%);
  transition: transform 220ms ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: calc(env(safe-area-inset-top) + 0px);
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.drawer-head strong { font-size: 15px; }
.drawer-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 26px;
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}
.drawer-close:hover { background: var(--accent-dim); color: var(--text); }
.drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.drawer-tab {
  flex: 1 1 auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 8px 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.drawer-tab.is-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}
.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
}
.tab { display: none; }
.tab.is-active { display: block; }
.btn-primary, .btn-secondary {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: background 120ms;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.6; cursor: default; }
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface-2); }
.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  margin-bottom: 12px;
}
.muted { color: var(--muted); font-size: 13px; }

.history-list {
  list-style: none;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.hi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.hi-text { color: var(--text); line-height: 1.4; }
.hi-value { color: var(--accent); font-weight: 600; margin-top: 4px; font-size: 12px; }

.advice-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.advice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
}
.advice-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.advice-card .why {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 8px;
}
.advice-card .action {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}
.advice-meta {
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* ===== Recording overlay ===== */
.rec-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 17, 23, 0.92);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  z-index: 100;
}
.rec-overlay.hidden { display: none; }
.rec-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
}
.rec-time {
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rec-hint { color: var(--muted); font-size: 13px; }
.rec-actions { display: flex; gap: 10px; margin-top: 10px; }
.btn-rec-stop, .btn-rec-cancel {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.btn-rec-stop { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}
.toast.hidden { display: none; }

@media (max-width: 480px) {
  .recent-item { grid-template-columns: auto 1fr auto; }
  .recent-item .metric-value { display: none; }
}
