:root {
  --bg: #F6F2EA; --surface: #FFFFFF; --ink: #1D2A24; --muted: #55605A;
  --line: #E2DACB; --line2: #CFC6B4; --track: #ECE5D7;
  --primary: #1F4D3A; --on-primary: #FFFFFF; --on-primary-soft: #D9E6DE; --accent: #1F4D3A;
  --success-bg: #DCEBE2; --warn-bg: #F6E7C8; --warn-ink: #5C3F0A;
  --banner-bg: #EDE4D2; --banner-ink: #3D3524; --danger: #A8323E;
  --toast-bg: #1D2A24; --toast-fg: #F6F2EA;
  --display: 'Bricolage Grotesque', Inter, system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="donker"] {
  --bg: #121714; --surface: #1B211E; --ink: #ECE8DF; --muted: #A3ADA7;
  --line: #2E3531; --line2: #4A524D; --track: #2A302C;
  --primary: #2E6B52; --accent: #93CDB0;
  --success-bg: #1E3B2E; --warn-bg: #3A2E17; --warn-ink: #F0D49A;
  --banner-bg: #2A2620; --banner-ink: #E8DCC0; --danger: #F08A94;
  --toast-bg: #ECE8DF; --toast-fg: #121714;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #121714; --surface: #1B211E; --ink: #ECE8DF; --muted: #A3ADA7;
    --line: #2E3531; --line2: #4A524D; --track: #2A302C;
    --primary: #2E6B52; --accent: #93CDB0;
    --success-bg: #1E3B2E; --warn-bg: #3A2E17; --warn-ink: #F0D49A;
    --banner-bg: #2A2620; --banner-ink: #E8DCC0; --danger: #F08A94;
    --toast-bg: #ECE8DF; --toast-fg: #121714;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, system-ui, sans-serif; }
h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { max-width: 480px; min-height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 20px; padding: 16px 20px 32px; padding-top: max(16px, env(safe-area-inset-top)); }
.screen.has-bar { padding-bottom: 130px; }
.screen.has-bar-2 { padding-bottom: 190px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.display { font-family: var(--display); font-weight: 700; line-height: 1.1; }
h1.display { font-size: 30px; }
.topbar { display: flex; align-items: center; gap: 4px; margin: 0 -8px; min-height: 44px; }
.topbar h1 { font-family: var(--display); font-size: 24px; font-weight: 700; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.eyebrow.red { color: var(--danger); }

.icon-btn { flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.icon-btn.soft { background: var(--bg); color: var(--muted); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 16px; border-radius: 16px; border: 0; background: var(--primary); color: var(--on-primary); font-size: 17px; font-weight: 600; text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.btn.quiet { background: var(--surface); color: var(--ink); border: 1px solid var(--line2); }
.btn.danger { background: var(--surface); color: var(--danger); border: 1px solid var(--line2); }
.btn.small { min-height: 44px; border-radius: 12px; font-size: 15px; }
.btn[disabled] { opacity: .6; cursor: default; }
.link-btn { align-self: center; min-height: 44px; border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; }

.card { padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--banner-bg); color: var(--banner-ink); font-size: 14px; }
.banner svg { flex-shrink: 0; margin-top: 1px; }
.banner.green { background: var(--success-bg); color: var(--accent); align-items: center; }
.hint { padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--line2); font-size: 13px; color: var(--muted); }

.avatar { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.avatar.s { width: 26px; height: 26px; font-size: 12px; }
.avatar.m { width: 34px; height: 34px; font-size: 14px; }
.avatar.l { width: 44px; height: 44px; font-size: 17px; }
.avatars { display: flex; }
.avatars .avatar { margin-right: -6px; border: 2px solid var(--warn-bg); }

.logo { width: 56px; height: 56px; border-radius: 18px; background: var(--primary); color: #F6F2EA; display: flex; align-items: center; justify-content: center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 14px; font-weight: 600; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input, .field textarea { width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); font-size: 16px; }
.field textarea { padding: 12px 14px; resize: none; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { font-size: 14px; color: var(--danger); }

.mine-card { display: flex; flex-direction: column; gap: 14px; width: 100%; padding: 20px; border-radius: 20px; border: 0; background: var(--primary); color: #F6F2EA; text-align: left; text-decoration: none; }
.mine-card .title { font-family: var(--display); font-size: 22px; font-weight: 700; }
.mine-card .sub { color: var(--on-primary-soft); }
.pill { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 8px 14px; border-radius: 999px; background: #F6F2EA; color: #1F4D3A; font-size: 14px; font-weight: 600; }

.person { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; text-decoration: none; }
.person .name { font-size: 17px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--primary); }

.wish { display: flex; flex-direction: column; gap: 12px; }
.wish .head { display: flex; gap: 12px; align-items: flex-start; }
.wish .title { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.wish .note { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.wish .price { flex-shrink: 0; font-weight: 600; }
.thumb { flex-shrink: 0; width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.photo { display: block; width: 100%; height: 220px; border-radius: 18px; object-fit: cover; }
.meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.meta a { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; min-height: 32px; }

.status { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.status.bought { background: var(--success-bg); color: var(--accent); font-weight: 600; }
.status.together { background: var(--warn-bg); color: var(--warn-ink); }
.status.free { border: 1px dashed var(--line2); color: var(--muted); }
.actions { display: flex; gap: 8px; }
.actions > * { flex: 1; }

.bottombar { position: fixed; left: 0; right: 0; bottom: 0; }
.bottombar > div { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; padding: 16px 20px; padding-bottom: max(24px, env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }

.photo-pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 120px; border-radius: 14px; border: 1px dashed var(--line2); background: var(--surface); color: var(--accent); font-size: 15px; font-weight: 600; cursor: pointer; }
.photo-pick span { font-size: 13px; font-weight: 400; color: var(--muted); }
.photo-wrap { position: relative; }
.photo-wrap img { display: block; width: 100%; height: 180px; border-radius: 14px; object-fit: cover; }
.photo-wrap button { position: absolute; right: 10px; bottom: 10px; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: #1D2A24; color: #FFFFFF; font-size: 14px; font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.theme { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; }
.theme[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--success-bg); padding: 11px 5px; }
.theme i { width: 54px; height: 40px; border-radius: 8px; border: 1px solid var(--line2); }
.list-card { border-radius: 16px; border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.list-card > * { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; font-size: 15px; }
.list-card > *:last-child { border-bottom: 0; }

#toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: calc(100% - 40px); max-width: 440px; padding: 12px 16px; border-radius: 14px; background: var(--toast-bg); color: var(--toast-fg); font-size: 14px; font-weight: 500; text-align: center; z-index: 10; }
.loading { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); }
