/* ───────────────────────── Nats Study ─────────────────────────
   Soft garden-green theme · mobile-first · big touch targets
   (sister app to Nats Lifts — same bones, green soul) */

:root {
  --bg: #F2FAF3;
  --card: #FFFFFF;
  --ink: #24352B;
  --muted: #7C9C88;
  --line: #E0F0E4;
  --green: #2E9E68;
  --leaf: #7BC86C;
  --deep: #1F7A4D;
  --grad: linear-gradient(120deg, #2E9E68, #7BC86C);
  --grad-soft: linear-gradient(120deg, #E1F5E6, #F0F9E3);
  --amber: #E8A33D;
  --blush: #ED5C86;
  --shadow: 0 6px 24px rgba(46, 158, 104, 0.10);
  --radius: 22px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }
body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

#app { max-width: 480px; margin: 0 auto; padding: 18px 18px 90px; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: var(--green); text-decoration: none; }

/* ── header ── */
.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 16px; }
.brand { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.brand .sprout { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); display: inline-block; }
.sync-dot.pending { background: var(--amber); }
.sync-dot.offline { background: #B9C9BE; }
.sync-dot.error { background: #E2574C; }

/* ── sync warning bar (says it in words, not just a dot) ── */
.syncbar {
  max-width: 480px; margin: 0 auto; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  background: #FFF4E3; color: #6E4A16; border-bottom: 1px solid #F2DFC2;
  font-size: 13px; line-height: 1.35; font-weight: 500;
}
.syncbar span { flex: 1; }
.syncbar button {
  flex: none; padding: 8px 12px; border-radius: 12px; font-size: 13px;
  font-weight: 700; background: #6E4A16; color: #fff;
}

/* ── settings rows ── */
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: none; padding-bottom: 0; }
.set-row:first-child { padding-top: 0; }
.set-row b { display: block; font-size: 15px; font-weight: 800; }
.set-row .hint { font-size: 12.5px; color: var(--muted); font-weight: 500; line-height: 1.4; display: block; margin-top: 3px; }

/* ── this-week strip ── */
.weekstrip { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 16px 12px; margin-bottom: 16px; }
.weekstrip-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.weekstrip-head b { font-size: 15px; font-weight: 800; }
.weekstrip-head span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.weekbars { display: flex; align-items: flex-end; gap: 7px; height: 74px; }
.weekbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.weekbar .col { width: 100%; border-radius: 7px 7px 4px 4px; background: var(--grad); min-height: 4px; transition: height .3s ease; }
.weekbar .col.empty { background: var(--line); }
.weekbar .col.goal { background: linear-gradient(180deg, #1F7A4D, #2E9E68); }
.weekbar .dl { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.weekbar.is-today .dl { color: var(--green); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; background: var(--card);
  box-shadow: var(--shadow); font-size: 18px; display: grid; place-items: center;
}

/* ── back row ── */
.back-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.back-btn {
  width: 40px; height: 40px; border-radius: 13px; background: var(--card);
  box-shadow: var(--shadow); font-size: 17px; display: grid; place-items: center; flex: none;
}
.back-row h1 { font-size: 21px; font-weight: 800; line-height: 1.15; }
.back-row .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.back-row .grow { flex: 1; min-width: 0; }
.pill-btn {
  padding: 9px 15px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow);
  font-weight: 700; font-size: 13.5px; color: var(--green); flex: none;
}

/* ── hero (home) ── */
.hero {
  background: var(--grad); border-radius: var(--radius); padding: 20px;
  color: #fff; box-shadow: 0 10px 28px rgba(46, 158, 104, 0.30); margin-bottom: 20px;
  display: flex; gap: 16px; align-items: center;
}
.hero .left { flex: 1; min-width: 0; }
.hero .hi { font-size: 20px; font-weight: 800; }
.hero .date { font-size: 13px; opacity: 0.9; margin-top: 2px; font-weight: 500; }
.hero .msg { font-size: 13px; font-weight: 600; margin-top: 10px; opacity: 0.96; line-height: 1.35; }
.hero .stats { display: flex; gap: 16px; margin-top: 14px; }
.hero .stat b { display: block; font-size: 19px; font-weight: 800; line-height: 1; }
.hero .stat span { font-size: 11px; opacity: 0.9; font-weight: 500; }

/* goal ring */
.ring-wrap { position: relative; width: 108px; height: 108px; flex: none; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { stroke: rgba(255,255,255,0.25); }
.ring-fg { stroke: #fff; transition: stroke-dashoffset 0.8s cubic-bezier(.2,.8,.2,1); stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring-label b { display: block; font-size: 17px; font-weight: 800; line-height: 1.1; }
.ring-label span { font-size: 10px; opacity: 0.92; font-weight: 600; }

/* ── garden ── */
.section-title { font-size: 15px; font-weight: 800; margin: 4px 2px 12px; display: flex; justify-content: space-between; align-items: center; }
.section-title .hint { font-size: 12px; font-weight: 600; color: var(--muted); }
.garden { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.tree-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 10px 14px; text-align: center; position: relative; overflow: hidden;
}
.tree-card .sky { border-radius: 14px; background: linear-gradient(180deg, #EAF7FB 0%, #F2FAF3 78%, #E9F3E6 100%); }
.tree-card svg { display: block; width: 100%; height: auto; }
.tree-card .name { font-size: 14.5px; font-weight: 800; margin-top: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-card .meta { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.tree-card .today-chip {
  position: absolute; top: 9px; right: 9px; font-size: 10.5px; font-weight: 800;
  background: var(--grad); color: #fff; border-radius: 999px; padding: 3px 8px;
  box-shadow: 0 3px 10px rgba(46,158,104,0.35);
}
.plant-card {
  border: 2px dashed #BFDEC9; border-radius: var(--radius); display: grid; place-items: center;
  min-height: 168px; color: var(--muted); font-weight: 700; font-size: 14px; background: rgba(255,255,255,0.5);
}
.plant-card .plus { font-size: 30px; line-height: 1; color: var(--green); margin-bottom: 6px; }

/* empty garden */
.empty {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 22px; text-align: center; margin-bottom: 20px;
}
.empty .art { font-size: 44px; }
.empty h2 { font-size: 18px; font-weight: 800; margin: 10px 0 6px; }
.empty p { font-size: 13.5px; color: var(--muted); font-weight: 500; line-height: 1.45; }

/* today list */
.today-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 16px; margin-bottom: 20px; }
.today-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.today-row:last-child { border-bottom: none; }
.today-row .t-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-row .t-min { color: var(--green); font-weight: 800; }
.today-row .t-time { color: var(--muted); font-size: 12px; font-weight: 500; }

/* ── subject page ── */
.tree-stage {
  background: linear-gradient(180deg, #EAF7FB 0%, #F4FBF3 70%, #E9F3E6 100%);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 10px 0; margin-bottom: 14px;
  position: relative; overflow: hidden;
}
.tree-stage svg { display: block; width: 100%; height: auto; }
.tier-chip {
  position: absolute; top: 12px; left: 12px; background: rgba(255,255,255,0.85); backdrop-filter: blur(4px);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 800; color: var(--deep);
  box-shadow: 0 3px 12px rgba(46,158,104,0.15);
}
.milestone { text-align: center; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 14px; }
.milestone b { color: var(--green); }

.grow-btn {
  display: block; width: 100%; background: var(--grad); color: #fff; border-radius: var(--radius);
  padding: 18px; font-size: 18px; font-weight: 800; box-shadow: 0 10px 28px rgba(46,158,104,0.35);
  margin-bottom: 16px; transition: transform 0.15s;
}
.grow-btn:active { transform: scale(0.97); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.stat-box { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 4px; text-align: center; }
.stat-box b { display: block; font-size: 16px; font-weight: 800; color: var(--green); line-height: 1.15; }
.stat-box span { font-size: 10.5px; font-weight: 600; color: var(--muted); }

.sess-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 16px; margin-bottom: 20px; }
.sess-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.sess-row:last-child { border-bottom: none; }
.sess-row .s-date { color: var(--muted); font-weight: 500; width: 62px; flex: none; }
.sess-row .s-min { color: var(--green); font-weight: 800; flex: 1; }
.sess-row .s-slips { color: var(--amber); font-size: 12px; }

/* ── focus mode ── */
.focus { text-align: center; }
.focus .f-subject { font-size: 15px; font-weight: 800; color: var(--muted); margin-bottom: 2px; }
.focus .f-timer { font-size: 56px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.focus .f-state { font-size: 13px; font-weight: 700; color: var(--green); min-height: 20px; margin-top: 2px; }
.focus .f-state.paused { color: var(--amber); }
.focus .tree-stage { margin-top: 14px; }
.focus .f-live { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 10px 0 16px; }
.focus .f-live b { color: var(--green); }
.f-controls { display: flex; gap: 10px; margin-bottom: 12px; }
.f-btn {
  flex: 1; padding: 16px; border-radius: 18px; font-size: 16px; font-weight: 800;
  background: var(--card); box-shadow: var(--shadow); color: var(--ink);
}
.f-btn.primary { background: var(--grad); color: #fff; box-shadow: 0 10px 24px rgba(46,158,104,0.35); }
.f-btn.warn { color: var(--amber); }
.f-discard { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 8px; }
.slips { font-size: 12.5px; font-weight: 700; color: var(--amber); margin-top: 4px; min-height: 18px; }

/* away overlay (strict pause) */
.away {
  position: fixed; inset: 0; background: rgba(36, 53, 43, 0.92); z-index: 40;
  display: grid; place-items: center; color: #fff; text-align: center; padding: 30px;
}
.away .a-emoji { font-size: 52px; }
.away h2 { font-size: 21px; font-weight: 800; margin: 12px 0 8px; }
.away p { font-size: 14px; opacity: 0.85; font-weight: 500; line-height: 1.5; margin-bottom: 22px; }
.away button {
  background: var(--grad); color: #fff; font-weight: 800; font-size: 16px;
  padding: 15px 34px; border-radius: 999px; box-shadow: 0 10px 24px rgba(46,158,104,0.5);
}

/* dim (battery saver during long sessions) */
.dim {
  position: fixed; inset: 0; background: #0B1410; z-index: 50; display: grid; place-items: center;
  opacity: 0; transition: opacity 0.8s; cursor: pointer;
}
.dim[hidden] { display: none; } /* author display would otherwise beat the hidden attr and eat every tap */
.dim.on { opacity: 1; }
.dim-inner { text-align: center; color: #9DC3AA; }
.dim-time { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; color: #CFE8D8; }
.dim-hint { font-size: 12.5px; font-weight: 600; margin-top: 10px; opacity: 0.7; }

/* ── forms (plant / edit / settings) ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.field-label { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 7px; display: block; }
.text-input {
  width: 100%; padding: 14px 16px; border-radius: 15px; border: 2px solid var(--line);
  font-size: 16px; font-weight: 600; background: var(--bg); outline: none;
}
.text-input:focus { border-color: var(--leaf); }
.btn-main {
  display: block; width: 100%; background: var(--grad); color: #fff; border-radius: 17px;
  padding: 16px; font-size: 16px; font-weight: 800; box-shadow: 0 8px 22px rgba(46,158,104,0.3); margin-top: 14px;
}
.btn-ghost { display: block; width: 100%; text-align: center; padding: 13px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.btn-danger { color: #D65C5C; }

/* goal stepper */
.stepper { display: flex; align-items: center; gap: 14px; justify-content: center; }
.stepper button {
  width: 52px; height: 52px; border-radius: 17px; background: var(--grad-soft);
  font-size: 24px; font-weight: 800; color: var(--green);
}
.stepper .val { font-size: 26px; font-weight: 800; min-width: 110px; text-align: center; }

/* toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-row .t-text b { display: block; font-size: 15px; font-weight: 800; }
.toggle-row .t-text span { font-size: 12.5px; color: var(--muted); font-weight: 500; line-height: 1.4; display: block; margin-top: 3px; }
.switch { position: relative; width: 54px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; z-index: 2; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0; background: #D9E8DD; border-radius: 999px; transition: background 0.25s;
}
.switch .knob::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,0.18); transition: transform 0.25s;
}
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { transform: translateX(22px); }

.note { font-size: 12.5px; color: var(--muted); font-weight: 500; line-height: 1.5; }

/* ── toast ── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  padding: 12px 20px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 60; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}

/* leaf confetti canvas */
.leaves { position: fixed; inset: 0; z-index: 55; pointer-events: none; }

/* ── tree sway animation ── */
@keyframes sway { from { transform: rotate(-0.7deg); } to { transform: rotate(0.9deg); } }
@keyframes swayHi { from { transform: rotate(-1.1deg); } to { transform: rotate(1.3deg); } }
.sway { animation: sway 5.5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.sway-hi { animation: swayHi 4s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes popIn { from { transform: scale(0.92); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
.tree-pop { animation: popIn 0.5s cubic-bezier(.2,.8,.2,1); transform-box: fill-box; transform-origin: 50% 100%; }

@media (prefers-reduced-motion: reduce) {
  .sway, .sway-hi, .tree-pop { animation: none; }
}

/* device-key lock (same as lifts) */
.lock { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 82vh; text-align: center; }
.lock-heart { font-size: 34px; margin-bottom: 10px; }
.lock-title { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.lock-title .heart { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lock-sub { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 8px; min-height: 20px; }
.lock-sub.err { color: var(--blush); }
.pin-dots { display: flex; gap: 16px; margin: 26px 0 30px; }
.pin-dot { width: 15px; height: 15px; border-radius: 50%; border: 2.5px solid #BFE0C9; box-sizing: border-box; transition: all 0.15s; }
.pin-dot.filled { background: var(--grad); border-color: transparent; transform: scale(1.12); }
.pin-dots--key { gap: 7px; }
.pin-dots--key .pin-dot { width: 12px; height: 12px; }
.pin-dots--key .pin-dot:nth-child(4n):not(:last-child) { margin-right: 10px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 74px); gap: 16px; justify-content: center; }
.pin-key {
  width: 74px; height: 74px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow);
  font-size: 27px; font-weight: 700; color: var(--ink); display: grid; place-items: center;
}
.pin-key:active { background: var(--grad-soft); }
.pin-key.ghost { background: transparent; box-shadow: none; pointer-events: none; }
