:root {
  color-scheme: light;
  --paper: #f7f3e9;
  --paper-strong: #fffdf7;
  --ink: #263632;
  --muted: #727a71;
  --line: rgba(44, 60, 52, .15);
  --accent: #b54e35;
  --accent-light: #df8051;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --serif: "Songti SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; background: var(--paper); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: #f2eee4; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(181, 78, 53, .58); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.activity-background { position: fixed; z-index: 0; inset: 0; overflow: hidden; pointer-events: none; }
.activity-background::before { position: absolute; inset: -24px; background: url("/img/retro-moto-cover.jpg") center 25% / cover no-repeat; filter: blur(23px) saturate(.72); opacity: .42; content: ""; }
.activity-background::after { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(249, 246, 239, .68), rgba(247, 244, 237, .8) 48%, rgba(246, 242, 232, .87)); content: ""; }

.topbar { position: sticky; z-index: 10; top: 0; display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 12px; padding: max(8px, env(safe-area-inset-top)) max(20px, calc((100vw - 1040px) / 2)); border-bottom: 1px solid rgba(44, 60, 52, .1); background: rgba(255, 253, 248, .78); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
html.biwai-native-container .topbar { padding-top: 8px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 34px; height: 34px; overflow: hidden; border-radius: 10px; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-copy strong { font-family: var(--serif); font-size: 15px; }
.top-actions { display: flex; min-width: 0; align-items: center; gap: 8px; }
.token-chip, .login-button, .account-button { min-height: 35px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .68); color: var(--ink); font-size: 11px; }
.token-chip { max-width: min(220px, 38vw); overflow: hidden; color: #806b43; text-overflow: ellipsis; white-space: nowrap; }
.account-button { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { position: relative; z-index: 1; width: min(820px, calc(100% - 36px)); margin: 0 auto; padding: 40px 0 64px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
h1, h2 { font-family: var(--serif); }
h1 { margin: 0; font-size: clamp(32px, 6vw, 48px); font-weight: 600; letter-spacing: .02em; }
.lead { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.history-jump { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 253, 247, .72); color: var(--ink); font-size: 11px; }
.studio { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.source-panel, .poster-panel { min-width: 0; padding: clamp(18px, 4vw, 30px); border: 1px solid rgba(50, 63, 54, .12); border-radius: 22px; background: rgba(255, 253, 248, .78); box-shadow: 0 18px 48px rgba(49, 48, 40, .09); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.section-title { margin: 0 0 13px; font: 600 15px var(--serif); }
.upload-zone { position: relative; display: grid; min-height: clamp(260px, 42vw, 390px); place-items: center; overflow: hidden; border: 1px dashed rgba(53, 69, 57, .3); border-radius: 16px; background: rgba(232, 229, 217, .62); cursor: pointer; transition: border-color .2s, background .2s; }
.upload-zone:hover, .upload-zone.is-dragging { border-color: var(--accent); background: rgba(255, 253, 248, .84); }
.upload-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; }
.upload-zone:focus-within { outline: 3px solid rgba(181, 78, 53, .38); outline-offset: 2px; }
.source-preview { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; pointer-events: none; }
.upload-placeholder { position: relative; z-index: 1; display: grid; justify-items: center; gap: 8px; padding: 20px; text-align: center; pointer-events: none; }
.upload-placeholder strong { font: 600 19px var(--serif); }
.upload-placeholder span { color: var(--muted); font-size: 12px; }
.upload-placeholder strong::before { display: grid; width: 42px; height: 42px; place-items: center; margin: 0 auto 12px; border: 1px solid rgba(181, 78, 53, .36); border-radius: 50%; color: var(--accent); content: "+"; font: 26px/1 sans-serif; }
.change-photo { position: absolute; z-index: 1; right: 12px; bottom: 12px; padding: 9px 13px; border: 1px solid rgba(255, 255, 255, .72); border-radius: 999px; background: rgba(36, 49, 44, .78); color: white; font-size: 11px; pointer-events: none; }
.source-file-name { position: absolute; z-index: 1; left: 12px; bottom: 12px; max-width: calc(100% - 120px); overflow: hidden; padding: 8px 11px; border-radius: 999px; background: rgba(255, 253, 248, .87); color: var(--ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.usage-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 17px 0 12px; }
.usage-row strong { font-size: 13px; font-weight: 650; }
.usage-note { color: var(--muted); font-size: 10px; }
.generate { display: flex; width: 100%; min-height: 49px; align-items: center; justify-content: center; border: 0; border-radius: 999px; background: linear-gradient(105deg, #bd5638, #d77a4d); box-shadow: 0 8px 20px rgba(153, 75, 48, .18); color: #fffdf8; font-weight: 650; transition: opacity .2s, transform .2s; }
.generate:hover:not(:disabled) { transform: translateY(-1px); }
.generate:disabled { opacity: .45; cursor: not-allowed; }
.progress { margin-top: 16px; }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.progress-track { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 99px; background: rgba(48, 67, 54, .12); }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b95138, #e0a156); transition: width .3s ease; }
.status { min-height: 18px; margin: 11px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.status.error { color: #a53e32; }
.poster-panel[hidden] { display: none; }
.poster-frame { width: min(100%, 450px); margin: 0 auto; overflow: hidden; border-radius: 15px; background: #e8e2d6; box-shadow: 0 14px 34px rgba(46, 46, 39, .12); }
.poster-result { display: block; width: 100%; height: auto; }
.save-button { display: inline-flex; min-height: 38px; align-items: center; gap: 8px; margin-top: 13px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .7); font-size: 11px; }
.rules { margin-top: 22px; padding: 0 2px; color: #646e64; font-size: 11px; line-height: 1.8; }
.rules p { margin: 0; }
.history-section { margin-top: 45px; padding: 22px; border: 1px solid rgba(50, 63, 54, .12); border-radius: 18px; background: rgba(255, 253, 248, .74); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.history-heading h2 { margin: 0; font-size: 22px; }
.history-caption { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.history-refresh, .history-more, .history-save { min-height: 33px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .72); color: var(--ink); font-size: 10px; }
.history-state { margin: 16px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.history-state.is-error { color: #a53e32; }
.history-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.history-item { min-width: 0; overflow: hidden; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .72); }
.history-item img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; }
.history-item-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 1px 1px; }
.history-item time { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.history-more { display: block; margin: 16px auto 0; }
.toast { position: fixed; z-index: 30; right: 16px; bottom: max(22px, env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 999px; background: rgba(43, 53, 48, .94); color: #fff; font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(7px); transition: .2s; }
.toast.visible { opacity: 1; transform: none; }
.login { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(36, 47, 41, .38); backdrop-filter: blur(9px); }
.login-card { position: relative; width: min(100%, 370px); padding: 25px; border: 1px solid rgba(255, 255, 255, .8); border-radius: 19px; background: var(--paper-strong); box-shadow: 0 24px 65px rgba(30, 38, 33, .2); }
.login-card h2 { margin: 0; font-size: 24px; }
.login-card > p:not(.login-error) { color: var(--muted); font-size: 11px; line-height: 1.6; }
.login-card label { display: grid; gap: 6px; margin-top: 12px; color: var(--muted); font-size: 10px; }
.login-card input { min-height: 41px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.login-card button[type="submit"] { width: 100%; min-height: 42px; margin-top: 16px; border: 0; border-radius: 999px; background: var(--ink); color: white; font-size: 12px; }
.login-close { position: absolute; top: 9px; right: 11px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 22px; }
.login-error { color: #a53e32; font-size: 11px; }
footer { position: relative; z-index: 1; padding: 18px 16px max(22px, env(safe-area-inset-bottom)); color: #85867c; font-size: 9px; text-align: center; }

@media (max-width: 640px) {
  .topbar { min-height: 58px; gap: 6px; padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(12px, env(safe-area-inset-left)); }
  html.biwai-native-container .topbar { padding-top: 7px; }
  .brand-mark { width: 30px; height: 30px; }
  .top-actions { gap: 5px; }
  .token-chip, .login-button, .account-button { min-height: 31px; padding: 0 8px; font-size: 9px; }
  .token-chip { max-width: 32vw; }
  .account-button { max-width: 27vw; }
  .page { width: calc(100% - 28px); padding-top: 29px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 18px; }
  h1 { font-size: clamp(30px, 9vw, 42px); }
  .lead { font-size: 11px; }
  .history-jump { min-height: 34px; }
  .source-panel, .poster-panel { padding: 15px; border-radius: 17px; }
  .upload-zone { min-height: 270px; }
  .usage-row { align-items: flex-start; flex-direction: column; gap: 5px; }
  .history-section { margin-top: 34px; padding: 16px; }
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }

/* Retro Moto: sunlit, paper-first screen-print studio; no dark surfaces. */
:root {
  --paper: #faf4e8;
  --paper-strong: #fffdf6;
  --ink: #59483d;
  --muted: #8b796a;
  --line: rgba(164, 119, 80, .2);
  --accent: #c96f50;
  --accent-light: #e5a16f;
  --serif: "Songti SC", "Noto Serif SC", Georgia, serif;
}
html, body { min-height: 100%; background: #faf3e6; color: var(--ink); }
body { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; }
.activity-background::before { filter: blur(18px) saturate(.58); opacity: .48; }
.activity-background::after { background: linear-gradient(180deg, rgba(255, 249, 236, .65), rgba(255, 249, 238, .76) 50%, rgba(251, 245, 234, .86)); }
.topbar { min-height: 68px; background: rgba(255, 251, 242, .84); border-bottom-color: rgba(177, 132, 92, .12); }
.brand-copy strong { color: #765641; }
.token-chip, .login-button, .account-button { border-color: rgba(164, 119, 80, .2); background: rgba(255, 254, 248, .82); color: #795c47; }
.page { width: min(860px, calc(100% - 48px)); padding: 45px 0 70px; }
.intro { align-items: flex-end; margin-bottom: 24px; }
.intro-kicker { display: inline-block; color: #bd7954; font-size: 11px; letter-spacing: .1em; }
.intro h1 { margin-top: 8px; color: #684e3f; font: 600 clamp(38px, 6vw, 56px)/1.15 var(--serif); letter-spacing: -.04em; }
.lead { margin-top: 10px; color: #927c68; font-size: 13px; }
.history-jump { border-color: rgba(187, 125, 83, .23); background: rgba(255, 253, 246, .84); color: #895e43; }
.studio { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.source-panel, .poster-panel { padding: clamp(18px, 4vw, 31px); border: 1px solid rgba(255, 255, 255, .82); border-radius: 26px; background: rgba(255, 252, 243, .76); box-shadow: 0 24px 68px rgba(136, 99, 64, .12); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.section-title { margin-bottom: 16px; color: #775742; font: 600 17px var(--serif); }
.upload-zone { min-height: 0; max-height: min(65svh, 660px); aspect-ratio: 1.48 / 1; border: 1px dashed rgba(196, 133, 87, .48); border-radius: 18px; background: radial-gradient(ellipse at 20% 15%, rgba(255,255,255,.82), transparent 42%), linear-gradient(145deg, rgba(255,250,239,.86), rgba(242,227,206,.72)); }
.upload-zone:hover, .upload-zone.is-dragging { border-color: rgba(198, 107, 75, .66); background: linear-gradient(145deg, rgba(255,253,246,.94), rgba(248,231,211,.8)); }
.upload-placeholder strong { color: #765641; font: 600 20px var(--serif); }
.upload-placeholder strong::before { border-color: rgba(199, 116, 80, .36); background: rgba(255,254,247,.76); color: #c97857; }
.upload-placeholder span, .upload-placeholder small { color: #927b66; }
.source-preview { inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); padding: 7px; border-radius: 12px; background: rgba(255, 253, 246, .4); }
.change-photo { border-color: rgba(197, 128, 82, .2); background: rgba(255, 252, 243, .94); color: #875b41; box-shadow: 0 6px 18px rgba(119, 82, 49, .1); }
.source-file-name { border: 1px solid rgba(255,255,255,.8); background: rgba(255,252,244,.9); color: #755a46; }
.usage-row { margin: 20px 0 13px; }
.usage-row strong { color: #715540; font-size: 14px; }
.usage-note { color: #9a826c; }
.generate { min-height: 51px; border: 1px solid rgba(197, 109, 75, .16); border-radius: 14px; background: linear-gradient(110deg, #d58d67, #c76c50); box-shadow: 0 10px 24px rgba(192, 107, 75, .2); color: #fffaf1; letter-spacing: .02em; }
.generate:disabled { opacity: .55; }
.progress-track { background: rgba(183, 129, 83, .15); }
.progress-track i { background: linear-gradient(90deg, #e5af78, #c76c50); }
.status { color: #897764; }
.poster-frame { background: rgba(248, 237, 218, .74); box-shadow: 0 18px 42px rgba(138, 96, 60, .14); }
.save-button { border-color: rgba(185, 127, 82, .22); background: rgba(255, 253, 246, .86); color: #815c43; }
.rules { margin-top: 17px; color: #8e7d6a; }
.history-section { margin-top: 37px; padding: 24px; border: 1px solid rgba(255,255,255,.78); border-radius: 23px; background: rgba(255,252,243,.78); box-shadow: 0 18px 52px rgba(136,99,64,.09); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); }
.history-heading h2 { color: #71543f; }
.history-refresh, .history-more, .history-save { border-color: rgba(185, 127, 82, .22); background: rgba(255, 253, 246, .88); color: #815c43; }
.history-item { border-color: rgba(185, 127, 82, .16); background: rgba(255, 253, 247, .85); }
.toast { border: 1px solid rgba(201, 130, 84, .2); background: rgba(255, 252, 244, .97); color: #805d43; box-shadow: 0 12px 34px rgba(136, 99, 64, .14); }
.login { background: rgba(250, 243, 229, .72); }
.login-card { border-color: rgba(255,255,255,.88); background: #fffdf6; box-shadow: 0 24px 65px rgba(126, 91, 57, .16); }
.login-card input { border-color: rgba(164,119,80,.22); background: #fffefa; }
.login-card button[type="submit"] { background: #c97a59; color: #fffaf1; }
.login-close { background: rgba(224, 192, 160, .18); color: #896b53; }
footer { color: #a08b76; }
@media (max-width: 640px) {
  .page { width: calc(100% - 28px); padding-top: 28px; }
  .intro { gap: 14px; margin-bottom: 17px; }
  h1 { font-size: 35px; }
  .lead { font-size: 12px; }
  .source-panel, .poster-panel { padding: 14px; border-radius: 20px; }
  .upload-zone { width: 100%; min-height: 220px; max-height: 58svh; aspect-ratio: 1.12 / 1; }
  .usage-row { align-items: flex-start; flex-direction: column; gap: 5px; }
  .history-section { margin-top: 29px; padding: 16px; }
}
