:root {
  --bg: #fffefb; --surface: #ffffff; --sand: #f5f1eb; --border: #ede7df;
  --text: #1a1a1a; --muted: #6b5e53; --accent: #8c3d00; --accent-soft: #fff3eb; --accent-line: #f2c9b1;
  --ink: #1a1a1a; --on-ink: #fffefb; --danger: #b3261e; --ok: #2e6b3f;
  --radius: 10px; --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 14px rgb(0 0 0 / 5%);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210; --surface: #1e1b18; --sand: #26221e; --border: #332e29;
    --text: #f3eee8; --muted: #a89c90; --accent: #e8a36b; --accent-soft: #2b2018; --accent-line: #5a3b22;
    --ink: #f3eee8; --on-ink: #141210; --danger: #f2877f; --ok: #7fc08f;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 14px rgb(0 0 0 / 30%);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans);
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.hidden { display: none !important; }

.container { max-width: 720px; margin: 0 auto; padding: 1rem; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--border);
  padding: .75rem 1rem; padding-top: calc(.75rem + env(safe-area-inset-top));
}
.topbar-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; letter-spacing: .01em; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; background: var(--bg); border-top: 1px solid var(--border);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: flex; width: 100%; max-width: 720px; }
.tab {
  flex: 1; border: 0; background: none; color: var(--muted); padding: .55rem .25rem; font: inherit; font-size: .75rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.tab .ico { font-size: 1.25rem; line-height: 1; }
.tab[aria-current='page'] { color: var(--accent); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .85rem; box-shadow: var(--shadow); }
.card.accent { background: var(--accent-soft); border-color: var(--accent-line); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.section-title { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1.1rem 0 .45rem; font-weight: 600; }

.btn {
  font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--on-ink);
  padding: .65rem 1.1rem; cursor: pointer; min-height: 44px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .35rem .7rem; min-height: 34px; font-size: .85rem; }
.btn.block { width: 100%; }
.linklike { background: none; border: 0; color: var(--accent); font: inherit; padding: 0; cursor: pointer; text-decoration: underline; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .7rem; min-height: 44px;
}
input[type='color'] { padding: .15rem; }
input[type='range'] { padding: 0; min-height: 30px; }
input[type='checkbox'] { width: 22px; height: 22px; min-height: 0; }
textarea { min-height: 80px; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { margin-bottom: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.error { color: var(--danger); font-size: .9rem; margin: .4rem 0; }
.notice { background: var(--sand); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; margin-bottom: .8rem; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  font: inherit; font-size: .9rem; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .4rem .8rem; border-radius: 999px; cursor: pointer; min-height: 38px;
}
.chip[aria-pressed='true'] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--sand); color: var(--muted); }
.badge.warn { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }

.weather { display: flex; align-items: center; gap: .8rem; }
.weather .temp { font-family: var(--serif); font-size: 1.8rem; }

.items-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
@media (min-width: 560px) { .items-grid { grid-template-columns: repeat(3, 1fr); } }
.item-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; }
.thumb { aspect-ratio: 1 / 1; width: 100%; object-fit: cover; display: block; background: var(--sand); }
.thumb.placeholder { display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.item-meta { padding: .5rem .6rem .6rem; }
.item-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--border); vertical-align: middle; margin-right: 4px; }

.outfit-items { display: flex; gap: .5rem; margin: .6rem 0; overflow-x: auto; }
.outfit-items .mini { width: 72px; flex: none; text-align: center; font-size: .72rem; }
.outfit-items .thumb { border-radius: 8px; }
.reason { font-size: .9rem; margin: .25rem 0; }
.reason b { font-weight: 600; }

.stars { display: inline-flex; }
.star { background: none; border: 0; font-size: 1.4rem; color: var(--border); cursor: pointer; padding: 0 .1rem; min-height: 36px; }
.star.on { color: var(--accent); }

.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 50%); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .overlay { align-items: center; } .modal { border-radius: 16px; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--on-ink); padding: .65rem 1rem; border-radius: 8px; z-index: 30; max-width: 90vw; font-size: .9rem; }
.toast-error { background: var(--danger); color: #fff; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.4rem; }
.auth { max-width: 420px; margin: 0 auto; padding: 2rem 1rem; }
.auth h1 { text-align: center; font-size: 2rem; }
.photo-preview { width: 100%; max-height: 260px; object-fit: contain; background: var(--sand); border-radius: 8px; margin-bottom: .6rem; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.pack-row { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; font-weight: 400; margin: 0; cursor: pointer; }
.pack-row input { flex: none; }
.pack-thumb { width: 40px; flex: none; }
.pack-thumb .thumb { border-radius: 6px; font-size: 1.1rem; }
.pack-row span:nth-of-type(1) { flex: 1; }
.trip-outfit { margin-top: .4rem; }
button.card.item-card { width: 100%; display: block; text-align: left; font: inherit; color: inherit; }
.notice ul { margin: .3rem 0 0; padding-left: 1.2rem; }

.danger-zone { margin-top: 3rem; font-size: .85rem; color: var(--muted, #888); }
.danger-zone summary { cursor: pointer; opacity: .6; }
.danger-zone[open] summary { opacity: 1; }
.danger-zone .btn { margin-top: .6rem; }

.limit-input { width: 7.5rem; }

/* Lookbook */
.swipe-area { position: relative; display: flex; justify-content: center; padding: 1rem 0; touch-action: pan-y; }
.swipe-card { position: relative; width: min(100%, 340px); background: var(--card, #fff); border: 1px solid var(--line, #ddd); border-radius: 16px; padding: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.12); cursor: grab; user-select: none; transition: transform .15s ease; }
.swipe-card:active { cursor: grabbing; transition: none; }
.swipe-pieces { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: .5rem; }
.swipe-piece .thumb { border-radius: 10px; }
.swipe-stamp { position: absolute; top: .6rem; left: .6rem; font-weight: 700; font-size: 1.1rem; z-index: 1; }
.swipe-actions { justify-content: center; gap: 1rem; }
.basics-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.swipe-card:focus { outline: none; }
.swipe-card:focus-visible { outline: 2px solid var(--accent, #555); outline-offset: 3px; }
.swipe-context { text-align: center; font-weight: 700; font-size: 1.05rem; color: var(--ink, #111); margin-top: .4rem; }
