/* ========== CSS Custom Properties ========== */
:root {
  --primary: #C6A0A0;
  --secondary: #EBD9CC;
  --bg: #F7F4EF;
  --card: #FDFCF9;
  --accent: #A6C7AD;
  --reward: #99BF99;
  --punishment: #D98C8C;
  --text: #3D3A38;
  --text-secondary: #8C8580;
  --bubble-user: rgba(198,160,160,0.18);
  --bubble-ai: #F2EFE9;
  --shadow: rgba(61, 58, 56, 0.06);
  --border: rgba(198, 160, 160, 0.15);
}

[data-theme="warmClay"] {
  --primary: #C6A0A0; --secondary: #EBD9CC; --bg: #F7F4EF;
  --card: #FDFCF9; --accent: #A6C7AD; --reward: #99BF99;
  --punishment: #D98C8C; --text: #3D3A38; --text-secondary: #8C8580;
  --bubble-user: rgba(198,160,160,0.18); --bubble-ai: #F2EFE9;
  --reward-bg: rgba(153,191,153,0.12); --punish-bg: rgba(217,140,140,0.12);
  --primary-bg-15: rgba(198,160,160,0.15); --primary-bg-8: rgba(198,160,160,0.08);
  --punish-grad: rgba(217,140,140,0.7);
}
[data-theme="sageMint"] {
  --primary: #99BFAD; --secondary: #D9EBD9; --bg: #F2F8F2;
  --card: #F9FCF8; --accent: #C6A0A0; --reward: #8CC7A0;
  --punishment: #D98C8C; --text: #384740; --text-secondary: #80948A;
  --bubble-user: rgba(153,191,173,0.18); --bubble-ai: #EFF5EF;
  --reward-bg: rgba(140,199,160,0.12); --punish-bg: rgba(217,140,140,0.12);
  --primary-bg-15: rgba(153,191,173,0.15); --primary-bg-8: rgba(153,191,173,0.08);
  --punish-grad: rgba(217,140,140,0.7);
}
[data-theme="lavenderDream"] {
  --primary: #B8A6D1; --secondary: #E6E0F2; --bg: #F5F2FA;
  --card: #FBFAFD; --accent: #A6C7AD; --reward: #99BF99;
  --punishment: #D98C8C; --text: #3A3840; --text-secondary: #858094;
  --bubble-user: rgba(184,166,209,0.18); --bubble-ai: #F0EDF5;
  --reward-bg: rgba(153,191,153,0.12); --punish-bg: rgba(217,140,140,0.12);
  --primary-bg-15: rgba(184,166,209,0.15); --primary-bg-8: rgba(184,166,209,0.08);
  --punish-grad: rgba(217,140,140,0.7);
}
[data-theme="sunrisePeach"] {
  --primary: #D9AD9E; --secondary: #F2E6D1; --bg: #FBF7F1;
  --card: #FEFCF8; --accent: #B3CCB3; --reward: #9EC79E;
  --punishment: #E0948C; --text: #403D38; --text-secondary: #8C857A;
  --bubble-user: rgba(217,173,158,0.18); --bubble-ai: #F5F0EB;
  --reward-bg: rgba(158,199,158,0.12); --punish-bg: rgba(224,148,140,0.12);
  --primary-bg-15: rgba(217,173,158,0.15); --primary-bg-8: rgba(217,173,158,0.08);
  --punish-grad: rgba(224,148,140,0.7);
}
[data-theme="oceanBreeze"] {
  --primary: #94B8D1; --secondary: #D9EAF2; --bg: #F0F5FA;
  --card: #F7FAFD; --accent: #ADC9B3; --reward: #94C7A0;
  --punishment: #D98C8C; --text: #384448; --text-secondary: #7A8C94;
  --bubble-user: rgba(148,184,209,0.18); --bubble-ai: #EAF0F5;
  --reward-bg: rgba(148,199,160,0.12); --punish-bg: rgba(217,140,140,0.12);
  --primary-bg-15: rgba(148,184,209,0.15); --primary-bg-8: rgba(148,184,209,0.08);
  --punish-grad: rgba(217,140,140,0.7);
}

/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ========== App Container ========== */
#app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

@media (max-width: 479px) {
  #app { max-width: 100%; margin: 0; }
}

/* ========== Page ========== */
.page {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  animation: pageIn 0.3s ease;
}
.page.active { display: flex; }

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

/* ========== iOS Style Nav Bar ========== */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px 10px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  flex-shrink: 0;
  position: relative;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
}
.nav-bar h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}
.nav-bar .nav-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

/* ========== Tab Bar (iOS style) ========== */
.tab-bar {
  display: flex;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0 2px;
  gap: 1px;
  cursor: pointer;
  color: var(--text-secondary);
  touch-action: manipulation;
  border: none;
  background: none;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.tab-item.active { color: var(--primary); }
.tab-item .tab-icon { font-size: 24px; line-height: 1; }
.tab-item .tab-label { font-size: 10px; font-weight: 500; letter-spacing: 0.2px; }

/* ========== Chat ========== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 4px;
  -webkit-overflow-scrolling: touch;
}

/* Chat bubbles */
.msg {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  animation: msgUp 0.25s ease;
}
@keyframes msgUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user { flex-direction: row-reverse; }
.msg.ai { flex-direction: row; }

.msg-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 6px;
}
.msg.user .msg-avatar { background: var(--primary); color: white; }
.msg.ai .msg-avatar { background: var(--secondary); color: var(--text); }

.msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  color: var(--text);
}
.msg.user .msg-bubble {
  background: var(--bubble-user);
  border-radius: 18px 18px 6px 18px;
}
.msg.ai .msg-bubble {
  background: var(--bubble-ai);
  border-radius: 18px 18px 18px 6px;
}

.msg-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 3px;
  padding-left: 2px;
}
.msg-meta .emoji { font-size: 12px; }
.msg-meta .name { font-size: 11px; color: var(--text-secondary); }
.msg-meta .pts { font-size: 11px; font-weight: 600; }
.msg-meta .pts.reward { color: var(--reward); }
.msg-meta .pts.punish { color: var(--punishment); }

/* Loading dots */
.msg.loading .msg-bubble {
  background: var(--bubble-ai);
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 18px;
}
.msg.loading .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-secondary);
  animation: dotP 1.2s infinite;
  opacity: 0.3;
}
.msg.loading .dot:nth-child(2) { animation-delay: 0.2s; }
.msg.loading .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotP {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* ========== Chat Input ========== */
.chat-input-area {
  padding: 6px 12px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
}

.chat-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.chat-input::placeholder { color: var(--text-secondary); opacity: 0.5; }

.send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: opacity 0.15s, transform 0.1s;
}
.send-btn:active { transform: scale(0.88); }
.send-btn:disabled { opacity: 0.25; }

/* Speech button */
.speech-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0.5px solid var(--border);
  background: var(--bg);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: all 0.15s;
}
.speech-btn:active { transform: scale(0.88); }
.speech-btn.listening {
  background: var(--punish-bg);
  border-color: var(--punishment);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,140,140,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(217,140,140,0); }
}

/* ========== Dashboard ========== */
.dash-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.dash-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px var(--shadow);
}

.dash-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}

/* Today ring */
.today-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.ring-box {
  position: relative;
  width: 100px; height: 100px;
}

.ring-bg { fill: none; stroke: var(--secondary); stroke-width: 6; }
.ring-prog {
  fill: none; stroke-width: 6; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center;
  transition: stroke-dashoffset 0.8s ease;
  stroke: url(#rg);
}

.ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-score { font-size: 28px; font-weight: 700; color: var(--reward); line-height: 1; }
.ring-label { font-size: 10px; color: var(--text-secondary); }

.goal-badge {
  font-size: 12px;
  color: var(--reward);
  background: var(--reward-bg);
  padding: 4px 12px;
  border-radius: 20px;
}

/* Chart bars */
.chart-box {
  height: 130px;
  display: flex; align-items: flex-end;
  gap: 4px;
}

.chart-col {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; height: 100%; justify-content: flex-end;
}

.chart-bar {
  width: 100%; max-width: 28px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.6s ease;
  background: linear-gradient(to top, var(--reward), var(--accent));
}
.chart-bar.neg { background: linear-gradient(to top, var(--punishment), var(--punish-grad)); }

.chart-col-label { font-size: 10px; color: var(--text-secondary); margin-top: 4px; }
.chart-col-val { font-size: 9px; color: var(--text-secondary); margin-top: 1px; opacity: 0.7; }

/* Habit rows */
.habit-list { display: flex; flex-direction: column; gap: 8px; }
.habit-row { display: flex; justify-content: space-between; align-items: center; }
.habit-row .h-name { font-size: 14px; color: var(--text); }
.habit-row .h-pts { font-size: 14px; font-weight: 600; }
.habit-row .h-pts.reward { color: var(--reward); }
.habit-row .h-pts.punish { color: var(--punishment); }

/* Mini records */
.mini-list { display: flex; flex-direction: column; }
.mini-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
}
.mini-item:last-child { border-bottom: none; }
.mini-item .mi-e { font-size: 16px; width: 26px; text-align: center; }
.mini-item .mi-b { flex: 1; }
.mini-item .mi-t { font-size: 13px; color: var(--text); line-height: 1.3; }
.mini-item .mi-s { font-size: 10px; color: var(--text-secondary); }
.mini-item .mi-p { font-size: 14px; font-weight: 600; }
.mini-item .mi-p.reward { color: var(--reward); }
.mini-item .mi-p.punish { color: var(--punishment); }

/* ========== Sleep Tracker ========== */
.sleep-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.scard {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px var(--shadow);
}
.scard-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.sleep-stats {
  margin-bottom: 12px;
}
.ss-row {
  display: flex;
  gap: 6px;
}
.ss-item {
  flex: 1;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 1px 4px var(--shadow);
}
.ss-v {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.ss-l {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Sleep form */
.sf-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.sf-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sf-field span {
  font-size: 10px;
  color: var(--text-secondary);
}
.sf-input {
  width: 100%;
  padding: 8px 4px;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  text-align: center;
  -webkit-appearance: none;
  box-sizing: border-box;
  min-width: 0;
}
.sf-input:focus { border-color: var(--primary); }
.sf-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  touch-action: manipulation;
}
.sf-btn:active { opacity: 0.7; }

/* Sleep chart */
.sleep-chart {
  height: 110px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.sc-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.sc-bar {
  width: 100%;
  max-width: 24px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  background: var(--primary-bg-15);
  transition: height 0.4s ease;
}
.sc-bar.good { background: var(--reward); }
.sc-bar.ok { background: #D4C587; }
.sc-bar.bad { background: var(--punishment); }
.sc-bar.late::after {
  content: '🌙';
  font-size: 8px;
  display: block;
  text-align: center;
  margin-top: -10px;
}
.sc-label { font-size: 9px; color: var(--text-secondary); margin-top: 3px; }
.sc-val { font-size: 8px; color: var(--text-secondary); margin-top: 1px; }

/* Sleep log */
.sl-empty {
  text-align: center;
  padding: 16px 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.sl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}
.sl-item:last-child { border-bottom: none; }
.sl-date { min-width: 72px; font-size: 12px; color: var(--text-secondary); }
.sl-times { flex: 1; color: var(--text); }
.sl-dur { font-weight: 600; color: var(--text); min-width: 44px; }
.sl-badge {
  font-size: 10px;
  background: var(--punish-bg);
  color: var(--punishment);
  padding: 1px 6px;
  border-radius: 8px;
}
.sl-del {
  border: none;
  background: none;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.3;
  touch-action: manipulation;
}

/* ========== Journal ========== */
.journal-top {
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
}
.journal-search-box {
  padding: 8px 16px;
}
.journal-search {
  width: 100%;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.journal-search::placeholder { color: var(--text-secondary); opacity: 0.5; }

.journal-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 10px;
}
.jd-nav {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}
.jd-nav:active { background: var(--primary-bg-8); }
.jd-info { text-align: center; }
.jd-date { font-size: 14px; font-weight: 600; color: var(--text); }
.jd-today { font-size: 11px; color: var(--primary); cursor: pointer; margin-top: 1px; }

.journal-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.journal-empty {
  text-align: center;
  padding: 60px 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.jd-card {
  background: var(--card);
  border-radius: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px var(--shadow);
  overflow: hidden;
}
.jd-card.today {
  border: 1px solid var(--primary);
}

.jd-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--border);
}
.jd-card-date {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.jd-card-day { font-size: 16px; font-weight: 700; color: var(--text); }
.jd-card-dow { font-size: 11px; color: var(--text-secondary); }
.jd-card-total { font-size: 18px; font-weight: 700; }
.jd-card-total.r { color: var(--reward); }
.jd-card-total.p { color: var(--punishment); }

.jd-card-body { padding: 4px 0; }

.jd-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 0.5px solid var(--border);
}
.jd-entry:last-child { border-bottom: none; }

.jd-entry-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 36px;
}
.jd-entry-time { font-size: 10px; color: var(--text-secondary); }
.jd-entry-emoji { font-size: 18px; }

.jd-entry-main { flex: 1; min-width: 0; }
.jd-entry-habit { font-size: 13px; font-weight: 600; color: var(--text); }
.jd-entry-desc { font-size: 12px; color: var(--text); line-height: 1.3; margin-top: 1px; }
.jd-entry-ai { font-size: 11px; color: var(--text-secondary); line-height: 1.3; margin-top: 2px; }

.jd-entry-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.jd-entry-pts { font-size: 15px; font-weight: 700; }
.jd-entry-pts.r { color: var(--reward); }
.jd-entry-pts.p { color: var(--punishment); }
.jd-entry-actions { display: flex; gap: 2px; }
.jd-edit-btn, .jd-del-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  opacity: 0.4;
  transition: opacity 0.15s;
  touch-action: manipulation;
}
.jd-edit-btn:hover, .jd-del-btn:hover { opacity: 1; }

/* ========== Settings ========== */
.set-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.set-section { margin-bottom: 14px; }

.set-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 4px var(--shadow);
}

.set-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.set-label .si { color: var(--primary); }

/* Theme picker */
.theme-picker {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.to {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  cursor: pointer; touch-action: manipulation;
  border: none; background: none; padding: 4px;
  font-family: inherit;
}

.tc {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  transition: border-color 0.2s;
  position: relative;
}
.tc.sel { border-color: var(--text); }
.tc.sel::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.tn { font-size: 10px; color: var(--text-secondary); }

/* Personality */
.ps-list { display: flex; flex-direction: column; gap: 6px; }

.po {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: inherit; text-align: left; width: 100%;
  touch-action: manipulation;
}
.po.act { border-color: var(--primary); background: var(--primary-bg-8); }
.po .po-l .po-n { font-size: 14px; font-weight: 600; color: var(--text); }
.po .po-l .po-d { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

/* Slider */
.goal-d { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.goal-d .gv { font-size: 20px; font-weight: 700; color: var(--primary); }
.goal-d .gl { font-size: 13px; color: var(--text-secondary); }

input[type="range"] {
  width: 100%; height: 4px;
  -webkit-appearance: none; appearance: none;
  background: var(--secondary);
  border-radius: 2px; outline: none;
  touch-action: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px var(--shadow);
  touch-action: manipulation;
}

/* API input */
.api-input {
  width: 100%;
  padding: 10px 12px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.api-input:focus { border-color: var(--primary); }
.api-hint { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* Activity Settings */
.activity-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.as-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 12px;
}
.as-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.as-fields {
  display: flex;
  gap: 4px;
}
.as-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.as-field span {
  font-size: 9px;
  color: var(--text-secondary);
  text-align: center;
}
.as-input {
  width: 100%;
  min-width: 0;
  padding: 6px 2px;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  outline: none;
  text-align: center;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.as-input:focus { border-color: var(--primary); }

/* About */
.about-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); }
.about-row + .about-row { margin-top: 4px; }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: white;
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== Misc ========== */
::-webkit-scrollbar { width: 2px; }
::-webkit-scrollbar-thumb { background: var(--text-secondary); border-radius: 2px; }

@media (min-width: 480px) {
  #app { border-left: 0.5px solid var(--border); border-right: 0.5px solid var(--border); }
}
