/* Closet: warm linen paper, ink type, an oxblood accent, editorial serif headings. */
:root {
  --bg: #F4EFE8;
  --card: #FFFDFA;
  --ink: #221E1B;
  --muted: #6F6760;
  --line: #E2DAD0;
  --field: #EEE7DE;
  --accent: #7C2D3B;
  --accent-ink: #FFF8F6;
  --accent-soft: #F2DFE1;
  --ok: #3F6B4F;
  --danger: #A8342A;
  --shadow: 0 1px 2px rgba(34, 30, 27, .06), 0 6px 18px rgba(34, 30, 27, .05);
  --radius: 16px;
  --tab-h: 62px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171514; --card: #211E1C; --ink: #EFE9E2; --muted: #A69D94; --line: #34302C; --field: #2B2724;
    --accent: #D9798A; --accent-ink: #2A0E14; --accent-soft: #3C2328; --ok: #7CC096; --danger: #EE8577; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171514; --card: #211E1C; --ink: #EFE9E2; --muted: #A69D94; --line: #34302C; --field: #2B2724;
  --accent: #D9798A; --accent-ink: #2A0E14; --accent-soft: #3C2328; --ok: #7CC096; --danger: #EE8577; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { font: -apple-system-body; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: max(1rem, 16px); line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, ol { margin: 0; }
.icon { flex: none; display: block; }
a { color: inherit; }
img { display: block; }

.main { padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px); max-width: 760px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Type ---------- */
.title { font-family: var(--serif); font-size: 2em; font-weight: 600; letter-spacing: -.01em; line-height: 1.12; }
.h2 { font-family: var(--serif); font-size: 1.25em; font-weight: 600; }
.eyebrow { font-size: .82em; color: var(--muted); text-transform: capitalize; }
.muted { color: var(--muted); }
.small { font-size: .88em; }
.tiny { font-size: .78em; }
.strong { font-weight: 650; }
.center { text-align: center; }
.link { color: var(--accent); font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; font-size: .92em; }
.notes { background: var(--field); border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; }
.error { color: var(--danger); }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: .92em; }
.summary { font-family: var(--serif); font-size: 1.1em; font-style: italic; }
.empty-line { grid-column: 1 / -1; padding: 24px 0; text-align: center; }

/* ---------- Layout ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 10px; }
.row.end { justify-content: flex-end; }
.row.gap { gap: 8px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.hscroll { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 6px; scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { flex: none; width: 132px; scroll-snap-align: start; }
.hscroll.tiles > * { width: 112px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.ogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

/* ---------- Today ---------- */
.hero { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.snap {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border-radius: 20px; padding: 18px; min-height: 84px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 28%, transparent);
}
.snap:active { filter: brightness(.95); }
.snap-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent-ink) 16%, transparent); flex: none; }
.snap-text { display: flex; flex-direction: column; gap: 2px; }
.snap-title { font-family: var(--serif); font-size: 1.3em; font-weight: 600; }
.snap-sub { font-size: .88em; opacity: .85; }
.steps { padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Piece tiles ---------- */
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit;
  border: 0; background: none; padding: 0; text-align: left; min-width: 0;
}
.art { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--field); width: 100%; }
.art img { width: 100%; height: 100%; object-fit: cover; }
.art.swatch { display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.tile-name { font-size: .84em; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-fav { position: absolute; top: 6px; right: 6px; color: var(--accent); background: var(--card); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; }
.tile-badge { position: absolute; top: 4px; left: 4px; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: .8em; padding: 0 6px; background: var(--ink); color: var(--bg); }
.tile-badge.add { background: var(--accent); color: var(--accent-ink); }
.tile.small { width: 72px; flex: none; }
.tile.small .art { border-radius: 10px; }
.tile.dim { opacity: .45; }
.tile.picked .art { box-shadow: 0 0 0 3px var(--accent); }
.tile:not(.picked)[aria-pressed="false"] .art { opacity: .55; }

.collage { display: grid; gap: 2px; width: 100%; height: 100%; background: var(--line); }
.collage.n1 { grid-template-columns: 1fr; }
.collage.n2 { grid-template-columns: 1fr 1fr; }
.collage.n3, .collage.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.collage.n3 > :first-child { grid-row: span 2; }
.collage .art { border-radius: 0; aspect-ratio: auto; height: 100%; }

.ocard { position: relative; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.ocard-pic { aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; background: var(--field); }
.ocard-pic img { width: 100%; height: 100%; object-fit: cover; }
.ocard-when { font-size: .84em; color: var(--muted); }

.hero-art { max-width: 420px; width: 100%; margin: 0 auto; }
.hero-art .art { border-radius: 22px; }
.outfit-photo { border-radius: 22px; overflow: hidden; background: var(--field); max-height: 70vh; display: grid; place-items: center; }
.outfit-photo img { width: 100%; max-height: 70vh; object-fit: contain; }
.outfit-photo.look { aspect-ratio: 1; max-width: 420px; width: 100%; margin: 0 auto; }

/* ---------- Ideas ---------- */
.ideas { display: flex; flex-direction: column; gap: 12px; }
.idea { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.idea:first-child { border-top: 0; padding-top: 0; }
.idea-title { font-family: var(--serif); font-size: 1.12em; font-weight: 600; }
.idea-why { font-size: .94em; }
.strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.strip::-webkit-scrollbar { display: none; }
.tip { display: flex; gap: 8px; align-items: flex-start; font-size: .9em; color: var(--muted); }
.tip .icon { color: var(--accent); margin-top: 2px; }
.thinking { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 8px 0; }
.thinking .spinner { width: 24px; height: 24px; border-width: 2.5px; }

/* ---------- Capture review ---------- */
.preview { border-radius: 16px; overflow: hidden; background: var(--field); max-height: 34vh; display: grid; place-items: center; }
.preview img { max-height: 34vh; width: 100%; object-fit: contain; }
.prow { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 10px; transition: opacity .15s; }
.prow.off { opacity: .5; }
.prow-main { display: flex; align-items: center; gap: 10px; }
.prow-art { width: 64px; flex: none; }
.prow-art .art { border-radius: 10px; }
.prow-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.prow-fields .input { min-height: 40px; padding: 8px 10px; }
.prow-fields select.input { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: .9em; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: var(--accent-ink); }
[aria-pressed="true"] > .check { background: var(--accent); border-color: var(--accent); }
.match { display: flex; flex-direction: column; gap: 8px; background: var(--accent-soft); border-radius: 10px; padding: 8px; }
.match-who { display: flex; align-items: center; gap: 8px; }
.match-art { width: 36px; flex: none; }
.match-art .art { border-radius: 8px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 0;
  background: var(--field); color: var(--ink); font-weight: 650; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.block { width: 100%; }
.btn.small-btn { min-height: 38px; padding: 0 12px; font-size: .9em; border-radius: 11px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { filter: brightness(.95); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--ink);
  display: grid; place-items: center; flex: none; text-decoration: none;
}
.icon-btn.round { border-radius: 50%; background: var(--card); box-shadow: var(--shadow); }
.icon-btn.on { color: var(--accent); }
.icon-btn:active { filter: brightness(.94); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { border: 0; background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); padding: 7px 13px; border-radius: 999px; font-weight: 600; font-size: .86em; white-space: nowrap; color: var(--ink); min-height: 36px; }
.chip.on { background: var(--ink); color: var(--bg); box-shadow: none; }
.chip.static { background: var(--field); box-shadow: none; font-weight: 500; text-transform: capitalize; min-height: 0; padding: 5px 11px; }

.segs { display: inline-flex; background: var(--field); border-radius: 11px; padding: 3px; gap: 2px; }
.segs.wide { display: flex; }
.segs.wide .seg { flex: 1; }
.seg { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-weight: 600; font-size: .88em; color: var(--muted); min-height: 36px; }
.seg.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .85em; font-weight: 650; color: var(--muted); }
.field-hint { font-size: .8em; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--field); font-size: max(1rem, 16px); outline: none; -webkit-appearance: none; appearance: none;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--accent); background: var(--card); }
.input:disabled { opacity: .55; }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 56px; text-decoration: none; color: inherit; background: none; border: 0; width: 100%; text-align: left; }
.li:active { background: var(--field); }
.li .li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.li .li-title { font-weight: 600; }
.li .li-sub { font-size: .85em; color: var(--muted); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 40px 12px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 0 max(8px, calc((100% - 760px) / 2)) env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line); display: flex;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .7em; font-weight: 600; border: 0; background: none; }
.tab.active { color: var(--accent); }
.snap-dot { width: 50px; height: 50px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin-top: -10px; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- Sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .25s; z-index: 50; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; margin: 0 auto; max-width: 640px;
  background: var(--bg); border-radius: 22px 22px 0 0; max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.sheet.open { transform: none; }
.sheet.tall { height: 90vh; height: 90dvh; }
.sheet-head { padding: 6px 16px 4px; flex: none; }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 6px; }
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-title { font-family: var(--serif); font-size: 1.25em; font-weight: 600; }
.sheet-body { padding: 8px 16px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.sheet-foot { padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--line); flex: none; }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; border-radius: 22px; transform: translateY(-40%) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; max-height: 84vh; }
  .sheet.open { transform: translateY(-50%); opacity: 1; }
  .sheet.tall { height: 84vh; }
  .sheet-grab { display: none; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translate(-50%, -20px);
  background: var(--ink); color: var(--bg); padding: 6px 6px 6px 16px; border-radius: 12px; font-weight: 600; font-size: .92em;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 32px); min-height: 44px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast .toast-msg { padding: 6px 10px 6px 0; }
.toast button { border: 0; background: rgba(255,255,255,.14); color: inherit; font-weight: 700; padding: 8px 14px; border-radius: 9px; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop, .toast, .prow { transition: none; }
  .spinner { animation-duration: 2s; }
}
.tile.small .tile-name { font-size: .72em; color: var(--muted); }
.tile-badge.add { font-size: 1em; }
