:root {
  --ink: #151B33;        /* indigo dye */
  --paper: #F3F5F8;      /* cool pressed cotton */
  --card: #FFFFFF;
  --rail: #C9CFDB;       /* the clothes rail */
  --slate: #5D6579;
  --marigold: #F0A92B;   /* the one loud colour */
  --moss: #2F7D5B;
  --brick: #B4432F;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --tab-h: 64px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; min-height: 100%; background: var(--paper); color: var(--ink);
  font: 400 16px/1.5 var(--body); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 2.1rem; line-height: 1.05; }
h2 { font-size: 1.35rem; line-height: 1.15; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
.muted { color: var(--slate); }
.small { font-size: 0.875rem; }
.boot { padding: 40vh 24px 0; text-align: center; color: var(--slate); }

/* ---------- layout ---------- */
.screen { max-width: 560px; margin: 0 auto; padding: 20px 18px calc(var(--tab-h) + 36px + env(safe-area-inset-bottom, 0px)); }
.stack { display: grid; gap: 16px; }
.stack-s { display: grid; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 0; border-radius: 14px; padding: 14px 18px; min-height: 48px;
  background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; text-align: center;
}
.btn.wide { width: 100%; }
.btn.sun { background: var(--marigold); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--rail); }
.btn.danger { background: transparent; color: var(--brick); box-shadow: inset 0 0 0 1.5px var(--brick); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; border: 0; white-space: nowrap; border-radius: 999px; padding: 9px 14px; min-height: 40px;
  background: var(--card); box-shadow: inset 0 0 0 1.5px var(--rail); cursor: pointer; font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; box-shadow: none; }
.field { display: grid; gap: 6px; font-weight: 500; font-size: 0.9rem; }
.field input, .field select, .field textarea, .input {
  width: 100%; border: 0; border-radius: 12px; padding: 13px 14px; min-height: 48px;
  background: var(--card); box-shadow: inset 0 0 0 1.5px var(--rail); font-weight: 400; font-size: 1rem;
}
.field input:focus, .field select:focus, .input:focus { box-shadow: inset 0 0 0 2px var(--ink); outline: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--ink); flex: none; }
.linkbtn { appearance: none; border: 0; background: none; padding: 8px 0; text-decoration: underline; cursor: pointer; color: var(--ink); }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; align-content: center; gap: 22px; padding: 28px 22px; max-width: 460px; margin: 0 auto; }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 4.2rem; line-height: 0.9; letter-spacing: -0.05em; }
.wordmark + p { font-size: 1.15rem; max-width: 24ch; }

/* ---------- the rail: an outfit hangs from it ---------- */
.outfit { background: var(--card); border-radius: 22px; padding: 18px 16px 16px; display: grid; gap: 14px; }
.railwrap { position: relative; padding-top: 14px; margin: 0 -16px; }
.railwrap::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 3px; background: var(--rail); border-radius: 2px; }
.rail { display: flex; gap: 10px; overflow-x: auto; padding: 0 16px 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.hung { position: relative; flex: 0 0 34%; max-width: 150px; scroll-snap-align: start; }
.hung::before {
  content: ""; position: absolute; left: 50%; top: -11px; width: 12px; height: 14px; transform: translateX(-50%);
  border: 3px solid var(--ink); border-bottom: 0; border-radius: 8px 8px 0 0;
}
.hung img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; background: var(--paper); }
.hung span { display: block; font-size: 0.78rem; color: var(--slate); margin-top: 5px; line-height: 1.25; }
.note { border-left: 3px solid var(--marigold); padding: 2px 0 2px 10px; font-size: 0.92rem; }
.verdict { background: var(--ink); color: #fff; border-radius: 18px; padding: 16px; font-family: var(--display); font-size: 1.2rem; line-height: 1.25; }
.preview img { width: 100%; border-radius: 16px; background: var(--paper); }
.preview .small { margin-top: 8px; }
.warn { background: #FFF4DD; border-radius: 12px; padding: 10px 12px; font-size: 0.875rem; }
.err { background: #FBE9E5; color: #7A2A1C; border-radius: 12px; padding: 12px 14px; font-size: 0.92rem; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.actions .btn { padding: 12px 6px; font-size: 0.92rem; }
.btn.on { background: var(--moss); color: #fff; box-shadow: none; }
.btn.off { background: var(--brick); color: #fff; box-shadow: none; }

/* ---------- wardrobe ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { appearance: none; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; position: relative; }
.tile img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; background: var(--card); }
.tile span { display: block; font-size: 0.78rem; margin-top: 4px; line-height: 1.2; }
.flag { position: absolute; top: 6px; left: 6px; background: var(--marigold); color: var(--ink); font-size: 0.7rem; font-weight: 600; padding: 3px 7px; border-radius: 999px; }
.empty { background: var(--card); border-radius: 20px; padding: 26px 20px; display: grid; gap: 10px; }
.filepick { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.filepick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 100px; }

/* ---------- sheet ---------- */
dialog { border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 22px 22px 0 0; background: var(--paper); color: var(--ink); max-height: 92dvh; }
dialog::backdrop { background: rgba(21, 27, 51, 0.55); }
.sheet { padding: 18px 18px calc(22px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }
.sheet > img { width: 55%; margin: 0 auto; border-radius: 14px; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--ink); padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); z-index: 5;
}
.tab { appearance: none; border: 0; background: none; color: #AEB5C8; min-height: 52px; font-size: 0.8rem; font-weight: 500; cursor: pointer; border-radius: 12px; }
.tab[aria-current="page"] { color: var(--ink); background: var(--marigold); font-weight: 600; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; max-width: min(92vw, 480px);
  font-size: 0.92rem; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 20; text-align: center;
}
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(4, 1fr); } }
