/* ここみる design system. Colours come from js/theme.js (CSS variables); buttons come in exactly four kinds:
   .btn.primary / .btn.secondary / .btn.danger / .icon-btn */
@view-transition { navigation: auto; }
:root {
  --radius: 22px; --radius-sm: 14px; --tap: 44px;
  --font: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "M PLUS Rounded 1c", "Zen Maru Gothic", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.2, .9, .3, 1);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  /* fallbacks before theme.js runs */
  --bg: #FFF6F1; --surface: #fff; --surface-2: #f4eeee; --fg: #2d2540; --muted: rgba(45,37,64,.6); --line: rgba(45,37,64,.1);
  --accent: #6B5AD6; --accent-fg: #fff; --accent-soft: rgba(107,90,214,.13); --accent-ink: #6253c4; --danger: #D93B5E; --danger-soft: rgba(217,59,94,.11);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
body { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
img, svg { display: block; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
::selection { background: var(--accent-soft); }

/* Soft gradient wash behind app pages */
.wash { background: radial-gradient(120% 70% at 0% 0%, var(--bg-2, transparent), transparent 60%), radial-gradient(90% 60% at 100% 10%, var(--accent-soft), transparent 70%), var(--bg); background-attachment: fixed; }

/* Page entrance (cross-document view transitions where supported, a gentle fade/slide otherwise) */
.page { animation: pageIn .38s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page, .sheet, .toast { animation: none !important; transition: none !important; } }

/* ---------- buttons ---------- */
.btn { min-height: 50px; padding: 0 20px; border: 0; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 16px; letter-spacing: .02em; cursor: pointer; text-decoration: none; user-select: none; -webkit-user-select: none;
  transition: transform .14s var(--ease), background-color .2s, box-shadow .2s, opacity .2s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-fg); box-shadow: 0 8px 20px -10px var(--accent); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: var(--tap); padding: 0 14px; border-radius: 13px; font-size: 14px; }
.icon-btn { width: var(--tap); height: var(--tap); min-width: var(--tap); border: 0; border-radius: 14px; display: inline-grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--fg); box-shadow: 0 1px 0 var(--line), 0 6px 14px -10px rgba(0,0,0,.35); transition: transform .14s var(--ease), background-color .2s, color .2s;
  text-decoration: none; position: relative; padding: 0; flex: none; }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.icon-btn.danger-on[aria-pressed="true"] { background: var(--danger); color: #fff; }
.icon-btn .dotn { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 0 2px var(--surface); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }
.btn-col { display: grid; gap: 10px; }

/* ---------- inputs ---------- */
.field { width: 100%; min-height: 52px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 16px; font-size: 17px; outline: none; transition: border-color .2s, box-shadow .2s; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.code-input { font: 700 28px/1 var(--mono); letter-spacing: .14em; text-align: center; text-transform: uppercase; min-height: 64px; }
label.lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 6px 4px; }
.err { color: var(--danger); font-size: 14px; min-height: 1.4em; margin: 2px 4px 0; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; text-decoration: none; color: inherit; transition: background-color .15s; }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--accent-soft); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.live { background: rgba(242,112,154,.16); color: var(--pink); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill.live .dot { animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.section-t { display: flex; align-items: center; justify-content: space-between; margin: 26px 6px 10px; font-size: 15px; font-weight: 800; }

/* ---------- app shell ---------- */
.shell { max-width: 640px; margin: 0 auto; padding: calc(var(--sat) + 10px) calc(var(--sar) + 18px) calc(var(--sab) + 28px) calc(var(--sal) + 18px); }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.topbar h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 6px 14px -8px rgba(232,134,159,.9); }
.brand b { font-size: 22px; letter-spacing: .06em; }
.brand small { display: block; font-size: 11px; color: var(--muted); letter-spacing: .02em; font-weight: 600; margin-top: -3px; }

/* ---------- bottom sheets / dialogs ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(28, 18, 44, .38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fadeIn .25s ease both; }
.sheet { position: relative; width: min(560px, 100%); max-height: calc(100dvh - var(--sat) - 24px); overflow: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--fg); border-radius: 28px 28px 0 0; padding: 10px calc(var(--sar) + 20px) calc(var(--sab) + 20px) calc(var(--sal) + 20px);
  box-shadow: 0 -10px 40px -10px rgba(0,0,0,.35); animation: sheetIn .36s var(--ease) both; }
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 4px 0 14px; font-size: 20px; text-align: center; }
.sheet p.lead { margin: -6px 0 16px; text-align: center; color: var(--muted); font-size: 14px; }
.sheet-wrap.closing .sheet { animation: sheetOut .22s ease both; }
.sheet-wrap.closing .sheet-bg { animation: fadeOut .22s ease both; }
@media (min-width: 700px) and (min-height: 560px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 28px; padding-bottom: 22px; animation-name: popIn; }
  .sheet::before { display: none; }
  .sheet-wrap.closing .sheet { animation-name: popOut; }
}
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetOut { to { transform: translateY(100%); } }
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popOut { to { opacity: 0; transform: scale(.96); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

/* Action sheet (long-press menus) */
.actions { display: grid; gap: 8px; }
.actions .btn { justify-content: flex-start; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 24px); z-index: 80; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-size: 14px; font-weight: 700; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  animation: toastIn .3s var(--ease) both; text-align: center; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

/* Code display */
.codebox { text-align: center; padding: 16px; border-radius: 20px; background: var(--accent-soft); }
.codebox .code { font: 800 34px/1.1 var(--mono); letter-spacing: .12em; color: var(--accent-ink); user-select: all; -webkit-user-select: all; }
.codebox small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.qr { width: 196px; height: 196px; margin: 14px auto 0; padding: 12px; background: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.qr svg, .qr img { width: 100%; height: 100%; }

/* Avatar */
.av { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--surface-2); flex: none; }
.av img, .av svg { width: 100%; height: 100%; object-fit: cover; }

/* Footer links */
.foot { text-align: center; margin-top: 30px; font-size: 13px; color: var(--muted); }
.foot a { color: var(--muted); text-decoration: none; padding: 10px 8px; display: inline-block; }

/* Legal pages */
.doc { max-width: 720px; margin: 0 auto; padding: calc(var(--sat) + 16px) calc(var(--sar) + 22px) calc(var(--sab) + 40px) calc(var(--sal) + 22px); }
.doc h1 { font-size: 24px; margin: 8px 0 18px; }
.doc h2 { font-size: 17px; margin: 26px 0 8px; }
.doc p, .doc li { font-size: 15px; line-height: 1.8; }
.doc .card { padding: 18px 22px; }
