/* Sophia r9 · Quiet villa design system */
:root {
  --paper: #f4efe6;
  --ink: #2a2a28;
  --ink-muted: #6a6560;
  --bamboo: #5c7a4a;
  --plum: #8b4a5a;
  --rain: #9aa6ad;
  --timber: #c9b8a0;
  --surface: rgba(255, 252, 247, 0.84);
  --surface-solid: #fffdf8;
  --line: rgba(42, 42, 40, 0.12);
  --shadow: 0 12px 40px rgba(42, 42, 40, 0.12);
  --radius: 12px;
  --radius-sheet: 18px;
  --font-ui: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  --font-lit: "Noto Serif SC", "Songti SC", "Source Han Serif SC", Georgia, serif;
  --dock-h: 64px;
  --focus-progress: 0;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.has-overlay { overflow: hidden; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--bamboo); }

.stage {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  pointer-events: none;
}
.stage-photo {
  position: absolute; inset: -4%;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.2s ease;
  filter: saturate(0.92) contrast(0.96);
}
.stage-day { opacity: 1; }
body[data-room] .stage-dusk { opacity: calc(var(--focus-progress) * 0.55); }
.stage-veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(244,239,230,0.55), rgba(244,239,230,0.78) 45%, rgba(244,239,230,0.92)),
    radial-gradient(120% 80% at 50% 0%, transparent, rgba(42,42,40,0.18));
}
.stage-grain {
  position: absolute; inset: 0; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.room-bamboo .stage-veil { background: linear-gradient(180deg, rgba(232,238,228,0.5), rgba(244,239,230,0.9)); }
.room-plum .stage-veil { background: linear-gradient(180deg, rgba(245,236,232,0.55), rgba(244,239,230,0.92)); }
.room-ink .stage-veil { background: linear-gradient(180deg, rgba(220,226,230,0.55), rgba(236,238,240,0.92)); }

.lang-toggle {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: 14px; z-index: 40;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; min-height: 36px; cursor: pointer;
  backdrop-filter: blur(10px);
}
.title-chip {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 14px; z-index: 40;
  font-size: 12px; letter-spacing: 0.04em; color: var(--plum);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}

.shell {
  position: relative; z-index: 1;
  max-width: 520px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px calc(var(--dock-h) + var(--safe-b) + 24px);
  min-height: 100%;
}
.page-head { margin-bottom: 16px; }
.eyebrow {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-muted); margin: 0 0 6px;
}
.page-title {
  font-family: var(--font-lit); font-weight: 600; font-size: 1.55rem;
  line-height: 1.35; margin: 0 0 8px; text-wrap: balance;
}
.lede { color: var(--ink-muted); line-height: 1.55; margin: 0 0 12px; }
.presence { font-size: 0.92rem; color: var(--ink-muted); line-height: 1.5; }
.sample-tag {
  display: inline-block; font-size: 10px; letter-spacing: 0.06em;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
  color: var(--rain); vertical-align: middle;
}
.section-title {
  font-size: 0.95rem; letter-spacing: 0.06em; color: var(--ink-muted);
  margin: 22px 0 10px; font-weight: 500;
}
.formats, .hint, .demo-hint, .version { font-size: 0.85rem; color: var(--ink-muted); }

.sheet {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sheet); padding: 16px;
  backdrop-filter: blur(14px); box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.field-label {
  display: block; font-size: 0.8rem; color: var(--ink-muted);
  margin: 10px 0 6px;
}
.field-label:first-child { margin-top: 0; }
.field {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; background: var(--surface-solid); outline: none;
  min-height: 44px;
}
.field:focus { border-color: var(--bamboo); box-shadow: 0 0 0 3px rgba(92,122,74,0.18); }
.field-narrow { max-width: 140px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 12px 16px; min-height: 44px; cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--ink); color: #f7f3ec; }
.btn-primary:hover { background: #1c1c1a; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 8px 12px; font-size: 0.9rem; }
.btn-file { cursor: pointer; }
.linkish {
  background: none; border: 0; color: var(--ink-muted); text-decoration: underline;
  cursor: pointer; padding: 8px; min-height: 44px;
}
.icon-close {
  position: absolute; top: 10px; right: 12px;
  border: 0; background: transparent; font-size: 24px; line-height: 1;
  cursor: pointer; min-width: 44px; min-height: 44px; color: var(--ink-muted);
}

.list-block { display: flex; flex-direction: column; gap: 10px; }
.task-row, .desk-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sheet); padding: 14px 16px;
  backdrop-filter: blur(10px);
}
.task-name { margin: 0; font-size: 1.05rem; font-weight: 600; }
.task-meta { margin: 4px 0 0; font-size: 0.85rem; color: var(--ink-muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-hint { color: var(--ink-muted); padding: 12px 4px; }

.interrupt-banner {
  background: rgba(139,74,90,0.08); border: 1px solid rgba(139,74,90,0.25);
  border-radius: var(--radius-sheet); padding: 12px 14px; margin-bottom: 12px;
}

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--dock-h) + var(--safe-b));
  padding: 6px 8px var(--safe-b);
  background: rgba(255,252,247,0.92); border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  max-width: 520px; margin: 0 auto;
}
.dock-btn {
  border: 0; background: transparent; color: var(--ink-muted);
  font-size: 0.78rem; cursor: pointer; border-radius: 10px;
}
.dock-btn.is-on { color: var(--ink); font-weight: 600; background: rgba(92,122,74,0.1); }

.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 18px;
  background: rgba(42,42,40,0.35); backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none !important; }
.overlay-card {
  position: relative; width: min(440px, 100%);
  max-height: min(92vh, 900px); overflow: auto;
  background: var(--surface-solid); border-radius: 22px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 22px 20px 20px;
}
.overlay-timer {
  background: rgba(20,22,20,0.25);
  align-items: stretch;
}
.timer-wrap {
  width: min(440px, 100%); margin: auto; text-align: center;
  background: var(--surface); border-radius: 24px; border: 1px solid var(--line);
  padding: 24px 18px 20px; backdrop-filter: blur(16px);
}
.ring-wrap { position: relative; width: 220px; height: 220px; margin: 16px auto; }
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(42,42,40,0.1); stroke-width: 8; }
.ring-fg {
  fill: none; stroke: var(--bamboo); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 540; stroke-dashoffset: 540;
  transition: stroke-dashoffset 0.2s linear;
}
.ring-center {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 4px;
  transform: rotate(0deg);
}
.timer-display {
  font-variant-numeric: tabular-nums; font-size: 2rem; font-weight: 600; margin: 0;
}
.timer-bird { margin: 0 auto; opacity: 0.95; }
.timer-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.onboard-bird { margin: 0 auto 12px; }
.onboard-card h2, .paywall-card h2 { font-family: var(--font-lit); text-wrap: balance; }

.creator-note {
  margin: 8px 0 16px; padding: 14px 16px;
  border-left: 3px solid var(--plum);
  background: rgba(139,74,90,0.06); border-radius: 0 12px 12px 0;
}
.creator-note p { margin: 0 0 6px; font-family: var(--font-lit); line-height: 1.6; }
.creator-en { color: var(--ink-muted); font-size: 0.95rem; }
.creator-label { font-size: 0.8rem; color: var(--plum); letter-spacing: 0.08em; margin: 0; }
.benefit-list { padding-left: 1.1rem; color: var(--ink-muted); line-height: 1.55; }
.sales-badge {
  display: inline-block; font-size: 0.8rem; letter-spacing: 0.04em;
  border: 1px dashed var(--rain); color: var(--ink-muted);
  padding: 4px 8px; border-radius: 6px;
}

.plan-list { display: grid; gap: 10px; margin: 14px 0; }
.plan-card {
  text-align: left; border: 1px solid var(--line); border-radius: 16px;
  background: #fff; padding: 14px 14px 12px; cursor: pointer;
  display: grid; gap: 4px; position: relative;
}
.plan-card.is-featured {
  border-color: var(--bamboo); box-shadow: 0 0 0 2px rgba(92,122,74,0.2);
  background: linear-gradient(180deg, #f7faf4, #fff);
}
.plan-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; background: var(--bamboo); color: #fff;
  border-radius: 999px; padding: 3px 8px;
}
.plan-title { font-weight: 600; }
.plan-price { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.plan-note, .plan-renew { font-size: 0.82rem; color: var(--ink-muted); }

.card-face {
  margin: 16px 0; padding: 20px 18px;
  background: linear-gradient(160deg, #fbf7ef, #f0e8d8);
  border: 1px solid var(--timber); border-radius: 14px;
  min-height: 160px;
}
.card-face.is-flip { animation: softIn 0.5s ease; }
@keyframes softIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.lit-text {
  font-family: var(--font-lit); font-size: 1.05rem; line-height: 1.7; margin: 0 0 12px;
  white-space: pre-wrap; color: var(--ink);
}
.lit-attr { margin: 0; font-size: 0.85rem; color: var(--ink-muted); }
.cards-grid, .bookmarks-grid { display: grid; gap: 12px; }
.lit-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px;
}
.bamboo-card {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.bamboo-slip {
  width: 48px; height: 72px; border-radius: 4px;
  background:
    linear-gradient(90deg, #8a9a5a, #c5d18a 40%, #8a9a5a 70%, #6f7f45);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
  position: relative;
}
.bamboo-slip::before {
  content: ""; position: absolute; inset: 8px 10px;
  border: 1px solid rgba(42,42,40,0.2); border-radius: 2px;
}
.bamboo-slip.big { width: 72px; height: 110px; margin: 12px auto; }
.pill {
  display: inline-block; font-size: 11px; margin-left: 8px;
  background: rgba(92,122,74,0.15); color: var(--bamboo);
  border-radius: 999px; padding: 2px 8px;
}

.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  background: var(--surface); border-radius: 12px; padding: 4px; border: 1px solid var(--line);
  margin-bottom: 16px;
}
.trail-seg {
  border: 0; background: transparent; border-radius: 10px; min-height: 40px; cursor: pointer;
  color: var(--ink-muted);
}
.trail-seg.is-on { background: var(--ink); color: #f7f3ec; }
.trail-stats { display: grid; gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sheet); padding: 16px;
}
.stat-label { margin: 0; color: var(--ink-muted); font-size: 0.85rem; }
.stat-value { margin: 6px 0 0; font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.room-grid { display: grid; gap: 10px; }
.room-card {
  display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center;
  text-align: left; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; padding: 10px; cursor: pointer;
}
.room-card.is-on { border-color: var(--bamboo); box-shadow: 0 0 0 2px rgba(92,122,74,0.18); }
.room-thumb {
  width: 72px; height: 56px; border-radius: 10px; background-size: cover; background-position: center;
}
.room-name { font-weight: 600; display: block; }
.room-desc { font-size: 0.82rem; color: var(--ink-muted); }

.watch-face {
  margin: 12px auto; width: 180px; height: 220px; border-radius: 40px;
  border: 8px solid #2a2a28; background: linear-gradient(180deg, #1e2420, #121612);
  color: #e8efe4; display: grid; place-content: center; gap: 8px; text-align: center;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.4);
}
.watch-time { font-size: 1.6rem; font-variant-numeric: tabular-nums; margin: 0; }
.watch-sophia { font-size: 0.75rem; letter-spacing: 0.08em; opacity: 0.7; margin: 0; }

.viewer-card { width: min(920px, 100%); height: min(90vh, 900px); display: flex; flex-direction: column; }
#viewer-frame, #viewer-img { flex: 1; width: 100%; border: 0; border-radius: 12px; background: #111; }
#viewer-text {
  flex: 1; overflow: auto; white-space: pre-wrap; background: #fffdf8;
  border-radius: 12px; padding: 16px; margin: 0;
}

.me-sheet .me-value { margin: 0 0 12px; font-weight: 600; }
.legal { margin-top: 18px; }
.timer-chip {
  display: inline-block; background: rgba(92,122,74,0.12); color: var(--bamboo);
  border-radius: 999px; padding: 4px 10px; font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important; transition: none !important; scroll-behavior: auto !important;
  }
}

@media (min-width: 720px) {
  .shell { padding-top: 36px; }
  .page-title { font-size: 1.8rem; }
}
