/* Sakubill: eight selectable themes, system rounded fonts only, no external requests. */
/* Sakubill: themes. Colour tokens live in the :root[data-theme] blocks at the bottom of the tokens section;
   component rules use only var(--token). Default (no attribute) = Night Sakura. Ids: sakura, pink-white, teal-black,
   gold-black, gold-white, red-black, blue-black, pink-gold. tests/themes.test.js parses these blocks and checks contrast. */
:root {
  --radius: 22px; --radius-sm: 16px;
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Yu Gothic UI", "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK JP", "Noto Sans CJK SC", sans-serif; /* CJK entries are system fonts only: no web fonts */
  --serif: var(--font);
  --tab-h: 68px;
}
/* sakura */
:root, :root[data-theme="sakura"] {
  color-scheme: dark;
  --bg: #170F24; --surface: #231736; --surface-2: #2D1F45; --ink: #FFF1F7;
  --muted: #C9B8DB; --line: #3A2A57; --accent: #FF9EC4; --accent-fill: #FF7FB0;
  --accent-ink: #2A0F22; --accent-hover: #FFB3D1; --accent-soft: #35204D; --field-line: #8A75B8;
  --lilac: #B9A5FF; --mint: #8EE8D0; --danger: #FF9AA8; --on-danger: #2A0F22;
  --warn-bg: #3F2A4A; --warn-ink: #FFD68A; --ok-bg: #1F3340; --ok-ink: #8EE8D0;
  --focus: #FFD1E5; --shadow: 0 1px 2px rgba(10, 4, 20, .5), 0 8px 24px rgba(10, 4, 20, .45), 0 0 24px rgba(255, 158, 196, .06); --glow: 0 0 18px rgba(255, 127, 176, .35); --glow-drop: rgba(255, 127, 176, .5);
  --scrim: rgba(10, 4, 20, .75); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .35); --hero-spot: #4A2766; --fan-line: #5A3F85;
  --fan-bg2: #2A1D45; --fan-badge-bg: #3B2B66; --fan-badge-ink: #D9CCFF; --petal-1: #FF9EC4;
  --petal-2: #FFB3D1; --petal-3: #B9A5FF; --accent-strong: #FFB3D1; --mark-face: #FFF1F7;
  --mark-ink: #2A0F22; --edge: rgba(255, 255, 255, .22); --plate: #3A2A57;
}
/* pink-white */
:root[data-theme="pink-white"] {
  color-scheme: light;
  --bg: #FFF6F9; --surface: #FFFFFF; --surface-2: #FFEAF1; --ink: #3A1A2E;
  --muted: #6F4A5F; --line: #F3D2E0; --accent: #B3185C; --accent-fill: #FF8DB6;
  --accent-ink: #3A0F26; --accent-hover: #FFAACB; --accent-soft: #FFE1EC; --field-line: #B07A95;
  --lilac: #6446C4; --mint: #1B7A5E; --danger: #B3203A; --on-danger: #FFFFFF;
  --warn-bg: #FFF0C7; --warn-ink: #6E4300; --ok-bg: #DDF5EA; --ok-ink: #13694F;
  --focus: #A3124F; --shadow: 0 1px 2px rgba(120, 50, 85, .10), 0 8px 24px rgba(150, 60, 100, .12); --glow: 0 0 16px rgba(255, 141, 182, .35); --glow-drop: rgba(255, 105, 160, .35);
  --scrim: rgba(70, 25, 50, .55); --shadow-lg: 0 20px 60px rgba(90, 30, 60, .25); --hero-spot: #FFD3E3; --fan-line: #D9C2F0;
  --fan-bg2: #F4ECFF; --fan-badge-bg: #E9DDFB; --fan-badge-ink: #4A2E96; --petal-1: #FF8DB6;
  --petal-2: #FFB3CF; --petal-3: #B9A5FF; --accent-strong: #8E0F47; --mark-face: #FFFFFF;
  --mark-ink: #3A0F26; --edge: rgba(90, 30, 60, .35); --plate: #FFDDE9;
}
/* teal-black */
:root[data-theme="teal-black"] {
  color-scheme: dark;
  --bg: #0A1416; --surface: #112124; --surface-2: #182E31; --ink: #EAFBF8;
  --muted: #A9C9C5; --line: #1F3B3E; --accent: #5EE0D0; --accent-fill: #2DD4BF;
  --accent-ink: #04201D; --accent-hover: #7DEBDD; --accent-soft: #12393A; --field-line: #5F9390;
  --lilac: #A9B8FF; --mint: #9BF0C0; --danger: #FF9AA8; --on-danger: #2A0710;
  --warn-bg: #3A2F17; --warn-ink: #FFD68A; --ok-bg: #12382B; --ok-ink: #8EE8B5;
  --focus: #B8FFF4; --shadow: 0 1px 2px rgba(0, 8, 10, .5), 0 8px 24px rgba(0, 8, 10, .45), 0 0 24px rgba(94, 224, 208, .06); --glow: 0 0 18px rgba(45, 212, 191, .30); --glow-drop: rgba(45, 212, 191, .45);
  --scrim: rgba(2, 10, 12, .78); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .4); --hero-spot: #14504F; --fan-line: #3F5F9A;
  --fan-bg2: #16233D; --fan-badge-bg: #25376A; --fan-badge-ink: #D3DBFF; --petal-1: #5EE0D0;
  --petal-2: #9BF0C0; --petal-3: #A9B8FF; --accent-strong: #7DEBDD; --mark-face: #EAFBF8;
  --mark-ink: #04201D; --edge: rgba(255, 255, 255, .22); --plate: #1F4A4C;
}
/* gold-black */
:root[data-theme="gold-black"] {
  color-scheme: dark;
  --bg: #14100A; --surface: #211A12; --surface-2: #2D2318; --ink: #FFF6E2;
  --muted: #CFBD9A; --line: #40321F; --accent: #F5C451; --accent-fill: #EDB53C;
  --accent-ink: #231805; --accent-hover: #FFD777; --accent-soft: #35291A; --field-line: #93794B;
  --lilac: #D7B8FF; --mint: #9EE6C0; --danger: #FF9C8F; --on-danger: #2A0A06;
  --warn-bg: #43301A; --warn-ink: #FFD68A; --ok-bg: #1F3426; --ok-ink: #9EE6B8;
  --focus: #FFE29A; --shadow: 0 1px 2px rgba(8, 5, 0, .5), 0 8px 24px rgba(8, 5, 0, .45), 0 0 24px rgba(245, 196, 81, .06); --glow: 0 0 18px rgba(237, 181, 60, .30); --glow-drop: rgba(237, 181, 60, .45);
  --scrim: rgba(10, 6, 0, .78); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .4); --hero-spot: #5A4217; --fan-line: #6B4F86;
  --fan-bg2: #2B2036; --fan-badge-bg: #40305A; --fan-badge-ink: #E6D6FF; --petal-1: #F5C451;
  --petal-2: #FFD777; --petal-3: #D7B8FF; --accent-strong: #FFD777; --mark-face: #FFF6E2;
  --mark-ink: #231805; --edge: rgba(255, 255, 255, .22); --plate: #40321F;
}
/* gold-white */
:root[data-theme="gold-white"] {
  color-scheme: light;
  --bg: #FFFBF2; --surface: #FFFFFF; --surface-2: #FFF3D9; --ink: #33250F;
  --muted: #6B5836; --line: #F0DFB8; --accent: #855400; --accent-fill: #F6BF3F;
  --accent-ink: #2B1C00; --accent-hover: #FFD36B; --accent-soft: #FFF0CB; --field-line: #A88A48;
  --lilac: #6446C4; --mint: #1B7A5E; --danger: #B3203A; --on-danger: #FFFFFF;
  --warn-bg: #FFE9B8; --warn-ink: #6A3F00; --ok-bg: #DDF3E6; --ok-ink: #13694F;
  --focus: #7A4A00; --shadow: 0 1px 2px rgba(110, 80, 20, .10), 0 8px 24px rgba(140, 100, 20, .12); --glow: 0 0 16px rgba(246, 191, 63, .40); --glow-drop: rgba(230, 170, 40, .40);
  --scrim: rgba(60, 40, 5, .55); --shadow-lg: 0 20px 60px rgba(80, 55, 10, .25); --hero-spot: #FFE3A0; --fan-line: #D9C8F0;
  --fan-bg2: #F6EEFF; --fan-badge-bg: #EADFFB; --fan-badge-ink: #4A2E96; --petal-1: #F6BF3F;
  --petal-2: #FFD98A; --petal-3: #C4A8F5; --accent-strong: #6B4300; --mark-face: #FFFFFF;
  --mark-ink: #2B1C00; --edge: rgba(80, 55, 10, .35); --plate: #FFE9B8;
}
/* red-black */
:root[data-theme="red-black"] {
  color-scheme: dark;
  --bg: #140A0C; --surface: #221216; --surface-2: #2E1A1F; --ink: #FFF0EF;
  --muted: #D3B6B8; --line: #44252B; --accent: #FF7378; --accent-fill: #FF5A62;
  --accent-ink: #26050A; --accent-hover: #FF8E92; --accent-soft: #3A1B22; --field-line: #9C6D73;
  --lilac: #E2B4FF; --mint: #8EE8D0; --danger: #FFC9A8; --on-danger: #2A0F06;
  --warn-bg: #43301A; --warn-ink: #FFD68A; --ok-bg: #1F3426; --ok-ink: #9EE6B8;
  --focus: #FFD5D2; --shadow: 0 1px 2px rgba(10, 2, 4, .5), 0 8px 24px rgba(10, 2, 4, .45), 0 0 24px rgba(255, 90, 98, .06); --glow: 0 0 18px rgba(255, 90, 98, .30); --glow-drop: rgba(255, 90, 98, .45);
  --scrim: rgba(12, 2, 4, .78); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .4); --hero-spot: #5E1F2B; --fan-line: #7A4A8A;
  --fan-bg2: #2C1830; --fan-badge-bg: #47285A; --fan-badge-ink: #F0D9FF; --petal-1: #FF7378;
  --petal-2: #FF9EA2; --petal-3: #E2B4FF; --accent-strong: #FF8E92; --mark-face: #FFF0EF;
  --mark-ink: #26050A; --edge: rgba(255, 255, 255, .22); --plate: #44252B;
}
/* blue-black */
:root[data-theme="blue-black"] {
  color-scheme: dark;
  --bg: #0A1020; --surface: #121B33; --surface-2: #1A2644; --ink: #EEF4FF;
  --muted: #AEBBD6; --line: #26365A; --accent: #7DB4FF; --accent-fill: #5B9DFF;
  --accent-ink: #06142E; --accent-hover: #9CC6FF; --accent-soft: #1A2F57; --field-line: #6A82B0;
  --lilac: #BBA9FF; --mint: #8EE8D0; --danger: #FF9AA8; --on-danger: #2A0710;
  --warn-bg: #3A3018; --warn-ink: #FFD68A; --ok-bg: #12382F; --ok-ink: #8EE8D0;
  --focus: #C6DDFF; --shadow: 0 1px 2px rgba(2, 6, 18, .5), 0 8px 24px rgba(2, 6, 18, .45), 0 0 24px rgba(125, 180, 255, .06); --glow: 0 0 18px rgba(91, 157, 255, .32); --glow-drop: rgba(91, 157, 255, .5);
  --scrim: rgba(2, 6, 18, .78); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .4); --hero-spot: #23458A; --fan-line: #5A4A9A;
  --fan-bg2: #1C1A3C; --fan-badge-bg: #33296A; --fan-badge-ink: #DDD5FF; --petal-1: #7DB4FF;
  --petal-2: #9CC6FF; --petal-3: #BBA9FF; --accent-strong: #9CC6FF; --mark-face: #EEF4FF;
  --mark-ink: #06142E; --edge: rgba(255, 255, 255, .22); --plate: #26365A;
}
/* pink-gold */
:root[data-theme="pink-gold"] {
  color-scheme: light;
  --bg: #FFDCE8; --surface: #FFEEF4; --surface-2: #FFD0E1; --ink: #3A0F2E;
  --muted: #6B3558; --line: #EDB0C8; --accent: #7A4600; --accent-fill: #F5B73A;
  --accent-ink: #2B1700; --accent-hover: #FFCF63; --accent-soft: #FFE6B5; --field-line: #A24C78;
  --lilac: #5B34B0; --mint: #13694F; --danger: #A8173A; --on-danger: #FFFFFF;
  --warn-bg: #FFF0C2; --warn-ink: #633A00; --ok-bg: #DCF3E6; --ok-ink: #0F5E46;
  --focus: #5A1A66; --shadow: 0 1px 2px rgba(130, 40, 85, .12), 0 8px 24px rgba(160, 50, 100, .16); --glow: 0 0 16px rgba(245, 183, 58, .45); --glow-drop: rgba(245, 183, 58, .5);
  --scrim: rgba(80, 20, 55, .55); --shadow-lg: 0 20px 60px rgba(100, 25, 65, .28); --hero-spot: #FFC6D9; --fan-line: #D3A8E8;
  --fan-bg2: #F6DFF3; --fan-badge-bg: #E6D2F7; --fan-badge-ink: #47238F; --petal-1: #F5B73A;
  --petal-2: #FFD27A; --petal-3: #FF8DB6; --accent-strong: #6A3C00; --mark-face: #FFF4F8;
  --mark-ink: #2B1700; --edge: rgba(100, 25, 65, .38); --plate: #FFE6EF;
}
/* Per-language order so Han characters pick the right regional glyphs. */
:root:lang(ja) { --font: ui-rounded, "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Noto Sans CJK JP", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
:root:lang(zh-Hans), :root:lang(zh) { --font: ui-rounded, "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
/* CJK has no spaces: let text wrap anywhere sensible, never overflow a narrow card. */
body { overflow-wrap: break-word; line-break: auto; }
:root:lang(ja) body, :root:lang(zh-Hans) body { word-break: normal; line-break: normal; }
:root:lang(ja) .eyebrow, :root:lang(zh-Hans) .eyebrow, :root:lang(ja) .cmp-who, :root:lang(zh-Hans) .cmp-who { letter-spacing: .02em; text-transform: none; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0; font-weight: 600; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--accent); }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; margin-top: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.upper { text-transform: uppercase; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
#view:focus { outline: none; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 8px; }

/* shell */
#shell { min-height: 100vh; min-height: 100dvh; }
.app-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand > div { display: flex; flex-direction: column; min-width: 0; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; letter-spacing: .01em; }
.brand-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.btn-add-header { display: none; }
#view { display: block; max-width: 760px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .tab-add svg { background: var(--accent-fill); stroke: var(--accent-ink); border-radius: 50%; padding: 4px; width: 32px; height: 32px; }
.tabbar .tab-add[aria-current="page"] { color: var(--ink); }

@media (min-width: 900px) {
  #shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "head head" "nav strip" "nav main"; }
  .cmp-strip { grid-area: strip; margin: 0; max-width: 820px; }
  .app-header { grid-area: head; }
  .btn.btn-add-header { display: inline-flex; }
  #view { grid-area: main; width: 100%; padding-bottom: 48px; margin: 0; max-width: 820px; justify-self: start; }
  .tabbar { grid-area: nav; position: sticky; top: 64px; align-self: start; height: auto; flex-direction: column; background: transparent; border: 0; padding: 16px 12px; gap: 4px; }
  .tabbar a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; min-height: 48px; border-radius: 16px; font-size: .95rem; }
  .tabbar a[aria-current="page"] { background: var(--accent-soft); }
  .tabbar .tab-add { display: none; }
  .hide-desktop-add { display: none; }
}

/* layout bits */
.screen { display: flex; flex-direction: column; gap: 14px; }
.screen-title { font-size: 1.7rem; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eyebrow { font-family: var(--font); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.hero { background: linear-gradient(160deg, var(--surface), var(--accent-soft)); }
.hero-amount { font-family: var(--serif); font-size: clamp(2.2rem, 9vw, 3.2rem); line-height: 1; font-weight: 600; }
.hero-amount small { font-family: var(--font); font-size: 1rem; color: var(--muted); font-weight: 500; }
.hero-sub { color: var(--muted); }
.notice { border-radius: 12px; padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.warn a { color: inherit; font-weight: 600; }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }
.empty { align-items: center; text-align: center; padding: 28px 20px; }
.empty-art { color: var(--ink); }
.empty p { max-width: 42ch; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.empty .row-actions { justify-content: center; }
.count { font-size: .85rem; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: 600 1rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-accent { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.btn-accent { box-shadow: var(--glow); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; padding: 0 10px; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger-outline { color: var(--danger); border-color: var(--danger); background: transparent; }

/* lists and rows */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li + li { border-top: 1px solid var(--line); }
.card-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 4px; text-decoration: none; color: inherit; }
.card-list .row { padding: 12px 14px; }
.row:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-titleline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-title { font-weight: 650; overflow-wrap: anywhere; }
.row-sub { font-size: .85rem; color: var(--muted); }
.row-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; flex-direction: column; }
.row-amount small { color: var(--muted); font-size: .72rem; }
.is-trial { background: var(--accent-soft); border-radius: 10px; }
.is-archived { opacity: .65; }
.chip { flex: none; min-width: 86px; text-align: center; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); font-size: .8rem; font-weight: 700; }
.chip-soon { background: var(--warn-bg); color: var(--warn-ink); }
.chip-trial { background: var(--accent-fill); color: var(--accent-ink); }
.badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-trial { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); align-self: flex-start; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.mchip { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; padding: 2px 8px 2px 6px; border: 1px solid var(--line); border-radius: 999px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px var(--edge); }
.avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; box-shadow: 0 0 0 1px var(--edge); }
.avatar-lg { width: 40px; height: 40px; font-size: 1rem; }

/* duplicates + bars */
.dup { border-color: var(--accent); }
.dup-group + .dup-group { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 2px; }
.dup-reason { font-weight: 650; margin-bottom: 6px; }
.dup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dup-list li { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.dup-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.bar-label.with-avatar { display: flex; align-items: center; gap: 8px; }
.bar-val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.bar { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field.grow { flex: 1 1 220px; }
label, legend { font-weight: 600; font-size: .9rem; padding: 0; }
input[type=text], input[type=number], input[type=search], input[type=date], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 14px; border: 1.5px solid var(--field-line); background: var(--bg); color: var(--ink); font: inherit;
}
textarea { resize: vertical; }
input[aria-invalid="true"] { border-color: var(--danger); border-style: dashed; border-width: 2px; }
.err { color: var(--danger); font-size: .85rem; font-weight: 600; }
.err::before { content: "\26A0\FE0E\00a0"; } /* icon + text: errors never rely on colour alone (matters on the red theme) */
.form-err { padding: 8px 0; }
.form { display: flex; flex-direction: column; gap: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; font-size: 1rem; cursor: pointer; }
.check input, .pick input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 10px; border: 1.5px solid var(--field-line); border-radius: 999px; font-weight: 500; font-size: 1rem; cursor: pointer; background: var(--surface); }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--field-line); background: var(--surface); color: var(--ink); font: 600 .9rem var(--font); cursor: pointer; }
.toggle[aria-pressed="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.form-actions { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; }
.toolbar .field:not(.grow) { flex: 1 1 140px; }
.toolbar .check { flex: 1 1 100%; min-height: 44px; }
.inline-form { display: flex; gap: 10px; }
.inline-form input { flex: 1; }
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.members li { display: flex; align-items: center; gap: 10px; }
.members input[type=text] { flex: 1; min-width: 0; }
.color { width: 48px; height: 44px; padding: 2px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; flex: none; }
.rates { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.rates li { display: flex; flex-direction: column; gap: 6px; }
.rate-row { display: flex; align-items: center; gap: 10px; }
.rate-row label { min-width: 72px; font-size: 1rem; }
.rate-row input { max-width: 160px; }
.rate-unit { font-weight: 600; }

/* sheet + dialogs */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; justify-content: center; animation: rise .22s ease-out; }
.sheet-panel { width: 100%; max-width: 640px; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.1rem; }
.sheet-head-spacer { width: 80px; }
.sheet-head .btn-ghost { width: 80px; justify-content: flex-start; color: var(--accent); white-space: nowrap; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); overscroll-behavior: contain; }
@media (min-width: 700px) {
  .sheet { background: var(--scrim); align-items: center; }
  .sheet-panel { max-height: min(92vh, 860px); border-radius: 28px; overflow: hidden; box-shadow: var(--shadow-lg); }
}
.confirm { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: var(--scrim); }
.confirm-box { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); z-index: 70; transform: translate(-50%, 20px);
  max-width: min(92vw, 460px); display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .2s, transform .2s, visibility .2s;
}
.toast.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); }
.toast:empty { display: none; }
/* While a full-screen sheet is open, keep the toast off its bottom rows: show it just under the sheet header instead. */
body.sheet-open .toast { bottom: auto; top: calc(56px + env(safe-area-inset-top)); transform: translate(-50%, -12px); }
body.sheet-open .toast.show { transform: translate(-50%, 0); }
.toast-btn { min-height: 44px; min-width: 44px; padding: 0 12px; background: transparent; border: 0; color: inherit; font: 700 .95rem var(--font); text-decoration: underline; cursor: pointer; border-radius: 8px; }
.toast :focus-visible { outline-color: var(--bg); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* cancel links (only rendered for stored https:// URLs) */
.has-cancel { position: relative; }
.row-cancel { display: inline-block; margin: 0 16px 10px 64px; font-size: .85rem; font-weight: 600; color: var(--accent, inherit); }
.cancel-link-box { margin: 16px 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* sakura decoration */
.app-header { overflow: hidden; }
.app-header::after {
  content: ""; position: absolute; right: -10px; top: -14px; width: 110px; height: 70px; pointer-events: none; opacity: .5; z-index: -1;
  background:
    radial-gradient(ellipse 7px 5px at 20% 60%, var(--petal-1) 98%, transparent),
    radial-gradient(ellipse 5px 4px at 50% 30%, var(--petal-2) 98%, transparent),
    radial-gradient(ellipse 6px 4px at 78% 70%, var(--petal-3) 98%, transparent);
}
.brand-mark { filter: drop-shadow(0 0 6px var(--glow-drop)); }
.brand-mark, .empty-mascot { color: var(--accent); fill: currentColor; }
.hero { background: radial-gradient(120% 140% at 100% 0%, var(--hero-spot) 0%, transparent 55%), linear-gradient(160deg, var(--surface), var(--accent-soft)); box-shadow: var(--shadow), var(--glow); }
.hero-amount { color: var(--accent-strong); }
.fan-card { border-color: var(--fan-line); background: linear-gradient(160deg, var(--surface), var(--fan-bg2)); }
.fan-amount { font-size: 1.6rem; font-weight: 700; color: var(--lilac); }
.fan-amount small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.badge-fan { background: var(--fan-badge-bg); color: var(--fan-badge-ink); }
.chip-trial, .tabbar .tab-add svg { box-shadow: var(--glow); }
.empty-art { position: relative; display: inline-block; width: 120px; height: 100px; }
.empty-mascot { position: absolute; left: 18px; top: 8px; filter: drop-shadow(0 0 14px var(--glow-drop)); animation: sway 5s ease-in-out infinite; transform-origin: 50% 90%; }
.petal { position: absolute; width: 10px; height: 8px; border-radius: 80% 0 80% 0; background: var(--accent); opacity: .75; animation: drift 6s ease-in-out infinite; }
.petal.p1 { left: 4px; top: 10px; }
.petal.p2 { right: 8px; top: 2px; background: var(--lilac); animation-delay: -1.5s; }
.petal.p3 { right: 0; top: 60px; animation-delay: -3s; }
.petal.p4 { left: 10px; top: 76px; background: var(--accent-hover); animation-delay: -4s; }
.petal.p5 { left: 56px; top: 94px; background: var(--mint); animation-delay: -2s; }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes drift { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(8px) rotate(40deg); } }
.group-filter { display: flex; flex-wrap: wrap; gap: 8px; }

/* companions (optional) */
.header-companion { margin-left: auto; flex: none; width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--line); border-radius: 50%; background: var(--plate); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; }
.header-companion:hover { background: var(--surface-2); }
.header-companion svg { width: 36px; height: 36px; display: block; }
.cmp-strip { max-width: 760px; margin: 0 auto; width: 100%; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.cmp-strip:not(.has-msg) { display: none; }
.cmp-strip-in { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; }
.cmp-strip-art { flex: none; width: 56px; height: 56px; }
.cmp-strip-art svg { display: block; width: 56px; height: 56px; }
.cmp-bubble { position: relative; flex: 1; min-width: 0; background: var(--surface-2); border: 1.5px solid var(--field-line); border-radius: 18px 18px 18px 6px; padding: 9px 14px; }
.cmp-who { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--lilac); overflow-wrap: anywhere; }
.cmp-say { overflow-wrap: anywhere; }
.cmp-x { flex: none; align-self: flex-start; min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted); font: 600 1.4rem/1 var(--font); border-radius: 12px; cursor: pointer; }
.cmp-x:hover { color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .cmp-strip-art svg, .header-companion svg { animation: cmp-bob 3.6s ease-in-out infinite; }
  @keyframes cmp-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
}
.cmp-prompt { border-style: dashed; border-color: var(--field-line); }
.cmp-faces { display: flex; gap: 2px; }
.cmp-faces svg { width: 40px; height: 40px; display: block; }
.cmp-pick-set { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cmp-opt { border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cmp-opt.is-on { border-color: var(--accent); background: var(--accent-soft); }
.cmp-pick { display: grid; grid-template-columns: auto 104px 1fr; align-items: center; gap: 12px; cursor: pointer; }
.cmp-pick input { width: 22px; height: 22px; accent-color: var(--accent); }
.cmp-opt-art svg { width: 104px; height: 104px; display: block; }
.cmp-none-art { color: var(--accent); fill: currentColor; }
.cmp-opt-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cmp-tag { color: var(--muted); font-size: .85rem; }
.cmp-sample { font-style: italic; font-size: .9rem; overflow-wrap: anywhere; }
@media (max-width: 420px) { .cmp-pick { grid-template-columns: auto 72px 1fr; gap: 10px; } .cmp-opt-art svg { width: 72px; height: 72px; } }
.header-companion { position: relative; z-index: 1; }
@media (max-width: 420px) {
  .sheet-head h2 { font-size: 1rem; text-align: center; }
  .sheet-head-spacer, .sheet-head .btn-ghost { width: 64px; }
}
@media (min-width: 900px) { .cmp-strip { margin: 0; justify-self: start; } }

/* header companion menu + wardrobe */
.hc-wrap { position: relative; margin-left: auto; flex: none; }
.hc-wrap .header-companion { margin-left: 0; }
.hc-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 220px; background: var(--surface); border: 1.5px solid var(--field-line); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.hc-menu[hidden] { display: none; }
.hc-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: 600 1rem var(--font); text-align: left; cursor: pointer; }
.hc-item:hover { background: var(--surface-2); }
.new-dot { position: absolute; top: -1px; right: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent-fill); border: 2px solid var(--bg); pointer-events: none; }
.new-dot[hidden], .new-badge[hidden] { display: none; }
.new-badge { display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--accent-fill); color: var(--accent-ink); }
.wr-entry { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.wr-entry .btn { gap: 8px; }
.cmp-opt-set .wr-entry, .cmp-pick-set > .wr-entry { padding: 12px; border: 1.5px dashed var(--field-line); border-radius: var(--radius-sm); }
.wr { display: flex; flex-direction: column; gap: 16px; }
.wr-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; border-radius: var(--radius); background: radial-gradient(120% 120% at 50% 0%, var(--hero-spot) 0%, transparent 62%), var(--surface); border: 1px solid var(--line); }
.wr-stage svg { width: 200px; height: 200px; display: block; }
.wr-wearing { margin: 0; text-align: center; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.wr h3 { font-size: 1rem; }
.wr-prog { margin: 0; font-weight: 600; }
.wr-slots { display: flex; flex-direction: column; gap: 14px; }
.wr-slot { border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 6px 10px 10px; margin: 0; min-width: 0; }
.wr-slot legend { padding: 0 6px; font-size: .75rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--lilac); }
.wr-opts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wr-opt { border-radius: 14px; border: 1.5px solid transparent; }
.wr-opt.is-on { border-color: var(--accent); background: var(--accent-soft); }
.wr-pick { display: grid; grid-template-columns: auto 64px 1fr; align-items: center; gap: 10px; padding: 6px 8px; min-height: 44px; cursor: pointer; }
.wr-pick input { width: 22px; height: 22px; accent-color: var(--accent); }
.wr-opt.is-locked { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 10px; padding: 6px 8px; background: color-mix(in srgb, var(--bg) 55%, transparent); }
.wr-opt.is-locked .wr-thumb { opacity: .55; filter: grayscale(.5); }
.wr-thumb { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--plate); }
.wr-thumb svg { width: 64px; height: 64px; display: block; }
.wr-none { color: var(--muted); font-size: 1.4rem; }
.wr-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wr-blurb { color: var(--muted); font-size: .85rem; }
.wr-lock { color: var(--warn-ink); font-size: .8rem; font-weight: 600; }
.wr-get { min-height: 44px; white-space: nowrap; }
.wr-redeem-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.wr-redeem-row .field { flex: 1 1 180px; min-width: 0; }
.wr-msg { margin: 0; min-height: 1.4em; font-weight: 600; overflow-wrap: anywhere; }
.wr-msg.ok { color: var(--ok-ink); }
.wr-msg.err { color: var(--danger); }
@media (max-width: 420px) {
  .wr-pick { grid-template-columns: auto 52px 1fr; }
  .wr-thumb, .wr-thumb svg { width: 52px; height: 52px; }
  .wr-opt.is-locked { grid-template-columns: 52px 1fr; }
  .wr-opt.is-locked .wr-get { grid-column: 1 / -1; justify-self: stretch; justify-content: center; }
  .wr-stage svg { width: 168px; height: 168px; }
}
@media (prefers-reduced-motion: no-preference) { .wr-stage svg { animation: cmp-bob 3.6s ease-in-out infinite; } }

/* theme picker */
.theme-set { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .theme-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.theme-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 10px; min-height: 44px; border: 1.5px solid var(--field-line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.theme-card:hover { background: var(--surface-2); }
.theme-card:has(.theme-input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.theme-card:has(.theme-input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.theme-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.theme-sw { position: relative; display: block; height: 54px; border-radius: 12px; background: var(--sw-bg); border: 1px solid var(--edge); overflow: hidden; }
.theme-sw-card { position: absolute; left: 8px; right: 8px; bottom: 7px; height: 24px; border-radius: 8px; background: var(--sw-surface); border: 1px solid var(--edge); }
.theme-sw-dot { position: absolute; left: 14px; bottom: 15px; width: 36px; height: 9px; border-radius: 999px; background: var(--sw-accent); }
.theme-sw-check { display: none; position: absolute; right: 7px; top: 5px; width: 20px; height: 20px; border-radius: 50%; place-items: center; font-size: .8rem; font-weight: 800; background: var(--accent-fill); color: var(--accent-ink); }
.theme-card:has(.theme-input:checked) .theme-sw-check { display: grid; }
.theme-name { font-size: .85rem; font-weight: 650; text-align: center; overflow-wrap: anywhere; }
