/* ============================================================
   Duskloom — Bedside Lamp Routine Rail
   Dusk-blue single-column mobile theme. No remote assets.
   ============================================================ */

:root {
  --bg-0: #1d2438;
  --bg-1: #2e3a59;
  --bg-2: #262f4c;
  --card: #39456a;
  --card-hi: #44507a;
  --ink: #f3ecdd;
  --ink-dim: #aab4d0;
  --line: rgba(232, 220, 198, 0.16);
  --amber: #e3a24a;
  --amber-deep: #b57f33;
  --amber-soft: rgba(227, 162, 74, 0.16);
  --sage: #9db89a;
  --rose: #d18f8f;
  --dusk: #8fa7d6;
  --danger: #e08a8a;
  --shadow: 0 10px 24px rgba(10, 14, 26, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 55%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.45;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
input { font: inherit; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(108px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Header ---------- */

.app-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 0 14px;
}
.head-moon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: inset -8px 4px 0 0 var(--amber);
  flex: none;
}
.app-title { font-size: 22px; letter-spacing: 0.5px; line-height: 1.2; }
.app-sub { font-size: 12.5px; color: var(--ink-dim); letter-spacing: 0.4px; }

/* ---------- Panel headings ---------- */

.panel-title { font-size: 18px; margin: 6px 0 2px; }
.panel-sub { font-size: 13px; color: var(--ink-dim); margin-bottom: 10px; }
.title-note {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-dim);
  margin-left: 6px;
}

/* ---------- Tonight: lamp-glow focus card ---------- */

.focus-card {
  margin-top: 6px;
  border-radius: 26px 26px 20px 20px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(227, 162, 74, 0.38), rgba(227, 162, 74, 0) 62%),
    linear-gradient(180deg, #45507a, #333d60);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px 18px 18px;
  text-align: center;
  cursor: pointer;
}
.focus-card:active { transform: translateY(1px); }
.focus-card.is-complete {
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(157, 184, 154, 0.22), rgba(157, 184, 154, 0) 62%),
    linear-gradient(180deg, #45507a, #333d60);
  cursor: default;
}
.lamp-shade {
  width: 118px;
  height: 30px;
  margin: 0 auto 4px;
  border-radius: 16px 16px 5px 5px;
  background: linear-gradient(180deg, var(--amber), var(--amber-deep));
  box-shadow: 0 0 26px 6px rgba(227, 162, 74, 0.35);
}
.is-complete .lamp-shade {
  background: linear-gradient(180deg, var(--sage), #6f8a6d);
  box-shadow: 0 0 20px 4px rgba(157, 184, 154, 0.25);
}
.lamp-stem {
  width: 10px;
  height: 12px;
  margin: 0 auto;
  background: rgba(232, 220, 198, 0.35);
  border-radius: 3px;
}
.lamp-base {
  margin: 10px auto 0;
  width: min(300px, 100%);
  background: linear-gradient(180deg, #4a3d29, #3a3021);
  border: 1px solid rgba(227, 162, 74, 0.35);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 12px;
}
.base-count { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 90px; }
.base-num { font-size: 22px; font-weight: 800; color: var(--amber); }
.is-complete .base-num { color: var(--sage); }
.base-label {
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #d8c9a8;
}
.base-stem { width: 1px; height: 32px; background: rgba(227, 162, 74, 0.4); }
.focus-kicker {
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--amber);
  margin-top: 14px;
}
.is-complete .focus-kicker { color: var(--sage); }
.focus-name { font-size: 24px; margin: 4px 0 2px; }
.focus-meta { color: var(--ink-dim); font-size: 13.5px; }
.focus-tap { margin-top: 10px; font-size: 12px; color: var(--amber); letter-spacing: 0.4px; }
.is-complete .focus-tap { color: var(--sage); }

/* ---------- Amber strip ---------- */

.amber-strip {
  display: block;
  width: 100%;
  margin: 14px 0 4px;
  padding: 15px;
  border-radius: 999px;
  background: var(--amber);
  color: #241a08;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 20px rgba(227, 162, 74, 0.28);
}
.amber-strip:active { transform: translateY(1px); }

/* ---------- Steps: phase groups + lamp-pull rows ---------- */

.phase-group { margin: 16px 0 6px; }
.phase-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 8px;
  padding-left: 2px;
}
.band-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.band-dusk { background: var(--dusk); }
.band-amber { background: var(--amber); }
.band-sage { background: var(--sage); }
.band-rose { background: var(--rose); }
.phase-count { margin-left: auto; font-size: 11px; letter-spacing: 0.5px; }

.pull-list { list-style: none; }
.pull-row {
  display: grid;
  grid-template-columns: 6px 48px minmax(0, 1fr) 42px auto;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 10px 10px 0;
  margin-bottom: 8px;
}
.band { align-self: stretch; border-radius: 14px 0 0 14px; min-height: 46px; }

.dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px;
  min-height: 46px;
  justify-content: center;
}
.dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--amber);
  background: transparent;
  transition: background 0.15s;
}
.is-done .dot { background: var(--amber); }
.dot-word { font-size: 9.5px; letter-spacing: 0.6px; color: var(--ink-dim); }
.is-done .dot-word { color: var(--amber); }

.row-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left; }
.row-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.is-done .row-name { color: var(--ink-dim); }
.row-phase { font-size: 12px; color: var(--ink-dim); }

.bead {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px dashed var(--line);
  background: var(--card-hi);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.row-actions { display: flex; flex-direction: column; gap: 5px; }
.mini-btn {
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.mini-danger { color: var(--danger); border-color: rgba(224, 138, 138, 0.4); }
.mini-btn:active { background: rgba(232, 220, 198, 0.08); }

/* ---------- Tonight: rest list ---------- */

.rail-heading {
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 18px 2px 8px;
}
.rest-list { list-style: none; }
.rest-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 7px;
}
.rest-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--amber); flex: none; }
.rest-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rest-meta { font-size: 12px; color: var(--ink-dim); flex: none; }
.rest-row:active { background: var(--card-hi); }

/* ---------- Add: bedside notebook form ---------- */

.notebook {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.field { margin-bottom: 14px; }
.field label, .field-label { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
.field input {
  width: 100%;
  font-size: 16px; /* prevents iOS zoom on focus */
  padding: 12px 14px;
  border-radius: 12px;
  background: #2c3654;
  border: 1.5px solid var(--line);
  color: var(--ink);
  appearance: textfield;
}
.field input:focus { outline: none; border-color: var(--amber); }
.field input.invalid { border-color: var(--danger); }
.field-error { font-size: 12.5px; color: var(--danger); margin-top: 5px; }
.field-row { display: flex; align-items: center; justify-content: space-between; }
.field-row .field-label { margin-bottom: 0; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn { border-radius: 12px; padding: 13px 18px; font-weight: 700; font-size: 15.5px; }
.btn-primary { background: var(--amber); color: #241a08; flex: 1; }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { border: 1.5px solid var(--line); color: var(--ink-dim); }

/* Done/Open toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #2c3654;
  border: 1.5px solid var(--line);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  flex: none;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-track { background: var(--amber-soft); border-color: var(--amber); }
.switch input:checked + .switch-track::after { transform: translateX(20px); background: var(--amber); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--amber); outline-offset: 2px; }
.switch-text { font-size: 13px; color: var(--ink-dim); min-width: 42px; }

/* ---------- Find: search-first index ---------- */

.find-box { margin: 8px 0 4px; }
.find-input {
  width: 100%;
  font-size: 16px;
  padding: 13px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--ink);
}
.find-input:focus { outline: none; border-color: var(--amber); }
.find-count { font-size: 12px; color: var(--ink-dim); margin: 6px 2px 10px; }

.find-list { list-style: none; }
.find-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 42px auto;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 10px;
  margin-bottom: 7px;
}
.find-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left; }
.find-name {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.is-done .find-name { color: var(--ink-dim); }
.find-phase { font-size: 11.5px; color: var(--ink-dim); }

.about {
  margin-top: 24px;
  border-top: 1px dashed var(--line);
  padding: 14px 2px 4px;
  font-size: 12.5px;
  color: var(--ink-dim);
}
.about h3 {
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 4px;
}
.about p { margin-bottom: 8px; }
.text-btn { color: var(--amber); text-decoration: underline; padding: 0; font-size: 12.5px; }

/* ---------- Empty state ---------- */

.empty-card {
  margin: 26px 0;
  padding: 30px 18px;
  text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: 20px;
  background: rgba(57, 69, 106, 0.5);
}
.empty-moon {
  display: block;
  width: 30px;
  height: 30px;
  margin: 0 auto 10px;
  border-radius: 50%;
  box-shadow: inset -9px 4px 0 0 var(--amber);
}
.empty-title { font-size: 18px; margin-bottom: 4px; }
.empty-sub { color: var(--ink-dim); font-size: 13.5px; margin-bottom: 14px; }

/* ---------- Bottom tab bar (lamp-pull cords) ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: rgba(24, 30, 48, 0.94);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  backdrop-filter: blur(8px);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 2px 6px;
  min-height: 58px;
  color: var(--ink-dim);
  border-radius: 12px;
}
.tab-label { font-size: 12px; letter-spacing: 0.4px; }
.cord {
  width: 2px;
  height: 16px;
  background: var(--line);
  border-radius: 2px;
  position: relative;
}
.cord::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}
.tab.is-active { color: var(--amber); }
.tab.is-active .cord {
  background: var(--amber);
  box-shadow: 0 0 10px 2px rgba(227, 162, 74, 0.5);
}
.tab.is-active .cord::after {
  background: var(--amber);
  box-shadow: 0 0 8px 2px rgba(227, 162, 74, 0.5);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  max-width: 488px;
  background: #20283f;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  z-index: 60;
}
.toast.show { opacity: 1; transform: none; }
