/* spine.css — visual identity PORTED from the prototype (field_test_log.html),
   per §4: moss-green ink on cream, monospace, ink-bordered cards. Not a redesign. */

:root {
  --bg: #f8f3e4;
  --card: #fffdf3;
  --ink: #37503b;
  --muted: #8b8a72;
  --line: #ddd6bb;
  --accent: #5d9d61;
  --terra: #c96a4b;
  --alert: #bb4733;
  --chip: #f1ecd8;

  /* tier colors (month view later uses the same for its dots) */
  --tier1: var(--accent);
  --tier2: var(--terra);
  --tier-anchor: var(--muted);

  --header-h: 52px;
  --nav-h: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Courier New", monospace;
}
body { max-width: 480px; margin: 0 auto; }
button { font-family: inherit; cursor: pointer; }

/* ================= HOME SCREEN (phone-framed 16-bit house) ================= */
#home { position: relative; min-height: 100vh; overflow: hidden; background: #e9e6d3; }

/* the pixel-art house wallpaper (kept crisp; parallax nudged from JS) */
#houseWall {
  position: fixed; inset: 0; max-width: 480px; margin: 0 auto; z-index: 0;
  background: #e9e6d3 url('../assets/home-house.png') no-repeat center top;
  background-size: cover; image-rendering: pixelated;
  transform: scale(1.06); transform-origin: center top; will-change: transform;
}
/* legibility fades top & bottom so the glass UI reads over the busy art */
#homeVignette {
  position: fixed; inset: 0; max-width: 480px; margin: 0 auto; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(45,55,40,.55) 0%, rgba(45,55,40,0) 22%),
    linear-gradient(0deg, rgba(45,55,40,.62) 0%, rgba(45,55,40,0) 34%);
}
/* subtle retro CRT scanlines */
#scanlines {
  position: fixed; inset: 0; max-width: 480px; margin: 0 auto; z-index: 2; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.05) 0 1px, transparent 1px 3px);
}
/* drifting pollen particles */
#particles { position: fixed; inset: 0; max-width: 480px; margin: 0 auto; z-index: 2; pointer-events: none; overflow: hidden; }
#particles span {
  position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255, 250, 220, .85); box-shadow: 0 0 4px rgba(255, 245, 200, .8);
  animation: floatUp linear infinite;
}
#particles span:nth-child(1) { left: 8%;  animation-duration: 15s; animation-delay: -2s; }
#particles span:nth-child(2) { left: 22%; animation-duration: 19s; animation-delay: -8s; }
#particles span:nth-child(3) { left: 37%; animation-duration: 13s; animation-delay: -5s; }
#particles span:nth-child(4) { left: 51%; animation-duration: 21s; animation-delay: -1s; }
#particles span:nth-child(5) { left: 63%; animation-duration: 17s; animation-delay: -11s; }
#particles span:nth-child(6) { left: 74%; animation-duration: 14s; animation-delay: -6s; }
#particles span:nth-child(7) { left: 86%; animation-duration: 20s; animation-delay: -3s; }
#particles span:nth-child(8) { left: 93%; animation-duration: 16s; animation-delay: -9s; }
@keyframes floatUp {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: .9; }
  90% { opacity: .9; }
  100% { transform: translateY(-102vh) translateX(14px); opacity: 0; }
}

#homeInner {
  position: relative; z-index: 3; min-height: 100vh;
  display: flex; flex-direction: column; padding: 0 14px 28px;
}

/* phone-style status bar */
#statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px 0; color: #fdf9ec; text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.sb-title { font-size: 13px; font-weight: 800; letter-spacing: 3px; }
#sbClock { font-size: 13px; font-weight: 700; letter-spacing: 1px; }

/* frosted-glass schedule widget — the daily driver, floated over the house */
#scheduleWidget {
  display: block; width: 100%; margin: 14px 0 auto; text-align: left; color: var(--ink);
  background: rgba(255, 253, 243, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 2px solid var(--ink); border-radius: 18px; padding: 15px;
  box-shadow: 0 6px 22px rgba(30, 40, 28, .35); transition: transform .15s;
}
#scheduleWidget:active { transform: scale(.985); }
.widget-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.widget-date .wd-weekday { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; color: var(--muted); }
.widget-date .wd-big { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -2px; }
.widget-date .wd-month { font-size: 13px; font-weight: 600; }
.widget-sprout { width: 56px; height: 56px; flex: none; animation: bob 4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.widget-list { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.widget-untimed {
  align-self: flex-start; font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted); background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
}
.widget-row {
  display: flex; gap: 10px; align-items: baseline; padding: 5px 8px;
  border-left: 4px solid var(--tier-anchor); background: rgba(248, 243, 228, .8); border-radius: 6px;
}
.widget-row.tier-1 { border-left-color: var(--tier1); }
.widget-row.tier-2 { border-left-color: var(--tier2); }
.widget-row .wr-t { font-size: 11px; color: var(--muted); flex: none; width: 62px; }
.widget-row .wr-n { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-more, .widget-empty { font-size: 11px; color: var(--muted); font-style: italic; padding: 2px 8px; }
.widget-open { margin-top: 12px; text-align: right; font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .5px; }

/* room selector — Gym live (glowing), the rest greyed & locked */
#homeRooms { margin-top: 18px; }
.rooms-label {
  font-size: 10px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase;
  color: #fdf9ec; text-shadow: 0 1px 3px rgba(0,0,0,.5); margin: 0 2px 8px;
}
#roomGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.room-tile {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px; border-radius: 14px; color: var(--ink);
  background: rgba(255, 253, 243, .8); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  border: 2px solid var(--ink); box-shadow: 0 4px 12px rgba(30, 40, 28, .28); transition: transform .15s;
}
.room-tile .room-icon { width: 24px; height: 24px; }
.room-tile .room-name { font-size: 13px; font-weight: 700; }
.room-tile .room-sub { font-size: 8.5px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700; }
.room-tile.live { border-color: var(--accent); animation: liveGlow 2.4s ease-in-out infinite; }
.room-tile.live .room-icon { color: var(--accent); }
.room-tile.live .room-sub { color: var(--accent); }
.room-tile.live:active { transform: scale(.95); }
@keyframes liveGlow {
  0%, 100% { box-shadow: 0 4px 12px rgba(30,40,28,.28), 0 0 0 rgba(93,157,97,0); }
  50% { box-shadow: 0 4px 12px rgba(30,40,28,.28), 0 0 14px rgba(93,157,97,.7); }
}
.room-tile.soon {
  background: rgba(226, 222, 205, .72); border-color: rgba(55, 80, 59, .35);
  color: var(--muted); box-shadow: none; cursor: default;
}
.room-tile.soon .room-icon { color: var(--muted); opacity: .7; }
.room-tile.soon .room-sub { color: var(--muted); font-weight: 400; }

@media (prefers-reduced-motion: reduce) {
  #particles { display: none; }
  .widget-sprout, .room-tile.live { animation: none; }
}

/* corner mini-phone = the home button (the only nav element) */
#homeBtn {
  position: fixed; right: 16px; bottom: 18px; z-index: 25;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--card); border: 1.5px solid var(--ink); color: var(--ink);
  box-shadow: 3px 3px 0 rgba(55, 80, 59, .18);
  align-items: center; justify-content: center; transition: transform .15s;
}
#homeBtn:not([hidden]) { display: flex; } /* id-specific display must not override [hidden] */
#homeBtn:active { transform: scale(.9); }

/* room placeholder toast (no room screens in the spine) */
#roomNote {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px);
  max-width: 300px; z-index: 26; background: var(--ink); color: var(--card);
  padding: 10px 14px; border-radius: 12px; font-size: 12px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#roomNote.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* ---------- header (sticky, prototype idiom) ---------- */
header {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  border-bottom: 1.5px solid var(--ink);
  height: var(--header-h); padding: 0 12px;
  display: flex; align-items: center; gap: 8px;
}
header #dayLabel { flex: 1; text-align: center; font-size: 13px; font-weight: 700; letter-spacing: .5px; }

/* sliding 12h/24h toggle (occupies the old logo slot) */
.fmttoggle {
  position: relative; flex: none; display: inline-flex; padding: 2px;
  width: 76px; height: 30px; border: 1.5px solid var(--ink); border-radius: 999px;
  background: var(--card); transition: transform .15s;
}
.fmttoggle:active { transform: scale(.95); }
.fmttoggle .opt {
  position: relative; z-index: 1; flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--muted); transition: color .18s;
}
.fmttoggle .knob {
  position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc(50% - 2px);
  border-radius: 999px; background: var(--ink); transition: left .18s ease;
}
.fmttoggle[data-fmt="24h"] .knob { left: calc(50%); }
.fmttoggle[data-fmt="12h"] .opt:first-of-type,
.fmttoggle[data-fmt="24h"] .opt:last-of-type { color: var(--card); }
header .nav button {
  border: 1.5px solid var(--ink); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; transition: transform .15s;
}
header .nav button:active { transform: scale(.95); }
header .nav button.today { font-weight: 700; }

/* ---------- view switcher (Day / Week / Month expanders) ---------- */
#viewNav {
  position: sticky; top: var(--header-h); z-index: 16;
  display: flex; gap: 6px; padding: 7px 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
#viewNav button {
  flex: 1; border: 1.5px solid var(--ink); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 7px 4px; font-size: 12px; letter-spacing: .3px; transition: transform .15s;
}
#viewNav button:active { transform: scale(.96); }
#viewNav button.on { background: var(--ink); color: var(--card); font-weight: 700; }

/* ---------- untimed tray (sticky, pinned to the top of the day) ---------- */
#tray {
  position: sticky; top: calc(var(--header-h) + var(--nav-h)); z-index: 15;
  background: var(--chip); border-bottom: 1.5px solid var(--ink);
  padding: 8px 12px;
  display: none;
}
#tray.has-items { display: block; }
#tray .traylabel {
  font-size: 9px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
#tray .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.uchip {
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  box-shadow: 2px 2px 0 rgba(55, 80, 59, .12);
  border-left: 5px solid var(--tier-anchor);
}
.uchip.tier-1 { border-left-color: var(--tier1); }
.uchip.tier-2 { border-left-color: var(--tier2); }
.uchip .floor { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }

/* ---------- true timeline ---------- */
#timeline { position: relative; margin: 0 8px 24px; }
.hourline { position: absolute; left: 44px; right: 0; border-top: 1px solid var(--line); }
.hourlabel {
  position: absolute; left: 0; width: 40px; text-align: right;
  font-size: 10px; color: var(--muted); transform: translateY(-55%);
}

.tblock {
  position: absolute; overflow: hidden;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 10px;
  border-left-width: 5px; border-left-color: var(--tier-anchor);
  box-shadow: 2px 2px 0 rgba(55, 80, 59, .12);
  padding: 3px 8px; font-size: 12px;
}
.tblock.tier-1 { border-left-color: var(--tier1); }
.tblock.tier-2 { border-left-color: var(--tier2); }
.tblock .nm { font-weight: 700; line-height: 1.25; }
.tblock .tm { font-size: 10px; color: var(--muted); }
.tblock .floor { font-size: 10px; color: var(--muted); font-style: italic; }

.tag {
  display: inline-block; font-size: 8.5px; font-weight: 700; letter-spacing: .5px;
  border-radius: 4px; padding: 0 4px; margin-left: 5px; vertical-align: 1px;
}
.tag.neverskip { background: var(--terra); color: #fff; }
.tag.oneoff { border: 1px solid var(--accent); color: var(--accent); }
.tag.diverged { border: 1px solid var(--muted); color: var(--muted); }

/* passive overlap warning — flag only, no resolution flow */
.tblock.overlap { border-color: var(--alert); border-style: dashed; border-left-style: solid; }
.tblock .warn { font-size: 10px; color: var(--alert); font-weight: 700; }

/* now line (only rendered when viewing today) */
#nowline { position: absolute; left: 40px; right: 0; border-top: 2px solid var(--terra); z-index: 5; }
#nowline::before {
  content: ''; position: absolute; left: -4px; top: -5px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--terra);
}

.emptyday {
  margin: 24px 12px; padding: 14px; text-align: center;
  color: var(--muted); font-size: 12px;
  border: 1.5px dashed var(--line); border-radius: 14px;
}

/* blocks + chips are tappable (opens the form — the form IS the block-detail view) */
.tblock, .uchip { cursor: pointer; }

/* ---------- WEEK view (list) ---------- */
#weekView { padding: 8px 12px 32px; }
.weekday-sec { margin-bottom: 14px; }
.weekday-head {
  position: sticky; top: calc(var(--header-h) + var(--nav-h)); z-index: 5;
  display: flex; align-items: baseline; gap: 8px; width: 100%;
  background: var(--bg); border: none; border-bottom: 1.5px solid var(--ink);
  padding: 6px 2px 5px; text-align: left; color: var(--ink);
}
.weekday-head .wd-name { font-size: 13px; font-weight: 800; letter-spacing: .5px; }
.weekday-head .wd-date { font-size: 11px; color: var(--muted); }
.weekday-head.is-today .wd-name { color: var(--accent); }
.weekday-head.is-today::after { content: 'today'; font-size: 9px; color: var(--accent); font-weight: 700; margin-left: auto; }

.week-untimed { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 7px 0 3px; }
.week-untimed .wu-label {
  font-size: 8.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}
.wu-chip {
  border: 1.5px solid var(--ink); background: var(--chip); color: var(--ink);
  border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 600;
  border-left: 4px solid var(--tier-anchor);
}
.wu-chip.tier-1 { border-left-color: var(--tier1); }
.wu-chip.tier-2 { border-left-color: var(--tier2); }

.week-empty { padding: 8px 2px; color: var(--muted); font-size: 11px; font-style: italic; }

.weekrow {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--tier-anchor);
  border-radius: 8px; padding: 8px 10px; margin-top: 6px; color: var(--ink);
}
.weekrow.tier-1 { border-left-color: var(--tier1); }
.weekrow.tier-2 { border-left-color: var(--tier2); }
.weekrow.overlap { border-color: var(--alert); }
.weekrow .wr-time { flex: none; width: 96px; font-size: 11px; color: var(--muted); padding-top: 1px; }
.weekrow .wr-body { flex: 1; min-width: 0; }
.weekrow .wr-name { font-size: 13px; font-weight: 600; }
.weekrow .wr-warn { display: block; font-size: 10px; color: var(--alert); font-weight: 700; }

/* ---------- MONTH view (dot-grid) ---------- */
#monthView { padding: 10px 10px 32px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-wd {
  text-align: center; font-size: 10px; font-weight: 700; color: var(--muted);
  padding-bottom: 2px; letter-spacing: .5px;
}
.month-cell {
  aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 10px;
  padding: 5px 2px 3px; color: var(--ink);
}
.month-cell:active { transform: scale(.96); }
.month-cell.out { background: #faf8ef; border-color: var(--line); color: var(--muted); }
.month-cell.is-today { border-color: var(--accent); border-width: 2px; }
.month-cell .mc-day { font-size: 12px; font-weight: 700; }
.month-cell.is-today .mc-day { color: var(--accent); }
.mc-dots { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; align-content: flex-start; }
.mc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tier-anchor); }
.mc-dot.tier-1 { background: var(--tier1); }
.mc-dot.tier-2 { background: var(--tier2); }
.mc-more { font-size: 8px; color: var(--muted); line-height: 6px; }

/* header "+" (new block) */
header .nav button.add { font-weight: 800; }

/* ---------- form sheet (ported prototype idiom: #shade / #sheet) ---------- */
#shade {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30;
  display: none;
}
#shade.open { display: block; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: -110%; max-width: 480px; margin: 0 auto;
  z-index: 31; background: var(--card); border: 1.5px solid var(--ink); border-bottom: none;
  border-radius: 18px 18px 0 0; padding: 16px 16px 24px;
  transition: bottom .18s ease; box-shadow: 0 -4px 24px rgba(0, 0, 0, .18);
  max-height: 82vh; overflow-y: auto;
}
#sheet.open { bottom: 0; }
#sheet h3 { margin: 0 0 10px; font-size: 14px; }

.field { margin-bottom: 10px; }
.flabel {
  display: block; font-size: 9px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
#sheet input[type=text], #sheet input[type=date] {
  width: 100%; padding: 9px 10px; border: 1.5px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 13px; background: var(--card); color: var(--ink);
}
#sheet input:focus { outline: none; border-color: var(--ink); }
#sheet .inline { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
#sheet .inline .sep { color: var(--muted); font-size: 12px; white-space: nowrap; }
#sheet .inline input { flex: 1; min-width: 0; }

.chiprow { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip {
  border: 1.5px solid var(--line); background: var(--chip); color: var(--ink);
  border-radius: 999px; padding: 7px 12px; font-size: 12px;
}
.fchip.sel { border-color: var(--accent); border-width: 2px; background: #eaf2e2; font-weight: 700; }
.fchip.day { min-width: 38px; padding: 7px 0; text-align: center; }
.fchip.swatch { width: 34px; height: 30px; padding: 0; }
.fchip.swatch.sel { outline: 2px solid var(--ink); outline-offset: 1px; }

.check { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.rules { gap: 16px; }

.hint { font-size: 11px; color: var(--muted); margin: -4px 0 10px; }
.hint.alertline { color: var(--alert); margin-top: 8px; }
.formerr { font-size: 12px; color: var(--alert); min-height: 16px; margin: 4px 0; }

.sheetactions { display: flex; gap: 8px; margin-top: 12px; }
.sheetactions .primary, .scopeopts .primary {
  flex: 1; min-height: 46px; border: none; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 700;
}
.sheetactions .ghost, .scopeopts .ghost {
  flex: 1; min-height: 46px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--muted); font-size: 14px;
}
.scopeopts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.confirmmsg { font-size: 14px; margin: 4px 0 4px; line-height: 1.4; }
.sheetactions.secondary { margin-top: 8px; }

/* time combo: typable input + scrollable half-hour dropdown */
.tcombo { position: relative; flex: 1; min-width: 0; }
.tcombo input { width: 100%; }
.tdrop {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 40;
  max-height: 168px; overflow-y: auto;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 10px;
  box-shadow: 2px 3px 0 rgba(55, 80, 59, .15);
}
.tdrop.open { display: block; }
.topt {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 7px 12px; font-size: 13px; color: var(--ink); border-bottom: 1px solid var(--line);
}
.topt:last-child { border-bottom: none; }
.topt:hover, .topt:focus { background: var(--chip); }
.sheetactions .ghost.danger { color: var(--alert); border-color: var(--alert); }
.scopeopts .primary.danger, .sheetactions .primary.danger { background: var(--alert); }
