:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --green-light: #e8f5e9;
  --neg: #c62828;
  --pos: #2e7d32;
  --warn: #e65100;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --bg: #f6f7f6;
  --card: #ffffff;
  --line: #e5e7eb;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  background: var(--green);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.net-status { font-size: 12px; color: #a5d6a7; }
.net-status.is-offline { color: #ffcc80; }

.view { flex: 1; overflow-y: auto; padding: 18px 16px 90px; }
.screen[hidden] { display: none; }

/* Compact horizontal wait row */
.wait-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 18px; margin-bottom: 6px;
}
.wait-row-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .07em; }
.wait-row-value { font-size: 30px; font-weight: 800; color: var(--green-dark); font-variant-numeric: tabular-nums; }
.wait-row-value.has-wait { color: var(--warn); }
.cushion-tag { font-size: 13px; font-weight: 600; color: var(--green-dark); }

/* Two-across behavior tiles */
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
  display: flex; align-items: center; gap: 8px; width: 100%; cursor: pointer; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 11px;
  font-size: 14px; color: var(--ink);
}
.tile:active { transform: scale(.98); }
.tile:disabled { opacity: .5; }
.tile-bar { width: 4px; height: 18px; border-radius: 2px; flex: none; }
.tile.neg .tile-bar { background: var(--neg); }
.tile.pos .tile-bar { background: var(--pos); }
.tile-label { flex: 1; min-width: 0; }
.tile-val { font-weight: 800; font-variant-numeric: tabular-nums; }
.tile.neg .tile-val { color: var(--neg); }
.tile.pos .tile-val { color: var(--pos); }

.screen-title { font-size: 18px; font-weight: 700; margin: 4px 0 14px; }

.placeholder-note { margin-top: 18px; color: var(--muted); font-size: 13px; font-style: italic; }
.empty { color: var(--muted); font-size: 14px; font-style: italic; padding: 4px 2px; }

/* Recent activity (Today) */
.recent { margin-top: 24px; }
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: 15px;
}
.recent-row.neg { border-left: 4px solid var(--neg); }
.recent-row.pos { border-left: 4px solid var(--pos); }
.r-label { font-weight: 600; }
.r-meta { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.r-delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.recent-row.neg .r-delta { color: var(--neg); }
.recent-row.pos .r-delta { color: var(--pos); }
.r-time { color: var(--muted); font-size: 12px; }

/* Behavior buttons (Log) */
.behavior-list { display: flex; flex-direction: column; gap: 18px; }
.b-group { display: flex; flex-direction: column; gap: 10px; }
.b-group-title {
  margin: 14px 2px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.b-group-title.neg { color: var(--neg); }
.b-group-title.pos { color: var(--pos); }
.b-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; font-size: 16px; font-weight: 600; color: var(--ink);
}
.b-btn:active { transform: scale(.99); }
.b-btn:disabled { opacity: .5; }
.b-btn.neg { border-left: 5px solid var(--neg); }
.b-btn.pos { border-left: 5px solid var(--pos); }
.b-label { margin-right: 12px; }
.b-wait { font-variant-numeric: tabular-nums; font-weight: 800; }
.b-btn.neg .b-wait { color: var(--neg); }
.b-btn.pos .b-wait { color: var(--pos); }

/* Export button */
.export-btn {
  width: 100%; margin-top: 18px; cursor: pointer;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-size: 14px; font-weight: 600;
}
.export-btn:active { transform: scale(.99); }

/* Quiet-time CTA + view */
.quiet-cta {
  width: 100%; margin-top: 14px; cursor: pointer;
  background: var(--green); color: #fff; border: none;
  border-radius: 14px; padding: 16px; font-size: 17px; font-weight: 700;
}
.quiet-cta:active { transform: scale(.99); }

.back-btn {
  background: none; border: none; color: var(--green); cursor: pointer;
  font-size: 15px; font-weight: 600; padding: 4px 0; margin-bottom: 10px;
}
.quiet-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 36px 22px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.quiet-headline { margin: 0; font-size: 20px; font-weight: 700; color: var(--green-dark); }
.quiet-wait { margin: 14px 0 6px; font-size: 56px; font-weight: 800; line-height: 1; color: var(--ink); }
.quiet-sub { margin: 6px 0 0; font-size: 16px; color: var(--muted); }
.quiet-timer {
  margin: 18px 0 0; font-size: 64px; font-weight: 800;
  font-variant-numeric: tabular-nums; color: var(--green-dark);
}
.quiet-start {
  margin-top: 22px; width: 100%; cursor: pointer;
  background: var(--green); color: #fff; border: none;
  border-radius: 14px; padding: 16px; font-size: 17px; font-weight: 700;
}
.quiet-start:active { transform: scale(.99); }

/* History list */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.hist-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.hist-row.neg { border-left: 4px solid var(--neg); }
.hist-row.pos { border-left: 4px solid var(--pos); }
.h-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.h-label { font-weight: 600; font-size: 15px; }
.h-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.h-delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.hist-row.neg .h-delta { color: var(--neg); }
.hist-row.pos .h-delta { color: var(--pos); }
.h-undo {
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.h-undo:active { transform: scale(.97); }
.h-undo:disabled { opacity: .5; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 20;
  background: #263238; color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  max-width: 90vw;
}
.toast[hidden] { display: none; }
.toast.pos { background: var(--green-dark); }
.toast.neg { background: var(--neg); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none;
  padding: 14px 0; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.tab.is-active { color: var(--green); }
