/* Autark Portal — phone-first styling.
   Calm, warm, dark. Big tap targets. Reads as a home-screen app, not a form.
   No framework; everything here is hand-tuned for one thumb on one phone. */

:root {
  --bg: #14110f;          /* warm near-black */
  --card: #201a16;        /* raised surface */
  --card-hi: #2b231d;     /* pressed / accented surface */
  --line: #3a2f27;        /* hairline borders */
  --text: #f3ede7;        /* primary text */
  --muted: #a89a8d;       /* secondary text */
  --accent: #e0794b;      /* terracotta — the one warm signal colour */
  --accent-soft: #7c4227; /* accent, dimmed for fills */
  --good: #8bb87a;        /* streak / positive */
  --radius: 20px;
  --tap: 0.12s ease;
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* leave room for the fixed tab bar + phone safe areas */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           calc(76px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* --- headers --- */
.topbar { display: flex; align-items: baseline; justify-content: space-between; padding: 24px 20px 8px; }
.topbar h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin: 0; }
.date { color: var(--muted); font-size: 15px; }

/* --- log tiles --- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 12px 16px; }
.tile {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  color: var(--text);
  font: inherit; cursor: pointer;
  transition: transform var(--tap), background var(--tap);
}
.tile:active { transform: scale(0.96); background: var(--card-hi); }
.tile .glyph { font-size: 34px; line-height: 1; color: var(--accent); }
.tile .label { font-size: 17px; font-weight: 600; }
/* today's tally badge, top-right of each tile */
.tile .badge {
  position: absolute; top: 12px; right: 14px;
  font-size: 13px; color: var(--muted);
}
.tile .badge.on { color: var(--good); }

/* --- progress view --- */
.neglect {
  margin: 8px 16px 4px; padding: 16px 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 16px;
}
.neglect .up { color: var(--accent); font-weight: 600; }
.neglect .all-good { color: var(--good); font-weight: 600; }

.cards { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: center; justify-content: space-between;
}
.card .left { display: flex; align-items: center; gap: 14px; }
.card .glyph { font-size: 24px; color: var(--accent); width: 28px; text-align: center; }
.card .name { font-size: 17px; font-weight: 600; }
.card .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card .streak { font-size: 15px; color: var(--good); font-weight: 600; white-space: nowrap; }
.card .streak.cold { color: var(--muted); }

/* --- entry sheet --- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; z-index: 50;
}
.sheet {
  width: 100%; background: var(--card);
  border-radius: 24px 24px 0 0; border-top: 1px solid var(--line);
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  animation: rise 0.18s ease;
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }
.sheet h2 { margin: 0 0 16px; font-size: 22px; }

.presets { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.chip {
  flex: 1 1 auto; min-width: 72px;
  padding: 16px 12px; border-radius: 14px;
  background: var(--card-hi); border: 1px solid var(--line); color: var(--text);
  font: inherit; font-size: 18px; font-weight: 600; cursor: pointer;
  transition: transform var(--tap), background var(--tap);
}
.chip:active { transform: scale(0.94); background: var(--accent-soft); border-color: var(--accent); }
.chip.done { flex-basis: 100%; background: var(--accent-soft); border-color: var(--accent); color: #fff; }

.entry-form { display: flex; flex-direction: column; gap: 12px; }
.entry-input, .entry-note {
  width: 100%; padding: 16px; border-radius: 14px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font: inherit; font-size: 18px;
}
.entry-input::placeholder, .entry-note::placeholder { color: var(--muted); }

.sheet-actions { display: flex; gap: 12px; margin-top: 4px; }
.btn { flex: 1; padding: 16px; border-radius: 14px; font: inherit; font-size: 17px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.primary { background: var(--accent); color: #1a0f08; border-color: var(--accent); }
.btn:active { transform: scale(0.97); }

/* --- toast --- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--good); color: #10240a; font-weight: 600;
  padding: 12px 22px; border-radius: 999px; z-index: 60;
  animation: pop 0.2s ease;
}
.toast.err { background: var(--accent); color: #1a0f08; }
.toast .undo { background: none; border: none; color: inherit; font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0 2px 0 6px; }

/* While a save is in flight: dim + disable the tap targets so nothing double-fires. */
.sheet.saving .chip, .sheet.saving .btn.primary { opacity: 0.5; pointer-events: none; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* --- bottom tab bar --- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: rgba(20,17,15,0.92);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; padding: 18px 0; background: none; border: none;
  color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.tab.active { color: var(--accent); }
