/* MuseFrame design system — spec §5 tokens, prototype-faithful.
 *
 * Two presentations share one DOM (2026-09):
 *   phone  — the app as it ships on Android / mobile browsers: full-bleed
 *            screens, bottom tab bar, bottom sheets. On a wide desktop with
 *            ?ui=phone it sits inside a phone-shaped demo frame.
 *   web    — html.web: a normal website layout for the browser at ≥900px:
 *            sticky top nav instead of a tab bar, centred content column,
 *            wrapped grids instead of horizontal shelves, centred dialogs.
 * app.js picks the mode (native → phone; ?ui= override; else viewport width)
 * and toggles the html.web class; everything below `html.web` is the override.
 */
:root {
  --canvas: #F7F5EF;
  --surface: #FFFFFF;
  --ink: #171717;
  --ink-muted: #6E6B66;
  --line: #D9D5CC;
  --cobalt: #1C49D8;
  --cobalt-soft: #E8EDFF;
  --success: #217A54;
  --success-soft: #E3F0E9;
  --warning: #A36513;
  --warning-soft: #F6EBD9;
  --danger: #B42318;
  --overlay: rgba(0,0,0,0.56);
  --serif: 'Source Serif 4', Georgia, 'Source Han Serif SC', 'Noto Serif CJK SC', 'Songti SC', serif;
  --sans: -apple-system, 'SF Pro Text', system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, Menlo, monospace;
  --web-max: 1120px;
  --web-nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: #ECEAE2; font-family: var(--sans); color: var(--ink); }
::-webkit-scrollbar { display: none; }

#stage { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
#phone {
  width: 402px; height: 874px; max-height: 100vh;
  background: var(--canvas); border-radius: 48px; overflow: hidden; position: relative;
  box-shadow: 0 40px 80px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.12);
}
/* Below 900px wide (or on short windows) the phone presentation is full-bleed; on a
   roomy desktop with ?ui=phone it sits in the phone-shaped demo frame instead. */
@media (max-width: 899px), (max-height: 700px) {
  #stage { align-items: stretch; }
  #phone { width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; box-shadow: none; }
}
/* Native app (Capacitor): always full-bleed, never the desktop demo frame. */
html.native #stage { align-items: stretch; }
html.native #phone { width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; box-shadow: none; }
#app { position: absolute; inset: 0; }

@keyframes mfIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes mfPulse { 0%,100% { opacity: .4; } 50% { opacity: 1; } }
@keyframes mfSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--canvas); animation: mfIn .22s ease; }
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

/* top bars */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid rgba(217,213,204,.5); flex: none;
}
.topbar.clear { border-bottom: none; }
.topbar-title { font: 600 15px var(--sans); }
.topbar-title.serif { font: 600 15px var(--serif); }
.iconbtn {
  width: 38px; height: 38px; border-radius: 999px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink);
}
.page-title { font: 600 34px/1.15 var(--serif); padding: 8px 20px 16px; }

.kicker { font: 500 10.5px var(--mono); letter-spacing: 1.8px; color: var(--ink-muted); text-transform: uppercase; }

/* buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; border-radius: 12px; border: none; cursor: pointer; width: 100%;
  background: var(--cobalt); color: #fff; font: 600 16px var(--sans);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); height: 50px; font-size: 14.5px; }
.btn.small { height: 44px; border-radius: 11px; font-size: 13px; }
.btn.success { background: var(--success); }
.chip {
  font: 600 12px var(--sans); border-radius: 999px; padding: 7px 14px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.chip.active { background: var(--ink); color: var(--canvas); border-color: var(--ink); }
.pillbtn {
  font: 600 11px var(--sans); color: var(--cobalt); background: var(--cobalt-soft);
  border: none; border-radius: 999px; padding: 5px 11px; cursor: pointer;
}
.linkbtn { font: 600 12.5px var(--sans); color: var(--cobalt); background: none; border: none; cursor: pointer; padding: 0; }

/* text inputs (auth) */
.input {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px;
  font: 15px var(--sans); background: var(--surface); color: var(--ink); margin-bottom: 8px; outline: none;
}
.input:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-soft); }

/* cards */
.card-art { position: relative; aspect-ratio: 4/5; border-radius: 12px; overflow: hidden; border: 1px solid rgba(23,23,23,.09); background-size: cover; background-position: center; }
.card-art.selected { outline: 2px solid var(--cobalt); outline-offset: -2px; }
.card-art .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,.5) 100%); }
.card-art .name { position: absolute; left: 10px; right: 10px; bottom: 9px; font: 600 14px var(--serif); color: #fff; }
.card-art .premium-badge {
  position: absolute; top: 8px; left: 8px; font: 600 9px var(--sans); letter-spacing: .6px;
  color: var(--ink); background: rgba(247,245,239,.9); border-radius: 999px; padding: 3px 7px;
}
.card-art .check {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 999px;
  background: var(--cobalt); color: #fff; display: flex; align-items: center; justify-content: center; font: 600 12px var(--sans);
}
.card-caption { font: 400 11px/1.4 var(--sans); color: var(--ink-muted); padding: 6px 2px 0; }
.card-tags { font: 500 10px var(--mono); letter-spacing: .8px; color: var(--ink-muted); padding: 3px 2px 0; text-transform: uppercase; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hrow { display: flex; gap: 12px; overflow-x: auto; padding: 2px 20px 4px; }
.hrow > * { flex: none; width: 146px; cursor: pointer; }

/* discover hero (phone: image with text overlaid; web: two columns) */
.hero { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.hero-art { aspect-ratio: 4/5; background-size: cover; background-position: center; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.6) 100%); }
.hero-text { position: absolute; left: 18px; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hero-kicker { font: 500 10px var(--mono); letter-spacing: 1.8px; color: rgba(247,245,239,.85); }
.hero-title { font: 600 30px/1.1 var(--serif); color: #fff; }
.hero-note { font: 400 13px/1.5 var(--sans); color: rgba(247,245,239,.92); }
.hero-btn { margin-top: 4px; background: #fff; color: var(--ink); font: 600 13px var(--sans); padding: 10px 18px; border-radius: 999px; border: none; cursor: pointer; }

/* segmented control */
.seg { display: flex; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button {
  flex: 1; text-align: center; padding: 9px 0; border-radius: 8px; border: none; background: transparent;
  font: 500 13px var(--sans); color: var(--ink); cursor: pointer;
}
.seg button.active { background: var(--ink); color: var(--canvas); }

/* bottom areas */
.bottom-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  background: rgba(247,245,239,.94); border-top: 1px solid rgba(217,213,204,.6);
  backdrop-filter: blur(10px); animation: mfIn .22s ease;
}
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-start;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: rgba(247,245,239,.92); border-top: 1px solid rgba(217,213,204,.7); backdrop-filter: blur(14px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; color: var(--ink-muted); background: none; border: none; font: 500 10px var(--sans); }
.tab.active { color: var(--cobalt); }
.tab .create-dot { width: 24px; height: 24px; border-radius: 8px; background: var(--cobalt); display: flex; align-items: center; justify-content: center; margin-top: -1px; }

/* web top nav / footer — hidden in phone mode, shown under html.web */
.webnav, .webfooter { display: none; }

/* toast */
.toast {
  position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%);
  background: var(--ink); color: var(--canvas); font: 500 12.5px var(--sans);
  border-radius: 999px; padding: 9px 16px; white-space: nowrap; animation: mfIn .2s ease; z-index: 90; max-width: 90%;
  overflow: hidden; text-overflow: ellipsis;
}

/* sheet (paywall, style detail) */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(23,23,23,.45); z-index: 80; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet {
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  animation: mfIn .25s ease; max-height: 86%; overflow-y: auto; overscroll-behavior: contain;
}
.sheet-grab { width: 36px; height: 4px; border-radius: 99px; background: var(--line); margin: 0 auto 14px; }

.spinner {
  width: 30px; height: 30px; border-radius: 999px;
  border: 2.5px solid var(--line); border-top-color: var(--cobalt);
  animation: mfSpin .9s linear infinite;
}

.plan-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 13px 14px; cursor: pointer; }
.plan-row.selected { border: 2px solid var(--cobalt); background: var(--cobalt-soft); padding: 12px 13px; }
.radio { width: 18px; height: 18px; border-radius: 999px; border: 2px solid var(--line); background: #fff; flex: none; }
.plan-row.selected .radio { border: 5px solid var(--cobalt); }
/* price list v2: small tier badges + the paywall's USD / CNY switch */
.plan-badge { display: inline-block; font: 600 9.5px/1 var(--sans); letter-spacing: .4px; color: var(--cobalt); background: var(--cobalt-soft); border-radius: 999px; padding: 3px 7px; margin-left: 8px; vertical-align: 1px; white-space: nowrap; }
.plan-badge.strong { color: #fff; background: var(--cobalt); }
.cur-switch { display: inline-flex; flex: none; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--canvas); }
.cur-switch button { border: 0; background: none; cursor: pointer; font: 600 11px/1 var(--sans); color: var(--ink-muted); padding: 6px 9px; border-radius: 999px; white-space: nowrap; }
.cur-switch button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.cur-switch button:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 1px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }

/* contact-to-buy card (paywall when the free quota is used up) */
.contact-card { background: var(--canvas); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.contact-card .email { font: 600 15px var(--mono); letter-spacing: .2px; word-break: break-all; color: var(--ink); }
.contact-card .qq-row { display: flex; gap: 14px; align-items: flex-start; }
.contact-card .qq-qr { width: 96px; height: 96px; border-radius: 10px; border: 1px solid var(--line); background: #fff; flex: none; }
.contact-card .qq-row .email { font-size: 22px; }

/* progress screen */
.progress-bg { position: absolute; inset: -30px; background-size: cover; background-position: center; filter: blur(30px) saturate(.65) brightness(.95); }
.progress-veil { position: absolute; inset: 0; background: rgba(247,245,239,.78); }
.progress-body { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 36px; }

/* auth card */
.auth-card { display: flex; flex-direction: column; gap: 4px; }

input[type=range] { width: 100%; accent-color: var(--cobalt); }
img { -webkit-user-drag: none; user-select: none; }

/* ===================================================================== */
/* Web presentation (html.web) — the browser at desktop widths.           */
/* ===================================================================== */
html.web, html.web body { height: auto; }
html.web body { background: var(--canvas); }
html.web #stage { display: block; min-height: 100vh; }
html.web #phone {
  width: 100%; height: auto; max-height: none; min-height: 100vh;
  border-radius: 0; box-shadow: none; overflow: visible; position: relative;
}
html.web #app { position: static; inset: auto; }
html.web #overlay { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
html.web #overlay > * { pointer-events: auto; }

html.web .screen { position: relative; inset: auto; min-height: 100vh; animation: none; }
html.web .scroll {
  overflow: visible; width: 100%; max-width: var(--web-max); margin: 0 auto;
  padding: 28px 32px 72px !important;
}
html.web .scroll.narrow { max-width: 760px; }
html.web .scroll.reading { max-width: 880px; }
html.web .topbar { max-width: var(--web-max); margin: 0 auto; width: 100%; padding: 10px 20px 8px; border-bottom: none; }
html.web .page-title { font-size: 40px; padding-left: 0; padding-right: 0; }

/* the tab bar is replaced by the top nav */
html.web .tabbar { display: none; }
html.web .webnav {
  display: flex; position: sticky; top: 0; z-index: 60; height: var(--web-nav-h);
  align-items: center; gap: 22px; padding: 0 32px;
  background: rgba(247,245,239,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
html.web .webnav .brand { font: 600 17px var(--serif); letter-spacing: 4px; cursor: pointer; background: none; border: none; color: var(--ink); padding: 0; }
html.web .webnav nav { display: flex; gap: 4px; }
html.web .webnav nav button {
  background: none; border: none; font: 500 14px var(--sans); color: var(--ink-muted);
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
html.web .webnav nav button:hover { color: var(--ink); }
html.web .webnav nav button.active { color: var(--ink); background: rgba(23,23,23,.06); }
html.web .webnav .spacer { flex: 1; }
html.web .webnav .lang { font: 600 12px var(--sans); color: var(--ink-muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; cursor: pointer; }
html.web .webnav .cta { height: 38px; width: auto; padding: 0 16px; border-radius: 10px; font-size: 13.5px; }
html.web .webnav .cta.secondary { height: 38px; font-size: 13.5px; }
html.web .webnav .pillbtn { font-size: 12px; padding: 7px 13px; }
/* signed-in account entry (avatar + email → profile, where "Sign out" lives) */
html.web .webnav .account { display: flex; align-items: center; gap: 8px; max-width: 240px; height: 38px; padding: 0 12px 0 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: 500 12.5px var(--sans); cursor: pointer; }
html.web .webnav .account:hover { border-color: var(--ink-muted); }
html.web .webnav .account .avatar { width: 30px; height: 30px; flex: none; border-radius: 999px; background: var(--ink); color: var(--canvas); display: flex; align-items: center; justify-content: center; font: 600 13px var(--serif); }
html.web .webnav .account .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) { html.web .webnav .account { padding: 0 3px; } html.web .webnav .account .who { display: none; } }

/* bottom bars stick to the viewport bottom but stay in the content column */
html.web .bottom-bar {
  position: sticky; bottom: 0; margin-top: auto; animation: none;
  padding: 14px max(32px, calc(50% - var(--web-max) / 2)) 18px;
}
html.web .bottom-bar .btn { max-width: 560px; margin-left: auto; margin-right: auto; }

/* grids: wrap instead of scroll */
html.web .grid2 { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 18px; }
html.web .hrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 18px; overflow: visible; padding: 2px 0 4px; }
html.web .hrow > * { width: auto !important; }
html.web .card-art .name { font-size: 15px; }
html.web .card-caption { font-size: 12px; }

/* discover hero → two columns */
html.web .hero { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; background: var(--surface); }
html.web .hero-shade { display: none; }
html.web .hero-text { position: static; padding: 36px 40px; justify-content: center; gap: 12px; }
html.web .hero-kicker { color: var(--ink-muted); }
html.web .hero-title { color: var(--ink); font-size: 40px; }
html.web .hero-note { color: var(--ink-muted); font-size: 15px; max-width: 46ch; }
html.web .hero-btn { background: var(--ink); color: var(--canvas); padding: 12px 22px; font-size: 14px; }

/* progress: keep the blurred stage under the nav */
html.web .screen.progress { min-height: 100vh; overflow: hidden; }
html.web .progress-bg, html.web .progress-veil, html.web .progress-body { top: var(--web-nav-h); }
html.web .progress-body > .panelish { max-width: 440px; }

/* dialogs: centred modals */
html.web .sheet-backdrop { position: fixed; align-items: center; justify-content: center; padding: 24px; }
html.web .sheet { border-radius: 20px; width: 100%; max-width: 520px; max-height: 90vh; max-height: calc(100dvh - 48px); flex: none; padding: 22px 26px 26px; }
html.web .sheet-grab { display: none; }
html.web .toast { position: fixed; bottom: 32px; }

/* auth screen becomes a centred card */
html.web .auth-card {
  max-width: 440px; margin: 40px auto 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 30px 30px 26px;
}

/* wide-screen result: artwork beside its actions */
@media (min-width: 1024px) {
  html.web .result-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
}

/* website footer */
html.web .webfooter { display: block; border-top: 1px solid var(--line); background: var(--surface); margin-top: auto; }
html.web .webfooter .inner { max-width: var(--web-max); margin: 0 auto; padding: 28px 32px 34px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; }
html.web .webfooter .brand { font: 600 14px var(--serif); letter-spacing: 3px; display: flex; flex-direction: column; gap: 2px; }
html.web .webfooter .brand span { font: 500 10px var(--mono); letter-spacing: 1.6px; color: var(--ink-muted); text-transform: uppercase; }
html.web .webfooter nav { display: flex; flex-wrap: wrap; gap: 4px 18px; flex: 1; }
html.web .webfooter .flink { font: 500 13px var(--sans); color: var(--ink-muted); background: none; border: none; padding: 0; cursor: pointer; text-decoration: none; }
html.web .webfooter .flink:hover { color: var(--ink); }
html.web .webfooter .fine { width: 100%; font: 400 11.5px/1.5 var(--sans); color: var(--ink-muted); }
html.web .plan-row { padding: 14px 16px; }
html.web .plan-row:hover { border-color: var(--cobalt); }
html.web .screen { padding-bottom: 0; }
