/* ==========================================================================
   とん箱 — Mobile-first design (#825dab purple theme)
   ========================================================================== */

:root {
  --primary: #825dab;
  --primary-dark: #6b4a91;
  --primary-light: #a080c4;
  --primary-lightest: #f3eef8;
  --primary-gradient: linear-gradient(135deg, #825dab 0%, #a080c4 100%);
  --accent: #825dab;
  --accent-hover: #6b4a91;

  --white: #fff;
  --bg: #f0f0f0;
  --card: #fff;
  --border: #e8e8e8;

  --t1: #333;
  --t2: #777;
  --t3: #aaa;
  --t-inv: #fff;

  --font: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', sans-serif;

  --app-w: 480px;
  --header-h: 48px;
  --bnav-h: 56px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 9999px;

  --sh-card: 0 1px 4px rgba(0,0,0,.08);
  --sh-btn: 0 2px 8px rgba(0,0,0,.12);

  --tr: 200ms ease;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.6;
  color: var(--t1); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
h1,h2,h3,h4 { line-height: 1.3; font-weight: 700; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Shell ─────────────────────────────────────────── */
.shell {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  max-width: var(--app-w);
  margin: 0 auto;
  background: var(--white);
  box-shadow: 0 0 20px rgba(0,0,0,.06);
  position: relative;
}

/* ── Header ────────────────────────────────────────── */
.hdr {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  position: sticky; top: 0; z-index: 100;
  padding: 0 12px;
}
.hdr__logo {
  font-size: 18px; font-weight: 800; color: var(--primary-dark);
  text-decoration: none; display: flex; align-items: center; gap: 6px;
}
.hdr__logo:hover { text-decoration: none; opacity: .85; }
.hdr__logo-icon {
  width: 28px; height: 28px; background: var(--primary);
  border-radius: 6px; display: grid; place-items: center;
  color: var(--t-inv); font-size: 13px; font-weight: 700;
}
.hdr__menu {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 20px; color: var(--t2); padding: 4px;
}
.hdr__dropdown {
  position: absolute; top: calc(var(--header-h) + 4px); right: 8px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--sh-btn);
  min-width: 160px; overflow: hidden; z-index: 200;
}
.hdr__dropdown a, .hdr__dropdown button {
  display: block; width: 100%; padding: 12px 16px;
  font-size: 13px; color: var(--t1); text-align: left;
  text-decoration: none; border-bottom: 1px solid var(--border);
}
.hdr__dropdown a:last-child, .hdr__dropdown button:last-child { border: none; }
.hdr__dropdown a:hover, .hdr__dropdown button:hover { background: #f8f8f8; text-decoration: none; }

/* ── Bottom Nav ────────────────────────────────────── */
.bnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--app-w);
  z-index: 100; background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}
.bnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 0;
  font-size: 10px; font-weight: 500; color: var(--t3);
  text-decoration: none; transition: color var(--tr);
}
.bnav a:hover { text-decoration: none; }
.bnav a.is-active { color: var(--primary-dark); }
.bnav__icon { font-size: 22px; line-height: 1; }

/* ── Page ──────────────────────────────────────────── */
.page {
  flex: 1;
  padding: 0 0 calc(var(--bnav-h) + 16px + env(safe-area-inset-bottom));
}
.page--pad {
  padding-left: 16px; padding-right: 16px;
  padding-top: 16px;
}
.page--nobnav { padding-bottom: 16px; }

/* ── Profile Hero (Landing) ────────────────────────── */
.profile-hero {
  background: var(--primary-gradient);
  padding: 32px 20px 28px;
  text-align: center; color: var(--t-inv);
}
.profile-hero__icon {
  width: 64px; height: 64px; margin: 0 auto 12px;
  background: rgba(255,255,255,.25); border-radius: var(--r-full);
  display: grid; place-items: center; font-size: 28px;
}
.profile-hero__name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.profile-hero__sub { font-size: 12px; opacity: .85; }

/* ── Quick Ask ─────────────────────────────────────── */
.quick-ask {
  padding: 20px 16px;
  text-align: center;
}
.quick-ask__btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--accent); color: var(--t-inv);
  font-size: 15px; font-weight: 700;
  padding: 14px 40px; border-radius: var(--r-full);
  box-shadow: var(--sh-btn);
  transition: background var(--tr), transform var(--tr);
  text-decoration: none; border: none; cursor: pointer;
}
.quick-ask__btn:hover { background: var(--accent-hover); transform: translateY(-1px); text-decoration: none; }
.quick-ask__btn:active { transform: scale(.97); }

/* ── Ask Form (inline) ─────────────────────────────── */
.ask-form {
  background: var(--white); border-top: 1px solid var(--border);
  padding: 20px 16px;
}
.ask-form__guest {
  text-align: center; font-size: 11px; color: var(--t3);
  margin-bottom: 12px; display: flex; align-items: center;
  justify-content: center; gap: 4px;
}
.ask-form__group { margin-bottom: 12px; }
.ask-form__label {
  display: block; font-size: 12px; font-weight: 600; color: var(--t2);
  margin-bottom: 4px;
}

/* ── Section ───────────────────────────────────────── */
.sec {
  border-top: 6px solid var(--bg);
}
.sec__head {
  padding: 16px 16px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.sec__title { font-size: 15px; font-weight: 700; color: var(--t1); }
.sec__link { font-size: 12px; color: var(--primary-dark); font-weight: 500; }

/* ── Card ──────────────────────────────────────────── */
.card {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  transition: background var(--tr);
}
.card:last-child { border-bottom: none; }
.card--tap { cursor: pointer; }
.card--tap:hover { background: #fafafa; }
.card--tap:active { background: #f5f5f5; }

.card__title {
  font-size: 14px; font-weight: 600; color: var(--t1);
  margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__body {
  font-size: 13px; color: var(--t2); line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__meta {
  display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--t3);
}
.card__meta-push { margin-left: auto; }

/* ── Badge ─────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 10px; font-weight: 600; line-height: 1.6;
}
.badge--mint { background: var(--primary-lightest); color: var(--primary-dark); }
.badge--orange { background: var(--primary-lightest); color: var(--primary); }
.badge--green { background: #e8f5e9; color: #2e7d32; }
.badge--gray { background: #f0f0f0; color: var(--t3); }

/* ── Pill tabs ─────────────────────────────────────── */
.pills {
  display: flex; gap: 6px;
  overflow-x: auto; -ms-overflow-style: none; scrollbar-width: none;
  padding: 0 16px 8px;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  padding: 6px 14px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: #f0f0f0; color: var(--t2);
  border: none; cursor: pointer; transition: all var(--tr);
}
.pill:hover { background: #e5e5e5; }
.pill.is-active { background: var(--primary); color: var(--t-inv); }

/* ── Button ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-weight: 600; border-radius: var(--r-md);
  text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; transition: all var(--tr);
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn--sm { padding: 6px 14px; font-size: 12px; }
.btn--md { padding: 10px 20px; font-size: 13px; }
.btn--lg { padding: 14px 28px; font-size: 15px; }

.btn--primary { background: var(--primary); color: var(--t-inv); }
.btn--primary:hover { background: var(--primary-dark); }
.btn--mint { background: var(--primary); color: var(--t-inv); }
.btn--mint:hover { background: var(--primary-dark); }
.btn--orange { background: var(--primary); color: var(--t-inv); }
.btn--orange:hover { background: var(--primary-dark); }
.btn--outline { background: var(--white); color: var(--t1); border-color: var(--border); }
.btn--outline:hover { background: #f8f8f8; }
.btn--ghost { background: none; color: var(--t2); }
.btn--ghost:hover { background: #f5f5f5; }
.btn--full { width: 100%; }

/* ── Form ──────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--t2); margin-bottom: 4px; }
.hint { font-size: 11px; color: var(--t3); margin-top: 2px; }

.input {
  width: 100%; padding: 10px 12px;
  font-size: 14px; line-height: 1.5;
  background: var(--white); color: var(--t1);
  border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color var(--tr);
}
.input::placeholder { color: var(--t3); }
.input:focus { outline: none; border-color: var(--primary); }
.input:disabled { background: #f8f8f8; color: var(--t3); }

.select {
  padding: 10px 12px; font-size: 13px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); cursor: pointer;
}
.select:focus { outline: none; border-color: var(--primary); }

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--t2); cursor: pointer;
}
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ── Upvote ────────────────────────────────────────── */
.upvote {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid var(--border);
  border-radius: var(--r-full); font-size: 12px; font-weight: 600;
  color: var(--t2); background: var(--white);
  transition: all var(--tr); cursor: pointer;
}
.upvote:hover { border-color: var(--primary); color: var(--primary-dark); }

/* ── FAB ───────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--bnav-h) + 16px + env(safe-area-inset-bottom));
  right: calc(50% - var(--app-w) / 2 + 16px);
  z-index: 90;
  display: flex; align-items: center; gap: 6px;
  padding: 12px 20px;
  background: var(--accent); color: var(--t-inv);
  font-size: 13px; font-weight: 700;
  border-radius: var(--r-full);
  box-shadow: var(--sh-btn);
  text-decoration: none;
  transition: all var(--tr);
}
.fab:hover { background: var(--accent-hover); transform: translateY(-2px); text-decoration: none; }
.fab:active { transform: scale(.95); }
@media (max-width: 480px) { .fab { right: 16px; } }

/* ── Spinner ───────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
.center-block { display: flex; justify-content: center; padding: 40px; }

/* ── Empty ─────────────────────────────────────────── */
.empty { text-align: center; padding: 40px 20px; }
.empty__icon { font-size: 40px; margin-bottom: 8px; display: block; color: var(--t3); }
.empty__text { font-size: 13px; color: var(--t3); }

/* ── Message ───────────────────────────────────────── */
.msg {
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500; margin-bottom: 12px;
}
.msg--error { background: #fef2f2; color: #c62828; }
.msg--success { background: #e8f5e9; color: #2e7d32; }

/* ── Auth ──────────────────────────────────────────── */
.auth {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 20px 16px;
}
.auth__card {
  width: 100%; padding: 28px 20px;
  background: var(--white);
  border-radius: var(--r-lg);
}
.auth__heading {
  font-size: 20px; text-align: center; color: var(--t1);
  margin-bottom: 4px;
}
.auth__sub {
  text-align: center; font-size: 12px; color: var(--t2);
  margin-bottom: 20px;
}
.auth__footer {
  text-align: center; font-size: 12px; color: var(--t2);
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ── Detail page ───────────────────────────────────── */
.detail { padding: 16px; }
.detail__back {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--t2); margin-bottom: 12px;
}
.detail__back:hover { color: var(--primary-dark); text-decoration: none; }

.detail__q {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px; margin-bottom: 20px;
}
.detail__q-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.detail__q-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.detail__q-body { font-size: 14px; color: var(--t2); line-height: 1.7; white-space: pre-wrap; margin-bottom: 12px; }
.detail__q-foot { display: flex; align-items: center; justify-content: space-between; }

.detail__ans { padding: 14px; border-bottom: 1px solid var(--border); }
.detail__ans:last-child { border-bottom: none; }
.detail__ans--best { background: #f0faf0; border: 1px solid #c8e6c9; border-radius: var(--r-md); margin-bottom: 8px; }
.detail__ans-body { font-size: 13px; line-height: 1.6; margin-bottom: 8px; white-space: pre-wrap; }
.detail__ans-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail__ans-meta { font-size: 11px; color: var(--t3); }

.best-btn {
  font-size: 11px; color: #2e7d32; border: 1px solid #2e7d32;
  border-radius: var(--r-full); padding: 3px 10px; margin-left: auto;
  transition: background var(--tr);
}
.best-btn:hover { background: #e8f5e9; }

.ans-form-wrap { border-top: 1px solid var(--border); padding: 16px; }
.ans-form { display: flex; flex-direction: column; gap: 10px; }

/* ── Settings ──────────────────────────────────────── */
.settings-sec { padding: 16px; }
.settings-sec__title {
  font-size: 14px; font-weight: 600; color: var(--t1);
  padding-bottom: 8px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; font-size: 13px; cursor: pointer;
}
.toggle-chip {
  font-size: 11px; font-weight: 600;
  padding: 3px 12px; border-radius: var(--r-full);
  background: #eee; color: var(--t3);
}
.toggle-chip.is-on { background: var(--primary); color: var(--t-inv); }

/* ── New question page ─────────────────────────────── */
.new-q { padding: 16px; }
.new-q__head { margin-bottom: 16px; }
.new-q__title { font-size: 17px; font-weight: 700; }
.new-q__sub { font-size: 12px; color: var(--t2); margin-top: 2px; }
.new-q__guest {
  font-size: 12px; color: var(--t3);
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; background: #f8f8f8; border-radius: var(--r-md);
  margin-bottom: 16px;
}

/* ── Page heading ──────────────────────────────────── */
.pg-head { padding: 16px 16px 8px; }
.pg-head__title { font-size: 17px; font-weight: 700; }
.pg-head__sub { font-size: 12px; color: var(--t2); margin-top: 2px; }

/* ── Inbox ─────────────────────────────────────────── */
.inbox-card { padding: 0; border-bottom: 1px solid var(--border); }
.inbox-card__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; gap: 10px; cursor: pointer;
  transition: background var(--tr);
}
.inbox-card__head:hover { background: #fafafa; }
.inbox-card__body { flex: 1; min-width: 0; }
.inbox-card__text { font-size: 13px; line-height: 1.5; margin-bottom: 2px; }
.inbox-card__date { font-size: 11px; color: var(--t3); }
.inbox-card__expand {
  padding: 14px 16px; background: #f9f9f9;
  border-top: 1px solid var(--border);
}
.vis-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.vis-toggle button {
  padding: 4px 12px; font-size: 11px; font-weight: 500;
  background: var(--white); color: var(--t2);
}
.vis-toggle button.is-active { background: var(--primary); color: var(--t-inv); }
