/* Guardaroba — lookbook editoriale, mobile-first. Dark di default ([data-theme]). */

@font-face { font-family: "Instrument Serif"; src: url(/fonts/InstrumentSerif-normal-latin.woff2) format("woff2"); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url(/fonts/InstrumentSerif-italic-latin.woff2) format("woff2"); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter Tight"; src: url(/fonts/InterTight-normal-latin.woff2) format("woff2"); font-style: normal; font-weight: 300 700; font-display: swap; }

:root {
  --font: "Inter Tight", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Helvetica Neue", sans-serif;
  --display: "Instrument Serif", "Hiragino Mincho ProN", Georgia, serif;
  --radius: 18px;
  --radius-s: 12px;
  --tabbar-h: 60px;
  --gutter: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root, [data-theme="dark"] {
  --bg: #0e0e0f;
  --surface: #161617;
  --surface-2: #1e1e20;
  --surface-3: #2a2a2d;
  /* card backdrop: a lifted warm grey, so black garments stay readable */
  --card: #2b2a2e;
  --card-hi: #3a393e;
  --text: #f1efe9;
  --text-2: #a8a6a0;
  --text-3: #6d6b67;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #e8483b;
  --accent-soft: rgba(232, 72, 59, 0.16);
  --ink: #f1efe9; /* primary button background */
  --ink-text: #0e0e0f;
  --danger: #ff6b5e;
  --blur-bg: rgba(14, 14, 15, 0.82);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --swatch-ring: rgba(255, 255, 255, 0.28);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f2f0eb;
  --surface: #faf9f6;
  --surface-2: #ebe8e1;
  --surface-3: #dedad1;
  --card: #e4e0d7;
  --card-hi: #efece5;
  --text: #151413;
  --text-2: #5f5c57;
  --text-3: #9a968f;
  --line: rgba(20, 18, 10, 0.09);
  --line-strong: rgba(20, 18, 10, 0.18);
  --accent: #c8332a;
  --accent-soft: rgba(200, 51, 42, 0.1);
  --ink: #151413;
  --ink-text: #f2f0eb;
  --danger: #c8332a;
  --blur-bg: rgba(242, 240, 235, 0.85);
  --shadow: 0 10px 30px rgba(40, 30, 10, 0.1);
  --swatch-ring: rgba(0, 0, 0, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
html, body { margin: 0; color: var(--text); }
body {
  background: var(--bg);
  font: 15px/1.45 var(--font);
  font-weight: 400;
  letter-spacing: -0.005em;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; letter-spacing: inherit; }
button:disabled { cursor: default; opacity: 0.4; }
input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.ic { display: inline-flex; flex: none; }
.ic svg { display: block; }
img { -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }

.display { font-family: var(--display); font-weight: 400; letter-spacing: -0.01em; line-height: 0.95; margin: 0; }
.display em { font-style: italic; }
h1.display { font-size: 44px; }
h2.display { font-size: 30px; line-height: 1.05; }
.kicker { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.16em; color: var(--text-2); margin-bottom: 6px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.lede { color: var(--text-2); font-size: 14px; margin: 4px 0 18px; max-width: 34em; }
.hint { color: var(--text-3); font-size: 12.5px; margin-top: 18px; line-height: 1.5; }
.mt { margin-top: 22px; }

/* ---------- layout ---------- */

#view { min-height: 100dvh; }
.view {
  padding: calc(var(--safe-t) + 14px) calc(var(--gutter) + var(--safe-r)) calc(var(--tabbar-h) + var(--safe-b) + 40px) calc(var(--gutter) + var(--safe-l));
  max-width: 820px;
  margin: 0 auto;
  animation: view-in .35s var(--ease);
}
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.page-head { margin: 14px 0 18px; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-seg { margin-top: 18px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  margin: calc(-1 * (var(--safe-t) + 14px)) calc(-1 * var(--gutter)) 10px;
  padding: calc(var(--safe-t) + 8px) calc(var(--gutter) - 8px) 8px;
  background: var(--blur-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  min-height: calc(var(--safe-t) + 56px);
}
.topbar-title { flex: 1; font-weight: 600; font-size: 16px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer, .topbar .back { width: 44px; flex: none; }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 2px; min-width: 44px; }
.topbar:not(:has(.topbar-title)) .topbar-right { margin-left: auto; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--text); transition: background .2s; }
.icon-btn:active { background: var(--surface-3); }
.icon-btn.fav-on { color: var(--accent); }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 calc(var(--safe-r) + 4px) var(--safe-b) calc(var(--safe-l) + 4px);
  background: var(--blur-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(20px);
  backdrop-filter: saturate(1.4) blur(20px);
  border-top: 0.5px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: center; text-decoration: none; color: var(--text-3); font-size: 10px; font-weight: 500; letter-spacing: 0.02em; transition: color .2s; }
.tabbar a.on { color: var(--text); }
.tab-add .add-disc { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--ink-text); transition: transform .2s var(--ease); }
.tab-add:active .add-disc { transform: scale(0.92); }
body.sheet-open .tabbar { pointer-events: none; }

/* ---------- buttons, inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 999px;
  font-weight: 600; font-size: 15px; text-decoration: none;
  transition: transform .15s var(--ease), background .2s, opacity .2s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.primary { background: var(--ink); color: var(--ink-text); }
.btn.secondary { background: var(--surface-3); color: var(--text); }
.btn.ghost { color: var(--text); border: 1px solid var(--line-strong); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.btn-row > .btn { flex: 1; }
.link { color: var(--text); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; padding: 8px 4px; }
.subtle-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; margin-top: 12px; padding: 4px 0; }

.text {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface-2);
  outline: none; font-size: 16px; transition: border-color .2s;
}
.text:focus { border-color: var(--line-strong); }
textarea.text { resize: vertical; min-height: 80px; line-height: 1.4; }
.text.date { -webkit-appearance: none; appearance: none; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .ic { position: absolute; left: 14px; color: var(--text-3); pointer-events: none; }
.search { width: 100%; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 16px 0 40px; outline: none; font-size: 16px; -webkit-appearance: none; }

/* segmented control */
.seg { display: flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 36px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--text-2); transition: background .25s var(--ease), color .2s; padding: 0 8px; white-space: nowrap; }
.seg button.on { background: var(--text); color: var(--bg); font-weight: 600; }

/* chips */
.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.scroll-x { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text-2); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.lg { height: 42px; padding: 0 16px; font-size: 14.5px; }
.chip.small { height: 30px; padding: 0 11px; font-size: 12.5px; }
.chip.today .ic { color: #f0b43a; }
.chip.today.on .ic { color: inherit; }

.filterbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.filter-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- item cards & grid ---------- */

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 10px; }
.grid.compact { grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } .grid.compact { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card { position: relative; display: block; text-align: left; animation: card-in .45s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 25ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
.card-img {
  aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 38%, var(--card-hi), var(--card) 70%);
  display: grid; place-items: center; transition: transform .25s var(--ease);
}
.card:active .card-img { transform: scale(0.97); }
.card-img img { width: 84%; height: 84%; object-fit: contain; opacity: 0; transition: opacity .35s; filter: drop-shadow(0 6px 10px rgba(0,0,0,.18)); }
.card-img img.ready { opacity: 1; }
.noimg { color: var(--text-3); display: grid; place-items: center; width: 100%; height: 100%; }
.card-meta { display: flex; flex-direction: column; padding: 8px 4px 0; min-width: 0; }
.card-title { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-brand { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.compact .card-meta { display: none; }
.compact .card-img { border-radius: var(--radius-s); }
.badge {
  position: absolute; top: 9px; right: 9px; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--text); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.badge.wish { background: var(--accent); color: #fff; text-transform: uppercase; letter-spacing: 0.08em; font-size: 9.5px; }
.badge.arch { color: var(--text-2); font-size: 10px; }
.badge.draft { background: #f0b43a; color: #1a1306; font-size: 10px; }
.badge.inline { position: static; }
.compact .badge { top: 6px; right: 6px; height: 19px; min-width: 20px; font-size: 10.5px; }
.card.st-archived .card-img { opacity: 0.55; }
.rain-ok { position: absolute; top: 9px; left: 9px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #3d7be0; color: #fff; }
.card-note { position: absolute; left: 9px; bottom: 50px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 70%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.compact .card-note { bottom: 6px; left: 6px; font-size: 9.5px; }
.card .check { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(255,255,255,.7); background: rgba(0,0,0,.25); color: transparent; transition: background .2s, color .2s; }
.card.selected .check { background: var(--text); border-color: var(--text); color: var(--bg); }
.card.selected .card-img { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- flat-lay board ---------- */

.board {
  position: relative; aspect-ratio: 4 / 5; width: 100%; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(130% 100% at 50% 35%, var(--card-hi), var(--card) 75%);
}
.board .piece { position: absolute; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(0,0,0,.22)); }
.board .piece.wish { opacity: 0.92; outline: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 4px; border-radius: 8px; }
.board.animate .piece { animation: piece-in .5s var(--ease) backwards; animation-delay: var(--d, 0ms); }
@keyframes piece-in { from { opacity: 0; transform: translateY(12px) scale(0.94); } }
.board-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); }
.board.large { border-radius: 22px; }
.board-wrap { margin: 4px 0 16px; }

.outfit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
@media (min-width: 560px) { .outfit-grid { grid-template-columns: repeat(3, 1fr); } }
.outfit-card { text-align: left; animation: card-in .45s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 35ms); }
.outfit-card:active .board { transform: scale(0.98); }
.outfit-card .board { transition: transform .25s var(--ease); }
.outfit-meta { display: flex; align-items: center; gap: 6px; padding: 8px 4px 0; font-size: 13.5px; font-weight: 500; min-height: 30px; }
.outfit-meta > span:first-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav { color: var(--accent); }
.mini-outfits { display: flex; gap: 10px; padding-bottom: 4px; }
.mini-outfit { flex: none; width: 118px; text-align: left; font-size: 12.5px; color: var(--text-2); }
.mini-outfit .board { border-radius: var(--radius-s); margin-bottom: 6px; }
.mini-outfit.on .board { outline: 2px solid var(--text); outline-offset: 2px; }
.outfit-choose { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.outfit-choose .mini-outfit { width: auto; }

/* builder slots */
.slots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.slot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px; }
.slot-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-2); font-weight: 600; margin-bottom: 8px; }
.slot-items { display: flex; gap: 6px; flex-wrap: wrap; }
.slot-thumb, .slot-add { position: relative; width: 56px; height: 70px; border-radius: 10px; display: grid; place-items: center; overflow: visible; }
.slot-thumb { background: var(--card); animation: piece-in .35s var(--ease); }
.slot-thumb img { width: 48px; height: 60px; object-fit: contain; opacity: 1; }
.slot-add { border: 1px dashed var(--line-strong); color: var(--text-2); }
.slot-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.builder-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-s); background: var(--accent-soft); color: var(--text); font-size: 13.5px; margin: 0 0 14px; }
.notice .ic { color: var(--accent); margin-top: 1px; }

/* ---------- banner, empty ---------- */

.banner { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; margin-bottom: 14px; border-radius: var(--radius-s); background: color-mix(in srgb, #f0b43a 16%, var(--surface)); font-weight: 500; font-size: 14px; text-align: left; }
.banner > span:nth-child(2) { flex: 1; }
.banner-n { min-width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; background: #f0b43a; color: #1a1306; font-weight: 700; font-size: 13px; padding: 0 6px; }
.empty { text-align: center; padding: 40px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-2); }
.empty.hero { padding: 48px 10px; text-align: left; align-items: flex-start; color: var(--text); }
.empty.hero .btn-col { width: 100%; }
.empty.full { min-height: 70dvh; justify-content: center; }

/* ---------- add / preview ---------- */

.picker-hero { padding: 18px 0 8px; }
.picker-hero h1 { margin-bottom: 10px; }
.preview-card {
  position: relative; aspect-ratio: 4 / 5; border-radius: 22px; overflow: hidden; display: grid; place-items: center;
  background: radial-gradient(130% 100% at 50% 35%, var(--card-hi), var(--card) 75%);
}
.preview-card.is-original .preview-img { width: 100%; height: 100%; object-fit: cover; }
.preview-card.is-cut .preview-img { width: 86%; height: 86%; object-fit: contain; filter: drop-shadow(0 10px 16px rgba(0,0,0,.25)); animation: piece-in .5s var(--ease); }
.preview-card.working .preview-img { filter: blur(6px) brightness(.6); transform: scale(1.04); }
.progress { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 20px; }
.edit-img .progress, .wear-edit .progress { position: static; padding: 40px 0; }
.progress-label { font-size: 13.5px; font-weight: 500; max-width: 22em; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--text); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-tools { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 22px; }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sticky-foot { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); z-index: 10; margin-top: 22px; }
.sticky-foot .btn { box-shadow: var(--shadow); }

.burst-summary { margin: 10px 0 18px; }
.burst-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.burst-tile { position: relative; aspect-ratio: 4 / 5; border-radius: var(--radius-s); background: var(--card); display: grid; place-items: center; overflow: hidden; animation: card-in .35s var(--ease); }
.burst-tile img { width: 86%; height: 86%; object-fit: contain; }
.burst-ph { color: var(--text-3); }
.burst-tile.working .burst-ph { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.burst-state { position: absolute; left: 6px; bottom: 6px; right: 6px; font-size: 10.5px; font-weight: 600; display: flex; justify-content: center; padding: 3px 6px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.burst-tile.error .burst-state { color: var(--danger); }
.page-intro { margin: 8px 0 6px; }
.page-intro h1 { margin-bottom: 10px; }

/* ---------- forms ---------- */

.form { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.field-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-2); font-weight: 600; display: flex; align-items: baseline; gap: 4px; margin-top: 4px; }
.field-label small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.req { color: var(--accent); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px 6px; }
.color { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; }
.color-label { font-size: 10.5px; color: var(--text-2); text-align: center; line-height: 1.15; }
.color.on .color-label { color: var(--text); font-weight: 600; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px var(--swatch-ring); }
.swatch.lg { width: 40px; height: 40px; transition: transform .2s var(--ease), box-shadow .2s; }
.color.on .swatch.lg { transform: scale(0.86); box-shadow: inset 0 0 0 1px var(--swatch-ring), 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }
.color-chip { padding-left: 10px; }

.warmth { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.warmth > button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); transition: background .2s, border-color .2s; }
.warmth > button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.w-n { font-weight: 600; font-size: 13px; }
.warmth-label { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-2); }
.w-dots { display: inline-flex; gap: 2px; vertical-align: middle; }
.w-dots i { width: 4px; height: 10px; border-radius: 2px; background: currentColor; opacity: .22; }
.w-dots i.f { opacity: 1; }
.w-dots.inline i { height: 9px; }

.token-input { display: flex; flex-direction: column; gap: 8px; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.tokens:empty { display: none; }
.token { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: 999px; background: var(--surface-3); font-size: 13px; font-weight: 500; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest:empty { display: none; }
.switch-row { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14.5px; }
.switch-row small { margin-left: auto; }
.switch-row input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; margin: 0; transition: background .2s;
}
.switch-row input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch-row input[type="checkbox"]:checked { background: var(--text); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(18px); background: var(--bg); }
.form-error { display: flex; align-items: center; gap: 8px; color: var(--danger); font-size: 14px; }

/* ---------- item detail ---------- */

.hero-img { position: relative; aspect-ratio: 4 / 5; border-radius: 24px; overflow: hidden; display: grid; place-items: center; background: radial-gradient(130% 100% at 50% 35%, var(--card-hi), var(--card) 75%); animation: hero-in .5s var(--ease); }
@keyframes hero-in { from { opacity: 0; transform: scale(0.97); } }
.hero-img img { width: 86%; height: 86%; object-fit: contain; filter: drop-shadow(0 12px 20px rgba(0,0,0,.25)); }
.hero-img img:not(.ready) { opacity: 0; } .hero-img img.ready { opacity: 1; transition: opacity .3s; }
.hero-img .badge { top: 14px; right: 14px; }
.item-head { margin: 22px 0 6px; }
.item-head h1 { font-size: 40px; }
.color-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.color-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.stats { margin: 6px 0 4px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 14px 4px; }
.stat + .stat { border-left: 1px solid var(--line); padding-left: 12px; }
.stat-n { font-family: var(--display); font-size: 34px; line-height: 1; }
.stat-n.small { font-size: 22px; line-height: 1.3; }
.stat-l { font-size: 11.5px; color: var(--text-2); margin-top: 4px; }
.attrs { margin: 18px 0; display: grid; gap: 0; }
.attr { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.attr dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-2); font-weight: 600; padding-top: 3px; }
.attr dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.attr a { text-underline-offset: 3px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 10px; border-radius: 999px; background: var(--surface-3); font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.tag.sys { background: color-mix(in srgb, #3d7be0 25%, var(--surface)); }
.section { margin: 26px 0 8px; }
.section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--text-2); font-weight: 600; margin-bottom: 12px; }
.edit-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.edit-img { width: 96px; aspect-ratio: 4 / 5; border-radius: var(--radius-s); background: var(--card); display: grid; place-items: center; overflow: hidden; }
.edit-img img { width: 86%; height: 86%; object-fit: contain; opacity: 1; }
.edit-img .progress { padding: 0; gap: 6px; }
.edit-img .progress-label, .edit-img span { font-size: 10px; }

/* ---------- today / wear ---------- */

.weather { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; display: flex; flex-direction: column; gap: 14px; }
.weather.off, .weather.loading { flex-direction: row; align-items: center; gap: 10px; padding: 14px 16px; font-size: 13.5px; }
.weather-main { display: flex; align-items: center; gap: 16px; }
.temps { display: flex; align-items: baseline; gap: 10px; }
.t-max { font-family: var(--display); font-size: 52px; line-height: 0.9; }
.t-min { font-family: var(--display); font-size: 30px; color: var(--text-2); }
.weather-side { margin-left: auto; text-align: right; font-size: 13px; color: var(--text-2); }
.weather-suggest { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; text-align: left; }
.rain-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--text); }
.rain-note .ic { color: #5b93ec; }
.today-wear { margin-bottom: 18px; }
.today-visual { display: block; width: 100%; }
.today-wear-meta { display: flex; align-items: center; gap: 10px; padding: 10px 2px; font-size: 14px; }
.today-wear-meta > span:first-child { flex: 1; font-weight: 500; }
.today-empty { padding: 20px; border-radius: var(--radius); border: 1px dashed var(--line-strong); }
.today-empty .btn { width: 100%; margin-top: 12px; }
.wear-photo { aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden; background: var(--card); position: relative; }
.wear-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-x { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.45); color: #fff; }
.wear-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0 4px; }
.wear-preview:empty { display: none; }
.wear-edit .seg { margin: 18px 0 6px; }
.wear-edit .grid.compact { margin: 14px 0; }

/* ---------- calendar ---------- */

.cal-nav { display: flex; gap: 2px; }
.calendar h1.display { text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; touch-action: pan-y; }
.cal-grid.slide-l { animation: slide-l .35s var(--ease); }
.cal-grid.slide-r { animation: slide-r .35s var(--ease); }
@keyframes slide-l { from { opacity: 0; transform: translateX(24px); } }
@keyframes slide-r { from { opacity: 0; transform: translateX(-24px); } }
.cal-wd { text-align: center; font-size: 10.5px; font-weight: 600; color: var(--text-3); padding: 4px 0 6px; letter-spacing: 0.1em; }
.cal-cell { position: relative; aspect-ratio: 4 / 5.6; border-radius: 9px; background: var(--surface); display: block; overflow: hidden; }
.cal-cell.blank { background: none; }
.cal-cell.future { opacity: 0.35; }
.cal-n { position: absolute; top: 4px; left: 5px; font-size: 11px; font-weight: 600; z-index: 3; color: var(--text-2); }
.cal-cell.today .cal-n { color: var(--bg); background: var(--text); border-radius: 999px; padding: 0 5px; left: 3px; top: 3px; }
.cal-cell.has .cal-n { color: var(--text); text-shadow: 0 0 4px var(--bg); }
.cal-thumb { position: absolute; inset: 0; animation: piece-in .4s var(--ease); }
.cal-thumb .board, .cal-thumb .wear-photo { border-radius: 0; height: 100%; aspect-ratio: auto; }
.cal-thumb .board .piece { filter: none; }
.cal-more { position: absolute; bottom: 3px; right: 4px; font-size: 9.5px; font-weight: 700; z-index: 3; background: var(--text); color: var(--bg); border-radius: 999px; padding: 0 4px; }
.cal-summary { font-size: 13px; margin-top: 14px; }
.day-wear { padding: 14px 0; border-bottom: 1px solid var(--line); }
.day-visual { width: 70%; margin: 0 auto 10px; }
.day-meta { font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.day-meta p { margin: 6px 0 0; }

/* ---------- drafts select bar ---------- */

.select-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); z-index: 25;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 18px; border-radius: 999px;
  background: var(--surface-3); box-shadow: var(--shadow); font-size: 14px; font-weight: 500;
  transform: translateY(140%); transition: transform .3s var(--ease);
}
.select-bar > span { flex: 1; }
.select-bar.show { transform: none; }

/* ---------- settings ---------- */

.set-group { padding: 20px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.set-group .section-title { margin-bottom: 0; }
.set-group .link { align-self: flex-start; padding-left: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14.5px; }
.stepper { display: inline-flex; align-items: center; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.stepper button { width: 38px; height: 36px; font-size: 18px; }
.step-v { min-width: 52px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.bands { display: flex; flex-direction: column; gap: 8px; }
.band { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--surface); border: 1px solid var(--line); }
.band-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; min-height: 36px; }
.band-range { display: flex; align-items: center; gap: 6px; }
.band-range .step-v { min-width: 26px; }
.band-range .stepper button { width: 32px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.save-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding-right: 8px; }
.colophon { margin-top: 28px; text-align: center; }

/* ---------- sheets ---------- */

.sheet-wrap { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: opacity .3s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 8px calc(var(--gutter) + var(--safe-r)) calc(var(--safe-b) + 18px) calc(var(--gutter) + var(--safe-l));
  transform: translateY(100%); transition: transform .38s var(--ease);
  max-width: 820px; margin: 0 auto;
}
.sheet.tall { height: 82dvh; }
.sheet.full { height: calc(100dvh - var(--safe-t) - 12px); display: flex; flex-direction: column; overflow: hidden; }
.sheet.full > :last-child { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet-scroll { overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 10px; }
.sheet-wrap.open { pointer-events: auto; }
.sheet-wrap.open .backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; position: sticky; top: 0; }
.sheet-title { font-family: var(--display); font-size: 28px; line-height: 1.05; margin-bottom: 10px; }
.sheet-head .sheet-title { margin: 0; flex: 1; }
.sheet-title.small { font-family: var(--font); font-size: 13px; color: var(--text-2); text-align: center; margin: 4px 0 12px; }
.sheet-foot { position: sticky; bottom: 0; padding-top: 14px; background: linear-gradient(transparent, var(--surface) 30%); }
.group { display: flex; flex-direction: column; border-radius: var(--radius-s); background: var(--surface-2); overflow: hidden; margin-bottom: 10px; }
.row.action { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px 16px; text-align: left; font-size: 15.5px; font-weight: 500; }
.row.action + .row.action { border-top: 1px solid var(--line); }
.row.action small { margin-left: auto; text-align: right; font-size: 12px; font-weight: 400; max-width: 50%; }
.row.action.danger { color: var(--danger); }
.row.action.on { font-weight: 700; }
.row.action > span:first-of-type:not(.ic) { flex: 1; }
.row.action:active { background: var(--surface-3); }
.confirm p { margin: 0 0 16px; }
.btn-col .btn.ghost { border: 0; }
.picker { display: flex; flex-direction: column; gap: 0; height: 100%; }
.picker .filterbar { margin-bottom: 12px; }
.picker-grid { padding-bottom: 30px; }

/* ---------- toast, pills ---------- */

#toast { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 80; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .3s var(--ease); }
#toast.top { bottom: auto; top: calc(var(--safe-t) + 10px); }
#toast.show { opacity: 1; transform: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 520px; padding: 12px 16px 12px 18px; border-radius: 16px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }
.toast button { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.status-pills { position: fixed; top: calc(var(--safe-t) + 6px); left: 0; right: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.pill { pointer-events: auto; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--surface-3); color: var(--text); box-shadow: var(--shadow); }
.offline-pill { display: none; }
body.is-offline .offline-pill { display: block; }
.outbox-pill { background: #f0b43a; color: #1a1306; }

/* ---------- login, splash ---------- */

.login { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: calc(var(--safe-t) + 24px) 24px calc(var(--safe-b) + 24px); transition: opacity .3s; }
.login.leaving { opacity: 0; }
.login-card { width: 100%; max-width: 360px; animation: view-in .6s var(--ease); }
.login-card h1.display { font-size: 64px; margin: 6px 0 14px; }
.login-card p { margin: 0 0 32px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-kicker { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.2em; color: var(--text-2); }
.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash-mark { font-family: var(--display); font-size: 64px; font-style: italic; opacity: .9; animation: pulse 1.6s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
body:has(.sticky-foot) #toast:not(.top), body:has(.select-bar.show) #toast:not(.top) { bottom: calc(var(--tabbar-h) + var(--safe-b) + 76px); }
#toast:not(.show) .toast { pointer-events: none; }
