:root {
  --cream: #f4ebdd;
  --cream-deep: #eadfcc;
  --paper: #fbf5ea;
  --ink: #2f3e5c;
  --ink-soft: #5d6a83;
  --wood: #8a5a34;
  --wood-dark: #6b4326;
  --wood-light: #b98653;
  --accent: #d96c4d;
  --planned: #2f3e5c;
  --worn: #7f9770;
  --skipped: #b5674c;
  --shadow: 0 8px 22px rgba(72, 54, 36, .14);
  --tabbar-h: 68px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 12% 6%, rgba(217, 108, 77, .07), transparent 42%),
    radial-gradient(circle at 88% 30%, rgba(47, 62, 92, .06), transparent 46%);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea, select { font-size: 16px; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 26px);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 2px 12px;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-hanger { width: 30px; height: 30px; flex: none; }
.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.brand-tag {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid rgba(47, 62, 92, .2);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}

/* ---------- shared type ---------- */
h2 { margin: 0; font-size: 22px; letter-spacing: .01em; }
h3 { margin: 0; }
.mini-head {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 22px 2px 10px;
  font-weight: 700;
}
.week-head { padding: 6px 2px 14px; }
.week-head p { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; }

/* ---------- top rail strip (Today) ---------- */
.rail-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 10px 8px 8px;
  background: linear-gradient(180deg, rgba(138, 90, 52, .1), rgba(138, 90, 52, .03));
  border-radius: 16px 16px 6px 6px;
  border-bottom: 3px solid rgba(138, 90, 52, .38);
  margin-bottom: 18px;
}
.strip-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.strip-hook {
  width: 14px;
  height: 8px;
  border: 2px solid var(--wood);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  opacity: .8;
}
.strip-body {
  width: 100%;
  aspect-ratio: 1 / 1.15;
  border-radius: 7px 7px 4px 4px;
  background: var(--paper);
  border: 1px solid rgba(138, 90, 52, .24);
  border-bottom-width: 4px;
  border-bottom-style: solid;
  border-bottom-color: rgba(47, 62, 92, .22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: rgba(47, 62, 92, .5);
  overflow: hidden;
  text-align: center;
  padding: 2px;
  transition: transform .18s ease;
}
.strip-body.has-entry { color: var(--ink); }
.strip-body.status-Planned { border-bottom-color: var(--planned); }
.strip-body.status-Worn { border-bottom-color: var(--worn); }
.strip-body.status-Skipped { border-bottom-color: var(--skipped); }
.strip-body.is-today { box-shadow: inset 0 0 0 2px rgba(217, 108, 77, .55); }
.strip-day .strip-name {
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
.strip-day.is-today .strip-name { color: var(--accent); }

/* ---------- counters ---------- */
.counter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.counter-disc {
  width: 76px;
  height: 76px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #f7ecd9, #e5d4ba 70%, #d9c3a4);
  border: 2px solid rgba(138, 90, 52, .34);
  box-shadow: inset 0 -3px 0 rgba(138, 90, 52, .22), 0 4px 10px rgba(72, 54, 36, .12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.counter-disc::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 9px;
  height: 5px;
  margin-left: -4.5px;
  border: 2px solid var(--wood-dark);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}
.disc-worn { background: radial-gradient(circle at 34% 28%, #f3f0dc, #dfe2c8 70%, #ccd1b2); }
.disc-num {
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  margin-top: 6px;
}
.disc-label {
  font-size: 8.5px;
  line-height: 1.15;
  text-align: center;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 3px;
}
.counter-note {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.45;
  padding-left: 4px;
}

/* ---------- buttons ---------- */
.wide-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-bottom: 22px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #3a4b6d, var(--ink));
  color: #f8f1e4;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: 0 6px 0 rgba(47, 62, 92, .24), 0 10px 20px rgba(47, 62, 92, .2);
  transition: transform .12s ease, box-shadow .12s ease;
}
.wide-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(47, 62, 92, .24), 0 5px 12px rgba(47, 62, 92, .18);
}

.btn-primary {
  flex: 1;
  padding: 14px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff8ef;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 13px;
  box-shadow: 0 4px 0 #a94e35;
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #a94e35; }
.btn-ghost {
  padding: 14px 18px;
  border: 1px solid rgba(47, 62, 92, .28);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.btn-danger {
  width: 100%;
  margin-top: 20px;
  padding: 15px;
  border: 1px solid rgba(181, 103, 76, .5);
  border-radius: 12px;
  background: rgba(181, 103, 76, .08);
  color: #94452e;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  font-size: 13px;
}
.btn-danger:active { background: rgba(181, 103, 76, .18); }

/* ---------- form sheet ---------- */
.slip {
  background: var(--paper);
  border-radius: 14px 14px 8px 8px;
  padding: 16px 15px 15px;
  box-shadow: var(--shadow);
  border-top: 4px solid rgba(138, 90, 52, .33);
  position: relative;
}
.slip::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 50%;
  width: 22px;
  height: 9px;
  margin-left: -11px;
  border: 3px solid var(--wood);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}
.slip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.slip-head h2 { font-size: 17px; }
.slip-sub {
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(47, 62, 92, .22);
  background: #fffaf1;
  border-radius: 9px;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 58px; line-height: 1.45; }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 108, 77, .16);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.err {
  display: block;
  font-style: normal;
  font-size: 11.5px;
  color: #b54a2f;
  margin-top: 4px;
  min-height: 0;
}
.field.invalid input,
.field.invalid textarea,
.field.invalid select { border-color: #c25e42; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- today's other entries ---------- */
.today-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 250, 241, .78);
  border: 1px solid rgba(138, 90, 52, .2);
  border-left: 4px solid var(--planned);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  text-align: left;
  width: 100%;
}
.today-row.status-Worn { border-left-color: var(--worn); }
.today-row.status-Skipped { border-left-color: var(--skipped); }
.today-row .tr-day {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  flex: none;
  width: 74px;
}
.today-row .tr-pieces {
  font-size: 13px;
  color: var(--ink-soft);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- week rail ---------- */
.rail {
  position: relative;
  padding-left: 22px;
}
.rail::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 14px;
  width: 5px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  box-shadow: 1px 0 0 rgba(255, 255, 255, .3) inset;
}
.rail-item {
  position: relative;
  margin-bottom: 12px;
}
.rail-hook {
  position: absolute;
  left: -19px;
  top: 17px;
  width: 16px;
  height: 9px;
  border: 3px solid var(--wood);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  z-index: 2;
}
.hanger-card {
  width: 100%;
  text-align: left;
  border: 0;
  padding: 0;
  border-radius: 10px 10px 4px 4px;
  background: var(--paper);
  box-shadow: 0 3px 10px rgba(72, 54, 36, .12);
  overflow: hidden;
  transition: transform .15s ease;
}
.hanger-card:active { transform: translateX(2px); }
.hanger-notch {
  position: absolute;
  top: 0;
  left: 18px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid var(--cream-deep);
  z-index: 3;
}
.hanger-inner { padding: 12px 14px 11px; }
.hanger-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.hanger-day {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  line-height: 1.1;
}
.hanger-day .day-index {
  font-size: 9.5px;
  color: var(--ink-soft);
  letter-spacing: .1em;
  margin-left: 6px;
  font-weight: 600;
}
.hanger-occ {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  border: 1px solid rgba(47, 62, 92, .18);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.hanger-pieces {
  margin: 6px 0 9px;
  font-size: 14px;
  line-height: 1.4;
  color: #3f4a5e;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.status-band {
  height: 18px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 8.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #fdf7ea;
  font-weight: 700;
}
.status-band.Planned { background: var(--planned); }
.status-band.Worn { background: var(--worn); }
.status-band.Skipped { background: var(--skipped); }
.hanger-card.is-empty .hanger-inner { padding: 15px 14px; }
.hanger-empty-pieces {
  font-size: 13px;
  color: rgba(93, 106, 131, .85);
  margin: 5px 0 10px;
  font-style: italic;
}

/* theme empty states */
.empty-note {
  border: 1px dashed rgba(138, 90, 52, .42);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: left;
  background: rgba(255, 250, 241, .55);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}
.empty-note strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.rail-empty {
  position: relative;
  margin-left: 4px;
}

/* ---------- occasions ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: none;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid rgba(47, 62, 92, .24);
  background: rgba(255, 250, 241, .6);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #f6efe1;
  box-shadow: 0 3px 8px rgba(47, 62, 92, .22);
}
.search-wrap { margin-bottom: 14px; }
.search-wrap input {
  width: 100%;
  border: 1px solid rgba(47, 62, 92, .22);
  background: #fffaf1;
  border-radius: 999px;
  padding: 11px 17px;
  outline: none;
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 108, 77, .16);
}
.compact-list { display: flex; flex-direction: column; gap: 8px; }
.compact-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 0;
  padding: 0;
  background: var(--paper);
  border-radius: 8px;
  overflow: hidden;
  text-align: left;
  box-shadow: 0 2px 6px rgba(72, 54, 36, .09);
}
.compact-row .cr-stripe { width: 5px; flex: none; }
.compact-row .cr-stripe.Planned { background: var(--planned); }
.compact-row .cr-stripe.Worn { background: var(--worn); }
.compact-row .cr-stripe.Skipped { background: var(--skipped); }
.cr-body { padding: 10px 12px; flex: 1; min-width: 0; }
.cr-line1 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.cr-day {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.cr-occ { font-size: 10px; color: var(--ink-soft); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.cr-pieces {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 3px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-count {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 2px 10px;
}

/* ---------- local ---------- */
.local-card {
  background: linear-gradient(160deg, #fffaf1, #f0e3cf);
  border: 1px solid rgba(138, 90, 52, .28);
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.local-card::after {
  content: "";
  position: absolute;
  right: -22px;
  top: -22px;
  width: 80px;
  height: 80px;
  border: 7px solid rgba(138, 90, 52, .13);
  border-radius: 50%;
}
.local-num {
  display: block;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}
.local-cap {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
.local-note {
  margin: 16px 2px 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  border-left: 3px solid rgba(217, 108, 77, .5);
  padding-left: 12px;
}
.local-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 0;
}
.local-facts div {
  background: rgba(255, 250, 241, .7);
  border: 1px solid rgba(138, 90, 52, .18);
  border-radius: 8px;
  padding: 10px 12px;
}
.local-facts dt {
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
.local-facts dd {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 700;
}

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  display: flex;
  padding: 0 10px calc(env(safe-area-inset-bottom) + 6px);
  background: linear-gradient(180deg, #a06c40, #7d4f2c);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 22px rgba(60, 40, 22, .3);
  z-index: 40;
}
.tab {
  flex: 1;
  position: relative;
  border: 0;
  background: transparent;
  padding: 20px 2px 10px;
  color: rgba(250, 240, 224, .72);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tab-hook {
  position: absolute;
  top: 3px;
  left: 50%;
  width: 20px;
  height: 13px;
  margin-left: -10px;
  border: 3px solid rgba(250, 240, 224, .55);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  transition: all .2s ease;
}
.tab-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.tab.is-active { color: #fff8ea; }
.tab.is-active .tab-hook {
  top: -18px;
  width: 40px;
  height: 26px;
  margin-left: -20px;
  border-width: 4px;
  border-color: #f6e7cc;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #a06c40, #8a5a34);
  box-shadow: 0 -3px 12px rgba(40, 25, 10, .35), 0 3px 0 rgba(250, 240, 224, .35);
}
.tab.is-active .tab-label { letter-spacing: .11em; }

/* ---------- inline row actions ---------- */
.row-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 8px;
}
.row-wrap .today-row { margin-bottom: 0; flex: 1; min-width: 0; }
.row-wrap .compact-row { flex: 1; min-width: 0; }
.row-del {
  flex: none;
  align-self: stretch;
  width: 60px;
  border: 1px solid rgba(181, 103, 76, .38);
  background: rgba(181, 103, 76, .08);
  color: #94452e;
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 6px 4px;
  line-height: 1.25;
}
.row-del.armed {
  background: #b5674c;
  border-color: #b5674c;
  color: #fff6ec;
}
.card-flex { display: flex; align-items: stretch; }
.card-flex .hanger-card { flex: 1; min-width: 0; }
.row-del.side {
  width: 46px;
  margin-left: 6px;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(72, 54, 36, .12);
}
.btn-danger.armed {
  background: #b5674c;
  border-color: #b5674c;
  color: #fff6ec;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 12px);
  background: rgba(47, 62, 92, .95);
  color: #f7efe0;
  font-size: 12.5px;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 70;
  max-width: 88%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.view { animation: fadeIn .18s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 480px) {
  .app { padding-left: 22px; padding-right: 22px; }
  .tabbar { border-radius: 20px 20px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
