:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #697482;
  --paper: #f4f6f8;
  --navy: #15202b;
  --red: #d84a62;
  --red-deep: #a92e44;
  --line: #e1e6ea;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-size: 16px; }
button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }
a { color: inherit; }
[hidden] { display: none !important; }

.login-page, .admin-page { min-height: 100vh; background: #f1f4f6; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); background: white; border: 1px solid var(--line); border-radius: 22px; padding: 34px; box-shadow: 0 24px 60px rgba(18, 31, 43, .11); }
.brand-mark { min-width: 52px; height: 52px; padding: 0 10px; border-radius: 15px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, #f06478, #c73750); font-size: .72rem; font-weight: 900; letter-spacing: .08em; }
.login-card h1 { margin: 22px 0 8px; font-size: 1.75rem; }
.login-card p { margin: 0 0 24px; color: var(--muted); line-height: 1.7; }

.field { display: grid; gap: 8px; margin: 16px 0; }
.field label { font-weight: 700; font-size: .92rem; }
input, textarea, select { width: 100%; border: 1px solid #ccd4db; border-radius: 11px; padding: 11px 12px; background: white; color: var(--ink); }
input[type="color"] { min-height: 44px; padding: 5px; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(216, 74, 98, .13); border-color: var(--red); }
textarea { min-height: 105px; resize: vertical; line-height: 1.6; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 43px; border: 0; border-radius: 11px; padding: 0 17px; background: var(--red); color: white; font-weight: 750; cursor: pointer; text-decoration: none; }
.button:hover { background: var(--red-deep); }
.button:disabled { opacity: .55; cursor: wait; }
.button.secondary { background: #e9edf1; color: #243140; }
.button.ghost { background: transparent; color: #d4dbe2; border: 1px solid rgba(255,255,255,.18); }
.button.full { width: 100%; }
.button.compact { min-height: 36px; margin-top: 10px; font-size: .88rem; }
.notice { border-radius: 11px; padding: 13px 15px; margin: 14px 0 18px; background: #fff4d7; color: #704c00; }
.notice.error { background: #fff0f1; color: #8a1725; }

.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: #f7fafc; padding: 24px 18px; display: flex; flex-direction: column; gap: 28px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.sidebar-brand .brand-mark { min-width: 42px; width: 42px; height: 42px; border-radius: 12px; font-size: .58rem; }
.nav { display: grid; gap: 7px; }
.nav a { text-decoration: none; padding: 11px 12px; color: #c8d0d9; border-radius: 9px; }
.nav a.active, .nav a:hover { color: white; background: rgba(255,255,255,.09); }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; color: #aab5c0; font-size: .88rem; }
.sidebar-foot form { margin: 0; }
.admin-main { padding: 30px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 4px 0 6px; font-size: 1.85rem; }
.page-head p { margin: 0; color: var(--muted); }
.kicker { color: var(--red); font-size: .72rem; font-weight: 900; letter-spacing: .16em; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric, .panel { background: white; border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 8px 26px rgba(29, 42, 55, .045); }
.metric { padding: 18px; }
.metric span { display: block; color: #6d7781; font-size: .86rem; }
.metric strong { display: block; margin-top: 9px; font-size: 1.75rem; }
.grid-two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr); gap: 18px; align-items: start; }
.panel { padding: 21px; margin-bottom: 18px; scroll-margin-top: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 5px; font-size: 1.16rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.check-row { display: flex; align-items: center; gap: 9px; margin: 14px 0; }
.check-row input { width: auto; }
.help { margin: 0; color: #74808c; font-size: .86rem; line-height: 1.55; }
.top-gap { margin-top: 24px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #ebeff2; vertical-align: middle; }
th { color: #62707c; font-size: .82rem; font-weight: 750; }
td { font-size: .92rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; background: #eef2f5; color: #43505c; font-size: .78rem; white-space: nowrap; }
.badge.live { background: #e7f6ed; color: #1d6741; }
.badge.warn { background: #fff1d9; color: #81520a; }
.preview-link { color: var(--red-deep); font-weight: 750; text-decoration: none; }
.empty { padding: 26px; text-align: center; color: #71808e; }
.mini-card-list { display: grid; gap: 10px; }
.mini-card { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid #ebeff2; border-radius: 13px; }
.mini-card p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
.character-dot { width: 42px; height: 42px; border-radius: 14px; background: var(--character-color); box-shadow: inset 0 0 0 8px rgba(255,255,255,.28); }
.inline-editor { margin-top: 15px; border-top: 1px solid #edf0f2; padding-top: 14px; }
.inline-editor summary { color: var(--red-deep); font-weight: 750; cursor: pointer; }
.note-admin-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.note-admin-card { border: 1px solid #e5e9ed; border-radius: 14px; padding: 15px; background: #fbfcfd; }
.note-admin-card p { line-height: 1.65; }
.note-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .8rem; }
.note-meta strong { color: var(--ink); }
.note-admin-card textarea { min-height: 82px; }
.reply-preview { border-radius: 10px; padding: 11px; background: #fff2f4; color: #71303b; line-height: 1.6; }

.life-page { min-height: 100vh; background: #111820; }
.life-shell { width: min(540px, 100%); min-height: 100vh; margin: 0 auto; background: #f7f4ef; color: #24292e; box-shadow: 0 0 80px rgba(0,0,0,.28); }
.life-stage { position: relative; min-height: 64vh; overflow: hidden; background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--character-color) 55%, white), #313944 78%); color: white; }
.life-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.life-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--character-color) 68%, white) 0, color-mix(in srgb, var(--character-color) 65%, #7c685c) 34%, #28323a 100%); }
.life-placeholder span { font-size: 7.5rem; filter: drop-shadow(0 20px 22px rgba(0,0,0,.24)); animation: breathe 3.8s ease-in-out infinite; }
.life-placeholder small { padding: 7px 12px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(20,25,30,.2); backdrop-filter: blur(8px); }
@keyframes breathe { 50% { transform: translateY(-7px) scale(1.02); } }
.stage-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(4,7,10,.46) 0, transparent 32%, transparent 53%, rgba(5,7,10,.72) 100%); pointer-events: none; }
.life-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; justify-content: space-between; padding: calc(18px + env(safe-area-inset-top)) 20px 0; font-size: .78rem; letter-spacing: .05em; }
.life-top div { display: flex; gap: 9px; align-items: center; }
.live-mark { padding: 4px 7px; border-radius: 6px; background: var(--character-color); font-size: .66rem; font-weight: 900; }
.scene-copy { position: absolute; z-index: 2; left: 22px; right: 74px; bottom: 32px; }
.today-label { color: rgba(255,255,255,.72); font-size: .76rem; }
.scene-copy h1 { margin: 8px 0 4px; font-size: clamp(1.65rem, 7vw, 2.35rem); line-height: 1.18; text-shadow: 0 2px 15px rgba(0,0,0,.34); }
.scene-copy p { margin: 0; color: rgba(255,255,255,.82); }
.sound-button, .audio-pill { position: absolute; z-index: 3; border: 1px solid rgba(255,255,255,.34); color: white; background: rgba(16,22,27,.32); backdrop-filter: blur(10px); cursor: pointer; }
.sound-button { right: 18px; top: calc(56px + env(safe-area-inset-top)); border-radius: 999px; padding: 9px 12px; font-size: .78rem; }
.audio-pill { left: 22px; bottom: 112px; border-radius: 999px; padding: 9px 13px; }
.note-fab { position: absolute; z-index: 3; right: 17px; bottom: 24px; width: 52px; height: 52px; border: 0; border-radius: 18px; color: white; background: var(--character-color); box-shadow: 0 12px 26px rgba(0,0,0,.24); cursor: pointer; }
.note-fab span { position: absolute; right: 58px; top: 15px; white-space: nowrap; color: white; font-size: .78rem; }
.life-panel { padding: 24px 20px 32px; }
.character-intro { display: grid; grid-template-columns: 54px minmax(0,1fr); gap: 13px; align-items: center; padding-bottom: 22px; border-bottom: 1px solid #e5dfd7; }
.character-avatar { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; background: color-mix(in srgb, var(--character-color) 78%, white); color: white; font-size: 1.35rem; font-weight: 900; }
.character-intro span { color: #8a8078; font-size: .78rem; }
.character-intro h2 { margin: 5px 0 0; font-size: 1rem; line-height: 1.55; }
.timeline { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 58px 1fr; gap: 12px; min-height: 50px; color: #8b8580; }
.timeline li::before { content: ""; position: absolute; left: 62px; top: 8px; width: 7px; height: 7px; border: 2px solid #c9c1ba; border-radius: 50%; background: #f7f4ef; }
.timeline li::after { content: ""; position: absolute; left: 66px; top: 18px; bottom: -2px; width: 1px; background: #ddd6cf; }
.timeline li:last-child::after { display: none; }
.timeline time { font-size: .76rem; padding-top: 4px; }
.timeline span { padding-left: 15px; line-height: 1.5; }
.timeline li.active { color: #282c30; font-weight: 750; }
.timeline li.active::before { border-color: var(--character-color); background: var(--character-color); box-shadow: 0 0 0 5px color-mix(in srgb, var(--character-color) 20%, transparent); }
.reply-section { margin-top: 20px; }
.reply-section h3 { font-size: 1rem; }
.paper-item { margin: 10px 0; padding: 15px; border-radius: 5px 15px 15px 15px; background: #fff6c9; box-shadow: 0 8px 18px rgba(75,61,34,.08); transform: rotate(-.3deg); }
.paper-item p { margin: 0 0 10px; color: #685f4c; }
.paper-item div { font-size: .9rem; line-height: 1.55; }
.life-foot { padding: 0 20px calc(28px + env(safe-area-inset-bottom)); text-align: center; color: #999087; font-size: .76rem; }
.empty-life { min-height: 100vh; display: grid; place-content: center; padding: 30px; color: white; text-align: center; }

.sheet-open { overflow: hidden; }
.note-sheet { position: fixed; z-index: 20; inset: 0; display: grid; align-items: end; }
.sheet-backdrop { position: absolute; inset: 0; border: 0; background: rgba(8,12,15,.6); backdrop-filter: blur(4px); }
.note-sheet > section { position: relative; z-index: 1; width: min(540px, 100%); margin: 0 auto; padding: 10px 22px calc(24px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: #fffaf0; box-shadow: 0 -20px 60px rgba(0,0,0,.25); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 18px; border-radius: 999px; background: #d8d0c5; }
.note-sheet h2 { margin: 0 0 6px; }
.note-sheet p { margin: 0; color: #7c746b; }
.form-feedback { min-height: 24px; margin-top: 10px; color: #9c3a49; text-align: center; font-size: .88rem; }
.form-feedback.success { color: #25724a; }

@media (max-width: 1000px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px 18px; gap: 14px; }
  .nav { grid-template-columns: repeat(5, 1fr); overflow-x: auto; }
  .nav a { text-align: center; padding: 9px 5px; font-size: .82rem; }
  .sidebar-foot { display: none; }
  .admin-main { padding: 20px 14px; }
  .upload-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .grid-two, .form-row, .note-admin-list { grid-template-columns: 1fr; }
  .page-head { display: block; }
  .page-head .button { margin-top: 14px; }
}
@media (max-width: 430px) {
  .life-stage { min-height: 68vh; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 14px; }
  .metric strong { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Keep the complete portrait frame; put copy in the bottom desk area. */
.life-stage { min-height: 0; aspect-ratio: 9 / 16; background: #191b1e; }
.life-media { position: relative; inset: auto; display: block; width: 100%; height: auto; aspect-ratio: 9 / 16; object-fit: contain; background: #111; }
.scene-copy { position: absolute; left: 4%; right: 16%; bottom: 2.5%; padding: 0; min-height: 0; background: transparent; text-shadow: 0 2px 8px rgba(0,0,0,.75); }
.scene-copy h1 { margin: 5px 0 4px; font-size: clamp(1.2rem, 5vw, 1.7rem); line-height: 1.25; }
.scene-copy p { font-size: .9rem; line-height: 1.5; }
.stage-shade { background: linear-gradient(180deg, rgba(4,7,10,.35), transparent 120px), linear-gradient(0deg, rgba(4,7,10,.55), transparent 18%); }
.note-fab { bottom: 28px; }
.note-fab span { position: static; display: block; font-size: .62rem; }
.audio-pill { bottom: auto; top: 118px; }
