/* ============================================================
   Chalkline — Blueprint Clipboard Task Strip theme
   ============================================================ */
:root {
  --blue: #2f5d8a;
  --blue-deep: #25496d;
  --blue-ink: #22303f;
  --paper: #f4ede0;
  --cream: #f2e7d5;
  --orange: #f28c28;
  --orange-deep: #cf6f14;
  --err: #b3541e;
  --grid-line: rgba(47, 93, 138, 0.13);
  --grid-bold: rgba(47, 93, 138, 0.22);
  --shadow: 3px 4px 0 rgba(47, 93, 138, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif;
  color: var(--blue-ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-bold) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-bold) 1px, transparent 1px),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------- Rough-sawn header ---------------- */
.sawhead {
  background-color: var(--blue);
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  color: #fdf9f1;
  padding: calc(14px + env(safe-area-inset-top)) 16px 22px;
  clip-path: polygon(
    0 0, 100% 0, 100% calc(100% - 9px),
    94% 100%, 88% calc(100% - 7px), 82% calc(100% - 11px),
    76% 100%, 70% calc(100% - 6px), 64% calc(100% - 10px),
    58% 100%, 52% calc(100% - 7px), 46% calc(100% - 11px),
    40% 100%, 34% calc(100% - 6px), 28% calc(100% - 10px),
    22% 100%, 16% calc(100% - 8px), 10% calc(100% - 11px),
    5% 100%, 0 calc(100% - 8px)
  );
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-roller {
  flex: 0 0 auto;
  width: 40px; height: 26px;
  border-radius: 4px;
  background: var(--orange);
  border: 2px solid rgba(0, 0, 0, 0.15);
  position: relative;
  transform: rotate(-8deg);
}
.brand-roller::after {
  content: ""; position: absolute;
  left: 50%; bottom: -12px;
  width: 6px; height: 12px;
  transform: translateX(-50%) rotate(8deg);
  background: #fdf9f1;
}

.brand h1 {
  font-size: 1.55rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.1;
}
.brand-sub {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #cfe0f2;
  margin-top: 2px;
}

/* ---------------- Layout ---------------- */
#views { padding: 18px 16px calc(120px + env(safe-area-inset-bottom)); }

.view[hidden] { display: none; }

@media (min-width: 480px) {
  #views, .sawhead > .brand, .tabbar > .tabbar-inner { max-width: 560px; margin-left: auto; margin-right: auto; }
}

.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blue);
  margin: 20px 2px 8px;
}
#views > .kicker:first-child { margin-top: 0; }

/* ---------------- Tape-measure counters ---------------- */
.tape-row { display: flex; gap: 12px; }

.tape {
  flex: 1;
  background: var(--cream);
  border: 1.5px solid var(--blue);
  border-radius: 3px;
  padding: 8px 12px 7px;
  box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(
    90deg, rgba(47,93,138,0.28) 0 1px, transparent 1px 8px);
  background-size: 100% 7px;
  background-repeat: no-repeat;
  background-position: bottom;
  position: relative;
}
.tape::before {
  content: ""; position: absolute;
  top: -5px; left: 12px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--blue);
}
.tape-num {
  display: block;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tape-label {
  display: block;
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--blue);
}
.tape-doing .tape-num { color: var(--orange-deep); }

/* ---------------- Safety-orange Add strip ---------------- */
.addstrip {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  margin-top: 18px;
  padding: 16px 16px 15px;
  background: var(--orange);
  color: #3a1e00;
  border: 1.5px solid var(--orange-deep);
  box-shadow: var(--shadow);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 14px) 100%, 0 100%);
  text-align: left;
}
.addstrip:active { background: var(--orange-deep); color: #fff; }
.addstrip-plus { font-size: 1.5rem; font-weight: 700; line-height: 0.8; }
.addstrip-word {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.addstrip-note {
  margin-left: auto;
  font-size: 0.72rem;
  font-style: italic;
  opacity: 0.75;
}

/* ---------------- Next-step card ---------------- */
.nextcard {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--cream);
  border: 1.5px solid var(--blue);
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 16px 14px 14px 18px;
  position: relative;
  overflow: hidden;
}
.nextcard::before {
  content: ""; position: absolute;
  left: 0; top: 0; bottom: 0; width: 10px;
  background: var(--stage-band, var(--blue));
}
.nextcard:active { transform: translate(1px, 1px); box-shadow: 2px 3px 0 rgba(47,93,138,0.22); }

.nextcard-room {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--blue);
}
.nextcard-name {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 4px 0 10px;
}
.nextcard-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nextcard-est {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--orange-deep);
}
.nextcard-est.na { color: rgba(34,48,63,0.45); font-weight: 400; font-style: italic; }

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border: 1.5px solid var(--blue);
  border-radius: 999px;
  background: rgba(255,255,255,0.55);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Stage dots — filled or hollow only, never check marks */
.dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 2px solid var(--blue);
  background: transparent;
}
.dot-filled { background: var(--blue); }
.dot-doing { border-color: var(--orange-deep); }
.dot-doing.dot-filled { background: var(--orange-deep); }

.stage-planned { --stage-band: var(--blue); }
.stage-doing   { --stage-band: var(--orange); }
.stage-done    { --stage-band: var(--blue-deep); }
.stage-doing .dot { border-color: var(--orange-deep); }
.stage-doing .dot.dot-filled,
.stage-doing .dot { background: var(--orange-deep); border-color: var(--orange-deep); }

/* ---------------- Steps list: lumber-tag rows ---------------- */
.group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 18px 2px 7px;
}
.group-head:first-child { margin-top: 0; }
.group-word {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blue);
}
.group-count {
  font-size: 0.68rem;
  color: rgba(34,48,63,0.55);
  font-variant-numeric: tabular-nums;
}
.group-rule { flex: 1; border-top: 1.5px dashed rgba(47,93,138,0.4); }

.rowlist { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.row-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  text-align: left;
  background: var(--cream);
  border: 1.2px solid rgba(47,93,138,0.55);
  box-shadow: 2px 3px 0 rgba(47,93,138,0.18);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  padding: 6px 10px 6px 0;
  position: relative;
}
.row-main::before {
  content: "";
  align-self: stretch;
  width: 9px;
  flex: 0 0 9px;
  margin-right: 4px;
  background: var(--stage-band, var(--blue));
}
.row-main:active { transform: translate(1px, 1px); box-shadow: 1px 2px 0 rgba(47,93,138,0.18); }

.row-body { min-width: 0; }
.row-name {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  display: block;
  font-size: 0.74rem;
  color: rgba(34,48,63,0.6);
  margin-top: 1px;
}
.row-est {
  margin-left: auto;
  padding-left: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--orange-deep);
  white-space: nowrap;
}
.row-est.na { color: rgba(34,48,63,0.35); font-weight: 400; }

.row-cycle {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 56px;
  background: rgba(255,255,255,0.6);
  border: 1.2px dashed rgba(47,93,138,0.55);
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
  padding: 4px 2px;
}
.row-cycle:active { background: var(--blue); color: #fff; }
.row-cycle .next-word { font-size: 0.58rem; }

/* ---------------- Empty states: pencil doorway ---------------- */
.empty {
  text-align: center;
  padding: 26px 18px 20px;
  color: rgba(47, 93, 138, 0.45);
}
.doorway { width: 92px; height: 108px; display: block; margin: 0 auto 10px; }
.empty-word {
  font-size: 0.9rem;
  font-style: italic;
  color: rgba(34,48,63,0.55);
  max-width: 260px;
  margin: 0 auto;
}

/* ---------------- Forms ---------------- */
.note-panel {
  background: var(--cream);
  border: 1.5px solid var(--blue);
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 16px 14px 18px;
  position: relative;
}
.note-panel::before {
  content: "";
  position: absolute;
  top: -9px; left: 50%;
  transform: translateX(-50%);
  width: 92px; height: 16px;
  background: var(--blue);
  border-radius: 3px;
  box-shadow: 0 2px 0 rgba(47,93,138,0.3);
}
.note-title {
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue);
  margin-bottom: 12px;
}

#step-form label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue);
  margin: 14px 0 5px;
}
#step-form label:first-of-type { margin-top: 2px; }
#step-form label em {
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: none;
  color: rgba(34,48,63,0.45);
  margin-left: 6px;
}

#step-form input,
#step-form select {
  width: 100%;
  font-size: 16px; /* prevents iOS focus zoom */
  font-family: inherit;
  color: var(--blue-ink);
  background: #fdfaf3;
  border: 1.5px solid rgba(47,93,138,0.6);
  border-radius: 2px;
  padding: 11px 10px;
}
#step-form input::placeholder { color: rgba(34,48,63,0.35); font-style: italic; }
#step-form input:focus, #step-form select:focus {
  border-color: var(--orange-deep);
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}
#step-form input.invalid, #step-form select.invalid { border-color: var(--err); }

.ferr {
  font-size: 0.76rem;
  color: var(--err);
  font-weight: 700;
  min-height: 1em;
  margin-top: 4px;
}
.ferr:empty { margin: 0; }

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 14px 12px;
  background: var(--orange);
  border: 1.5px solid var(--orange-deep);
  color: #3a1e00;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 12px) 100%, 0 100%);
  box-shadow: var(--shadow);
}
.btn-primary:active { background: var(--orange-deep); color: #fff; }

.btn-ghost, .btn-danger {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 2px;
}
.btn-ghost { border: 1.5px dashed rgba(47,93,138,0.6); color: var(--blue); background: rgba(255,255,255,0.5); }
.btn-ghost:active { background: var(--blue); color: #fff; }
.btn-danger { border: 1.5px solid var(--err); color: var(--err); background: rgba(179,84,30,0.08); }
.btn-danger:active { background: var(--err); color: #fff; }

/* ---------------- Find ---------------- */
.search-wrap { position: relative; }
#find-input {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  color: var(--blue-ink);
  background: #fdfaf3;
  border: 1.5px solid var(--blue);
  border-radius: 3px;
  padding: 13px 12px 13px 38px;
  box-shadow: var(--shadow);
}
#find-input::placeholder { color: rgba(34,48,63,0.35); font-style: italic; }
.search-wrap::before {
  content: "";
  position: absolute;
  left: 13px; top: 50%;
  width: 13px; height: 13px;
  transform: translateY(-58%);
  border: 2.5px solid var(--blue);
  border-radius: 50%;
  pointer-events: none;
}
.search-wrap::after {
  content: "";
  position: absolute;
  left: 24px; top: 50%;
  width: 7px; height: 2.5px;
  transform: rotate(45deg);
  transform-origin: left top;
  background: var(--blue);
  pointer-events: none;
}
#find-input:focus { outline: 2px solid var(--orange); outline-offset: 1px; }

.find-count {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(34,48,63,0.55);
  margin: 10px 2px 8px;
  min-height: 1em;
}

.about-panel {
  margin-top: 26px;
  border: 1.5px dashed rgba(47,93,138,0.55);
  border-radius: 3px;
  background: rgba(255,255,255,0.45);
  padding: 14px 14px 16px;
}
.about-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 8px;
}
.about-copy { font-size: 0.84rem; line-height: 1.45; color: rgba(34,48,63,0.8); }
.about-stat {
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--orange-deep);
  margin-top: 8px;
}
.about-actions { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.about-actions .btn-ghost, .about-actions .btn-danger { margin-top: 0; padding: 9px 12px; }

/* ---------------- Fixed bottom tab bar ---------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  background: var(--cream);
  border-top: 2px solid var(--blue);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -3px 8px rgba(47,93,138,0.18);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px 5px;
  color: rgba(47,93,138,0.6);
}
.tab-word {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* paint-roller tabs: active tilted with short shadow, inactive flat */
.tab-roller {
  width: 30px; height: 9px;
  border-radius: 3px;
  background: rgba(47,93,138,0.28);
  border: 1px solid rgba(47,93,138,0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}
.tab.active {
  color: var(--blue-ink);
}
.tab.active .tab-roller {
  background: var(--orange);
  border-color: var(--orange-deep);
  transform: rotate(-7deg) translateY(-3px);
  box-shadow: 2px 4px 3px rgba(47,93,138,0.4);
}
.tab.active .tab-word { color: var(--orange-deep); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  background: var(--blue);
  color: #fdf9f1;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 3px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
