:root {
  color-scheme: light;
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  color: #27302d;
  background: #e9eee8;
  --paper: #fff;
  --ink: #27302d;
  --muted: #6b7671;
  --line: #dce2dd;
  --red: #a3313f;
  --red-dark: #842735;
  --teal: #245b5d;
  --gold: #ac7c3e;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: #e9eee8; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button, input, textarea { letter-spacing: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible, .upload-zone:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { flex: none; width: 18px; height: 18px; stroke-width: 1.8; }
.page-width, .header-inner { width: min(1260px, calc(100% - 64px)); margin-inline: auto; }

.site-header { position: relative; z-index: 10; height: 80px; background: #f8faf7; border-bottom: 1px solid #bfcfc4; }
.header-inner { position: relative; height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 13px; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; white-space: nowrap; }
.brand-icon { display: block; width: 40px; height: 40px; object-fit: contain; border-radius: 4px; }
.brand-name { display: block; font-family: "Noto Serif SC", "Songti SC", serif; font-weight: 700; font-size: 22px; line-height: 1.1; }
.primary-nav { position: absolute; left: 50%; display: flex; align-items: center; gap: 30px; height: 100%; transform: translateX(-50%); }
.nav-button { display: inline-flex; align-items: center; justify-content: center; height: 100%; padding: 3px 0 0; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #596661; white-space: nowrap; }
.nav-button:hover, .nav-button.active { color: var(--red); }
.nav-button.active { border-bottom-color: var(--red); font-weight: 700; }
.admin-link svg { width: 19px; height: 19px; }

main { position: relative; min-height: calc(100vh - 142px); background: #e9eee8; isolation: isolate; }
.scene-backdrop { position: absolute; z-index: -1; inset: 0 0 auto; height: 560px; overflow: hidden; background: #d5ded6; }
.scene-image { position: absolute; inset: 0; background-position: center 30%; background-size: cover; opacity: 0; transition: opacity 1.2s ease; }
.scene-image.is-visible { opacity: 1; }
.scene-01 { background-image: url('/backgrounds/scene-01.webp'); }
.scene-02 { background-image: url('/backgrounds/scene-02.webp'); }
.scene-03 { background-image: url('/backgrounds/scene-03.webp'); }
.scene-04 { background-image: url('/backgrounds/scene-04.webp'); }
.scene-05 { background-image: url('/backgrounds/scene-05.webp'); }
.scene-06 { background-image: url('/backgrounds/scene-06.webp'); }
.scene-backdrop::after { position: absolute; inset: 0; content: ""; background: linear-gradient(to bottom, #f7faf526 0%, #f7faf526 42%, #e9eee826 86%, #e9eee8 100%); }
.view { position: relative; padding-block: 47px 80px; }
.gallery-view .view-heading { min-height: 208px; align-items: flex-start; padding-top: 27px; }
.view-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 35px; }
.eyebrow { margin: 0 0 8px; color: #a34c3f; font-size: 12px; font-weight: 700; line-height: 1.5; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 41px; font-weight: 700; line-height: 1.25; }
.subheading { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.record-count { padding-top: 15px; color: #526b61; white-space: nowrap; }
.compact-heading { min-height: 165px; align-items: flex-start; margin-bottom: 46px; padding: 32px 0 24px; border-bottom: 1px solid #aebfb5; }
.compact-heading h1 { font-size: 34px; }

.gallery-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid #b7c8bd; }
.toolbar-caption { color: #385b50; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 17px; font-weight: 700; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: #e9eeea; }
.segment { min-width: 68px; height: 35px; padding: 0 13px; border: 0; border-radius: 3px; background: transparent; color: #66736c; }
.segment:hover { color: var(--ink); }
.segment.active { background: #fff; color: var(--red); font-weight: 700; box-shadow: 0 1px 5px #24352914; }
.search-field { display: flex; align-items: center; gap: 9px; width: min(100%, 286px); height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 19px; margin-top: 25px; }
.portrait-card { overflow: hidden; border: 1px solid #c8d6ca; border-radius: 6px; background: #f9fbf8; text-align: left; padding: 0; min-width: 0; transition: transform .16s ease, box-shadow .16s ease; }
.portrait-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px #13231a15; }
.portrait-cover { position: relative; overflow: hidden; width: 100%; aspect-ratio: 3 / 4; background: #e6eae5; }
.portrait-cover img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.media-mark { position: absolute; right: 10px; bottom: 10px; display: grid; place-items: center; width: 33px; height: 33px; border-radius: 50%; background: #fffef5e8; color: var(--red); }
.media-mark svg { width: 17px; height: 17px; fill: currentColor; stroke-width: 0; }
.portrait-info { padding: 15px 15px 17px; }
.portrait-info h2 { overflow: hidden; margin: 0 0 6px; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 18px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.portrait-info p { overflow: hidden; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; text-overflow: ellipsis; white-space: nowrap; }
.empty-gallery { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 25px; text-align: center; }
.empty-symbol { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 20px; border: 1px solid #b9ccc0; border-radius: 50%; background: #f2f6f0a8; color: #547368; }
.empty-symbol svg { width: 28px; height: 28px; }
.empty-gallery h2 { margin: 0 0 7px; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 20px; }
.empty-gallery p { margin: 0; color: var(--muted); font-size: 13px; }

.license-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 70px; }
.license-main { max-width: 750px; }
.section-label { display: flex; align-items: baseline; gap: 15px; margin-bottom: 27px; }
.section-label span { color: var(--red); font-family: Georgia, serif; font-size: 14px; }
.section-label h2 { margin: 0; font-size: 21px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 18px; }
.field { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field-label { color: #4f5e57; font-size: 13px; font-weight: 600; }
.field input, .field textarea { width: 100%; min-width: 0; padding: 11px 12px; border: 1px solid #cfd9d2; border-radius: 4px; background: #fff; color: var(--ink); line-height: 1.5; }
.field input { height: 44px; }
.field textarea { resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #9aa6a0; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 4px; font-size: 13px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.button svg { width: 16px; height: 16px; }
.button.primary { background: var(--red); color: #fff; }
.button.primary:hover { background: var(--red-dark); }
.button.quiet { border-color: var(--line); background: #fff; color: #4d5d55; }
.button.quiet:hover { background: #eef2ed; }
.form-grid > .button { width: max-content; margin-top: 4px; }
.license-aside { align-self: start; padding-left: 28px; border-left: 1px solid var(--line); }
.aside-rule { display: flex; justify-content: space-between; gap: 15px; padding: 15px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.aside-rule:first-child { padding-top: 0; }
.aside-rule span { color: var(--muted); }
.aside-rule strong { font-weight: 600; text-align: right; }
.license-aside p { margin: 24px 0 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
code { padding: 1px 4px; border-radius: 3px; background: #e7ece8; color: #38544b; font-family: Consolas, monospace; }
.license-result { margin-top: 30px; padding: 18px 20px; border-left: 3px solid var(--teal); background: #e9f0ed; line-height: 1.7; }
.license-result strong { display: block; margin-bottom: 4px; }
.license-result a { color: var(--red); font-weight: 700; overflow-wrap: anywhere; }

.login-form { display: flex; align-items: end; gap: 12px; max-width: 560px; }
.login-form .field { flex: 1; }
.admin-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.admin-tab { min-height: 46px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); }
.admin-tab.active { border-bottom-color: var(--red); color: var(--red); font-weight: 700; }
.admin-panel { padding-top: 30px; }
.admin-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.admin-panel-heading h2 { margin: 0 0 4px; font-size: 19px; }
.admin-panel-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.voucher-create { display: flex; align-items: end; gap: 10px; }
.voucher-create .field { width: 76px; }
.new-codes { display: flex; align-items: end; gap: 12px; padding: 14px 0 20px; }
.new-codes .field { flex: 1; }
.new-codes textarea { font-family: Consolas, monospace; }
.secondary-heading { margin-top: 40px; }
.upload-status { min-height: 1.4em; margin: 12px 0 0; color: var(--muted); font-size: 13px; text-align: right; }
.admin-list { border-top: 1px solid var(--line); }
.admin-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; align-items: center; gap: 16px; min-height: 88px; padding: 12px 6px; border-bottom: 1px solid var(--line); }
.request-row { grid-template-columns: minmax(0, 1fr) auto; }
.admin-thumb { width: 62px; height: 62px; border-radius: 3px; background: #e1e8e1; object-fit: cover; }
.admin-row-main { min-width: 0; }
.admin-row-main strong { display: block; overflow: hidden; margin-bottom: 5px; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.admin-row-main span { color: var(--muted); font-size: 12px; }
.admin-row-actions { display: flex; align-items: center; gap: 9px; }
.status-label { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 3px; background: #e7eee9; color: var(--teal); font-size: 11px; }
.status-label.draft { background: #efede7; color: #7a6b4d; }
.icon-button { display: inline-grid; place-items: center; width: 35px; height: 35px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: #5d6b64; }
.icon-button:hover { color: var(--red); border-color: #d4aeb2; }
.list-empty { padding: 30px 6px; color: var(--muted); font-size: 13px; }

dialog { border: 0; padding: 0; }
dialog::backdrop { background: #17201dc9; }
.viewer-dialog { --viewer-ratio: 1.7778; width: min(1000px, calc(100vw - 32px), calc((100vh - 145px) * var(--viewer-ratio))); max-height: calc(100vh - 28px); overflow: auto; border-radius: 6px; background: #17201d; color: #fff; }
.viewer-media { position: relative; width: 100%; aspect-ratio: var(--viewer-ratio, 1.7778); max-height: calc(100vh - 125px); margin: 0 auto; overflow: hidden; background: #101713; }
.viewer-media img, .viewer-media video { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; background: #101713; }
.viewer-status { position: absolute; inset: auto 12px 12px; z-index: 1; width: fit-content; max-width: calc(100% - 24px); margin: 0; padding: 7px 10px; border-radius: 4px; background: #101713d9; color: #fff; font-size: 12px; pointer-events: none; }
.viewer-status[hidden] { display: none; }
.viewer-close { position: absolute; top: 12px; right: 12px; z-index: 1; border-color: #ffffff4a; background: #17201de6; color: #fff; }
.viewer-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 16px 22px 19px; }
.viewer-meta h2 { margin: 0; font-size: 17px; }
.viewer-meta p { margin: 0; color: #c6d1c7; font-size: 12px; }
.entry-dialog { width: min(620px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; border-radius: 6px; background: #fff; color: var(--ink); }
.entry-form { display: flex; flex-direction: column; gap: 18px; padding: 25px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.dialog-header h2 { margin: 0; font-size: 19px; }
.upload-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 152px; padding: 12px; border: 1px dashed #b9c9be; border-radius: 4px; background: #f8faf8; text-align: center; cursor: pointer; }
.upload-zone:hover { border-color: var(--teal); background: #f0f6f2; }
.upload-zone svg { width: 24px; height: 24px; color: var(--teal); }
.upload-zone strong { font-size: 13px; }
.upload-zone small { color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-notice { margin: -4px 0 0; color: #7a6654; font-size: 11px; line-height: 1.6; }
.toggle-row { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; }
.toggle-row input { width: 17px; height: 17px; accent-color: var(--red); }
.dialog-actions { display: flex; justify-content: end; gap: 10px; padding-top: 8px; }
.toast { position: fixed; z-index: 40; right: 24px; bottom: 24px; min-width: 220px; max-width: min(400px, calc(100vw - 48px)); padding: 12px 16px; border-radius: 4px; background: #273b33; color: #fff; box-shadow: 0 10px 25px #17201d42; font-size: 13px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red-dark); }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 62px; padding-inline: max(32px, calc((100vw - 1260px)/2)); border-top: 1px solid #c3d0c6; background: #e9eee8; color: #708479; font-size: 11px; }

@media (max-width: 980px) {
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .license-layout { gap: 35px; grid-template-columns: minmax(0, 1fr) 250px; }
}
@media (max-width: 720px) {
  .scene-backdrop { height: 450px; }
  .scene-image { background-position: center 30%; }
  .page-width, .header-inner { width: min(100% - 32px, 1260px); }
  .site-header { height: 68px; }
  .brand-icon { width: 34px; height: 34px; }
  .brand-name { display: block; font-size: 17px; }
  .primary-nav { gap: 16px; }
  .nav-button { font-size: 12px; }
  .nav-button.admin-link { width: 24px; }
  .view { padding-block: 30px 60px; }
  .gallery-view .view-heading { min-height: 160px; padding-top: 18px; }
  .view-heading { margin-bottom: 24px; }
  h1 { font-size: 31px; }
  .compact-heading h1 { font-size: 29px; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
  .gallery-toolbar { flex-wrap: wrap; }
  .search-field { width: min(60%, 286px); }
  .license-layout { display: block; }
  .license-aside { margin-top: 50px; padding: 0; border-left: 0; border-top: 1px solid var(--line); }
  .aside-rule:first-child { padding-top: 18px; }
  .site-footer { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .scene-image { transition: none; }
}
@media (max-width: 430px) {
  .header-inner { gap: 7px; }
  .brand { gap: 6px; }
  .brand-icon { width: 30px; height: 30px; }
  .brand-name { font-size: 13px; }
  .primary-nav { gap: 8px; }
  .nav-button { font-size: 10px; }
  .nav-button.admin-link { width: 20px; }
  .search-field { width: 56%; }
  .record-count { font-size: 11px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .portrait-info { padding: 10px 10px 12px; }
  .portrait-info h2 { font-size: 15px; }
  .portrait-info p { font-size: 11px; }
  .login-form { align-items: stretch; flex-direction: column; }
  .entry-form { padding: 18px; }
  .admin-row { grid-template-columns: 52px minmax(0, 1fr); gap: 10px; }
  .admin-thumb { width: 48px; height: 48px; }
  .admin-row-actions { grid-column: 2; justify-content: start; }
  .voucher-create { flex-wrap: wrap; }
  .new-codes { align-items: stretch; flex-direction: column; }
  .viewer-dialog { width: min(1000px, calc(100vw - 24px), calc((100vh - 135px) * var(--viewer-ratio, 1.7778))); }
  .viewer-media { max-height: calc(100vh - 112px); }
  .viewer-meta { display: block; padding: 14px 16px 16px; }
  .viewer-meta p { margin-top: 6px; }
}
