:root {
  --bg: #17181A;
  --bg-raised: #1C1E20;
  --line: #2B2D2F;
  --text: #EDEAE3;
  --text-muted: #8B8E90;
  --accent: #E8562E;
  --accent-dim: #3A2620;
  --success: #5B9A73;
  --radius: 3px;
  --font-display: 'Oswald', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
  color: inherit;
}

.screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* ---------- Login ---------- */
#loginView {
  align-items: center;
}
.login-card {
  width: min(320px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  letter-spacing: 0.5px;
  color: var(--text);
  margin-bottom: 8px;
  text-align: left;
}
.wordmark.small {
  font-size: 1.25rem;
  margin-bottom: 0;
}
.login-card input {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
}
.login-card input:focus {
  border-color: var(--accent);
}
.login-card button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #17181A;
  font-weight: 600;
  padding: 12px 14px;
  font-size: 1rem;
  cursor: pointer;
}
.login-card button:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.error-text {
  color: var(--accent);
  font-size: 0.85rem;
  margin: 0;
}

/* ---------- App shell ---------- */
#appView {
  width: 100%;
  display: block;
}
.topbar {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.tabs {
  display: flex;
  gap: 4px;
  align-items: center;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.95rem;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius);
}
.tab-btn.active {
  color: var(--text);
  background: var(--bg-raised);
}
.tab-btn.logout {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-left: 6px;
}

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- Hero ---------- */
.hero {
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.hero-number {
  font-family: var(--font-display);
  font-size: 4rem;
  line-height: 1;
  font-weight: 700;
  color: var(--accent);
}
.hero-label {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
  margin-top: 2px;
}
.hero-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 6px;
}
.hero-day {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text-muted);
}
.hero-workout {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  margin-top: 2px;
  margin-bottom: 14px;
}
.progress-bar {
  height: 8px;
  background: var(--bg-raised);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
}

/* ---------- Checklist ---------- */
.checklist {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}
.check-row {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.check-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.check-box {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 1.5px solid var(--text-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.check-row.done .check-box {
  background: var(--success);
  border-color: var(--success);
}
.check-box svg { width: 13px; height: 13px; display: none; }
.check-row.done .check-box svg { display: block; }
.check-row-nametarget {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.check-row-name {
  font-size: 0.98rem;
}
.check-row.done .check-row-name {
  color: var(--text-muted);
}
.check-row-target {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.target-hint {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 2px;
}
.check-row-summary {
  font-size: 0.8rem;
  color: var(--success);
}
.check-detail {
  margin-top: 10px;
  margin-left: 34px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.check-detail .form-row { display: flex; gap: 8px; }
.check-detail input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  font-size: 0.9rem;
  outline: none;
  min-width: 0;
}
.check-detail input:focus { border-color: var(--accent); }
.check-detail-actions { display: flex; gap: 8px; }
.check-detail-actions button {
  border: none;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 0.88rem;
  cursor: pointer;
}
.save-detail-btn { background: var(--accent); color: #17181A; font-weight: 600; }
.cancel-detail-btn { background: none; color: var(--text-muted); }

.extra-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 10px 0;
  cursor: pointer;
  text-align: left;
}
.extra-toggle:hover { color: var(--text); }

/* ---------- Entry form ---------- */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.form-row { display: flex; gap: 8px; }
.form-row input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.95rem;
  outline: none;
  min-width: 0;
}
.form-row input:focus { border-color: var(--accent); }
.form-row.triple input { text-align: left; }
.chips {
  flex-wrap: wrap;
}
.chip {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
}
.chip.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}
.add-btn {
  background: var(--accent);
  border: none;
  color: #17181A;
  font-weight: 600;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 4px;
}

/* ---------- Entries list ---------- */
.entries-list { display: flex; flex-direction: column; }
.day-group { margin-bottom: 18px; }
.day-heading {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.entry-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entry-name { font-size: 0.95rem; }
.entry-meta { font-size: 0.8rem; color: var(--text-muted); }
.entry-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  flex-shrink: 0;
}
.entry-del:hover { color: var(--accent); }
.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 20px 0;
}

/* ---------- Stats ---------- */
.stats-block {
  margin-bottom: 26px;
}
.stats-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.chart-wrap { width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-name { width: 108px; flex-shrink: 0; font-size: 0.85rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: var(--bg-raised); border-radius: 2px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }
.bar-count { width: 24px; text-align: right; font-size: 0.8rem; color: var(--text-muted); }

.stats-block.totals {
  display: flex;
  gap: 30px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.stats-block.totals > div {
  display: flex;
  flex-direction: column;
}
.stats-block.totals span {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--text);
}
.stats-block.totals small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ---------- Plan editor ---------- */
.plan-intro {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 18px;
}
.plan-editor {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 20px;
}
.plan-day {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.plan-day-name {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.plan-day input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  font-size: 0.95rem;
  margin-bottom: 8px;
  outline: none;
}
.plan-day textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  color: var(--text);
  min-height: 90px;
  resize: vertical;
  outline: none;
}
.plan-day input:focus, .plan-day textarea:focus { border-color: var(--accent); }
.saved-text {
  color: var(--success);
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
