:root {
  --ink: #14312c;
  --muted: #5c746c;
  --line: #d5e6de;
  --paper: #f7fbf8;
  --card: #ffffff;
  --teal: #0e7c6b;
  --teal-dark: #0a5c50;
  --gold: #e8b85a;
  --coral: #c84b32;
  --green: #1f7a4d;
  --shadow: 0 18px 40px rgba(18, 70, 56, 0.08);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at -10% -20%, #d9f3ea 0%, transparent 55%),
    radial-gradient(700px 380px at 110% -10%, #fde7c2 0%, transparent 50%),
    #e7f2ec;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

img { max-width: 100%; }

.splash, .auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  text-align: center;
}

.brand-name, .brand strong {
  font-size: 1.7rem;
  letter-spacing: -0.04em;
  margin: 0;
}

.splash p, .lede { color: var(--muted); }

.auth-card, .card, .modal, .plan-card {
  background: var(--card);
  border: 1px solid rgba(20, 49, 44, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px 22px 22px;
  text-align: left;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand small, .muted, .meta { color: var(--muted); }

.who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  color: var(--teal-dark);
  font-weight: 700;
}

.who .label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
}

h1, h2, p { margin-top: 0; }

h1 { font-size: 1.7rem; letter-spacing: -0.03em; margin-bottom: 4px; }

h2 { font-size: 1.05rem; margin-bottom: 10px; }

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: #eef6f2;
  border-radius: 999px;
  margin: 18px 0;
}

.auth-switch button, .choice {
  border: 0;
  background: transparent;
  border-radius: 999px;
  min-height: 40px;
}

.auth-switch button[aria-selected="true"], .choice:has(input:checked) {
  background: white;
  box-shadow: 0 4px 12px rgba(18, 70, 56, 0.08);
}

.choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
}

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

label.field, .field { display: grid; gap: 6px; margin-bottom: 12px; font-size: 0.92rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input, select, textarea {
  width: 100%;
  border: 1px solid #c9ddd4;
  background: #fff;
  border-radius: 12px;
  padding: 12px 12px;
  min-height: 46px;
}

textarea { min-height: 84px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(14, 124, 107, 0.18);
  border-color: var(--teal);
}

.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 14px; font-size: 0.92rem; }

.check input { width: auto; min-height: 0; margin-top: 3px; }

.btn {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  background: var(--teal);
  color: white;
  font-weight: 650;
}

.btn:hover { background: var(--teal-dark); }

.btn.block { width: 100%; }

label.btn { display: inline-flex; align-items: center; justify-content: center; }

.text-link {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--teal-dark);
  font-weight: 650;
  text-align: right;
}

.btn.ghost, .btn.soft {
  background: #e7f4ef;
  color: var(--teal-dark);
}

.btn.warn { background: #fde8e3; color: var(--coral); }

.btn.good { background: #e5f6ec; color: var(--green); }

.btn:disabled { opacity: 0.6; cursor: wait; }

.form-error { color: var(--coral); min-height: 1.2em; font-size: 0.92rem; }

.shell { min-height: 100dvh; background: var(--paper); }

.nav { display: none; }

.mobile-brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }

main { padding: 20px 16px 108px; }

.top p { margin-bottom: 18px; }

.stack { display: grid; gap: 12px; }

.card { padding: 16px; }

.card.is-due { border-color: #f0c2b6; background: #fff8f5; }

.card.is-done { opacity: 0.72; }

.card-head, .row-actions, .inline, .time-row, .plan-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.card-head { align-items: flex-start; }

.when {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--teal-dark);
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.78rem;
  background: #eef3f1;
  color: var(--muted);
  white-space: nowrap;
}

.badge.pending { background: #fff1d6; color: #8a5a10; }
.badge.taken, .badge.done, .badge.active { background: #e5f6ec; color: var(--green); }
.badge.skipped, .badge.paused, .badge.finished { background: #f3f4f4; color: #66716e; }
.badge.expired { background: #fde8e3; color: var(--coral); }

.row-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 12px; }

.ad-slot, .empty, .note {
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff7e8;
  color: #6d5420;
  margin-bottom: 14px;
}

.empty { background: white; color: var(--muted); border: 1px dashed var(--line); }

.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 8px 0; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}

.tabbar button, .nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 0.72rem;
}

.tabbar button[aria-current="page"], .nav button[aria-current="page"] {
  color: var(--teal-dark);
  font-weight: 700;
}

.nav button { 
  width: 100%;
  grid-template-columns: 28px 1fr;
  justify-items: start;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.98rem;
  min-height: 46px;
}

.nav button svg, .tabbar svg { width: 22px; height: 22px; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(16, 40, 34, 0.42);
  display: grid;
  place-items: end center;
  z-index: 20;
  padding: 12px;
}

.modal {
  width: min(560px, 100%);
  max-height: min(92dvh, 820px);
  overflow: auto;
  padding: 18px 16px 16px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.icon-btn {
  border: 0;
  background: #eef6f2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.weekdays { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.weekdays label {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.time-row { margin-bottom: 8px; }

.time-row input { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }

.stat { background: white; border-radius: 14px; padding: 10px; border: 1px solid var(--line); }

.stat b { display: block; font-size: 1.25rem; }

.plan-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }

.plan-list li { padding: 12px; border-radius: 14px; border: 1px solid var(--line); }

.plan-list .current { border-color: var(--teal); background: #f3fbf8; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(12px);
  background: #14312c;
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 30;
  max-width: min(90vw, 420px);
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
  .modal-back { place-items: center; }
  .modal { border-radius: var(--radius); }
}

@media (max-width: 560px) {
  .grid-2, .stats { grid-template-columns: 1fr; }
}

@media (min-width: 960px) {
  .shell {
    width: min(1120px, calc(100% - 48px));
    min-height: calc(100dvh - 48px);
    margin: 24px auto;
    display: grid;
    grid-template-columns: 250px 1fr;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(18, 70, 56, 0.12);
  }

  .nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px 16px;
    background: #f3faf6;
    border-right: 1px solid var(--line);
  }

  .nav nav { display: grid; gap: 4px; margin-top: 22px; }

  .nav-user { margin-top: auto; font-size: 0.92rem; }

  .mobile-brand, .tabbar { display: none; }

  main { padding: 32px 36px 40px; }

  #toast { bottom: 28px; }
}
