:root {
  --ground: #eef2ec;
  --surface: #ffffff;
  --raised: #f7f9f6;
  --text: #183b35;
  --muted: #53675e;
  --border: #dbe5dc;
  --rule: #edf1ec;
  --control: #aebeb1;
  --accent: #f2565d;
  --accent-soft: #fde9ea;
  --accent-ink: #902d37;
  --primary: #183b35;
  --positive-bg: #e0efe4;
  --positive-ink: #215a39;
  --font-ui: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-display: "Noto Serif SC", "Songti SC", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); font-family: var(--font-ui); background: var(--ground); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.small-mark { display: inline-flex; align-items: end; gap: 2px; width: 36px; height: 28px; flex: 0 0 auto; }
.small-mark span { width: 10px; height: 21px; background: var(--accent); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.small-mark span:nth-child(1) { height: 14px; }
.small-mark span:nth-child(3) { height: 17px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 36px; padding: 8px 16px; border-radius: 6px; border: 1px solid transparent; font-weight: 600; line-height: 1.2; text-decoration: none; transition: transform .18s ease, background-color .18s ease, border-color .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: #245348; }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--control); }
.button-secondary:hover { border-color: var(--text); }
.button-plain { background: transparent; color: var(--muted); }
.button-plain:hover { color: var(--text); }

/* Desktop frame: 232px sidebar + 1px divider + remaining canvas. Canvas padding is 29px on each side. */
.admin-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100svh; }
.admin-sidebar { display: flex; flex-direction: column; background: var(--ground); border-right: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; height: 64px; padding: 0 22px; border-bottom: 1px solid var(--border); font-family: var(--font-display); font-size: 16px; font-weight: 700; line-height: 1.05; white-space: nowrap; }
.sidebar-brand small { font-family: var(--font-ui); font-size: 11px; font-weight: 500; }
.sidebar-close { display: none; }
.admin-nav { padding: 28px 12px 12px; }
.nav-heading { margin: 0 10px 14px; color: var(--muted); font-size: 12px; }
.nav-item { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); text-align: left; font-size: 14px; }
.nav-item + .nav-item { margin-top: 4px; }
.nav-item:hover { color: var(--text); background: #e6ece6; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item span { font-variant-numeric: tabular-nums; font-weight: 500; }
.sidebar-bottom { margin-top: auto; padding: 0 24px 26px; display: grid; gap: 16px; }
.sidebar-bottom a { color: var(--muted); font-size: 13px; text-decoration: none; }
.sidebar-bottom a:hover { color: var(--text); text-decoration: underline; }
.admin-main { min-width: 0; }
.admin-topbar { height: 64px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--ground); }
.topbar-left { display: flex; align-items: center; gap: 16px; padding-left: 29px; min-width: 0; font-size: 14px; font-weight: 600; }
.topbar-scope { font-size: 13px; color: var(--muted); font-weight: 400; padding-left: 16px; border-left: 1px solid var(--border); white-space: nowrap; }
.topbar-account { height: 100%; min-width: 168px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 20px; border-left: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.topbar-account strong { color: var(--text); font-weight: 600; }
.account-dot { width: 6px; height: 6px; margin-left: 7px; border-radius: 50%; background: var(--accent); }
.mobile-menu-button { display: none; }
.admin-canvas { padding: 24px 29px 80px; max-width: 1500px; }
.prototype-note { margin: 0 0 28px; padding: 12px 16px; background: var(--accent-soft); color: #71313a; border-radius: 6px; font-size: 13px; line-height: 1.55; }
.screen-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 0 24px; }
.screen-heading h1 { margin: 0 0 7px; font-size: 26px; line-height: 1.3; font-weight: 700; }
.screen-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.screen-heading .button { flex: 0 0 auto; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.search-field { display: block; width: min(100%, 308px); }
.search-field input { width: 100%; height: 36px; padding: 0 12px; background: var(--surface); border: 1px solid var(--control); border-radius: 6px; color: var(--text); font-size: 14px; }
.search-field input::placeholder { color: #66766d; }
.list-total { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.album-list { padding: 0 18px; }
.album-list-head, .album-row { display: grid; grid-template-columns: minmax(250px, 2.2fr) minmax(140px, 1fr) minmax(95px, .6fr) minmax(90px, .7fr) 150px; gap: 18px; align-items: center; }
.album-list-head { min-height: 43px; color: var(--muted); font-size: 12px; }
.album-row { min-height: 83px; border-top: 1px solid var(--rule); font-size: 14px; }
.album-row:first-of-type { border-top: 0; }
.album-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.album-identity img { width: 54px; height: 54px; flex: 0 0 54px; object-fit: cover; border-radius: 4px; }
.album-identity div { min-width: 0; }
.album-identity strong { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-identity small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-region { color: var(--muted); white-space: nowrap; }
.album-count { white-space: nowrap; }
.album-count small { color: var(--muted); font-size: 12px; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.status { display: inline-block; padding: 3px 9px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.status-public { background: var(--positive-bg); color: var(--positive-ink); }
.status-draft { background: var(--accent-soft); color: var(--accent-ink); }
.row-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.row-actions button, .row-actions a, .text-action { padding: 2px 0; border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; }
.row-actions button:hover, .row-actions a:hover, .text-action:hover { color: var(--accent-ink); text-decoration: underline; }
.empty-search { padding: 26px 8px; color: var(--muted); font-size: 14px; }
.work-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: 24px; margin-top: 29px; align-items: start; }
.module-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.module-heading h2 { margin: 0; font-size: 18px; font-weight: 600; }
.module-heading h2 span { color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.upload-panel { padding: 17px 18px 15px; }
.upload-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-fields label { color: var(--muted); font-size: 12px; }
.upload-fields select { display: block; width: 100%; height: 36px; margin-top: 6px; padding: 0 30px 0 10px; color: var(--text); background: var(--surface); border: 1px solid var(--control); border-radius: 6px; font-size: 13px; }
.upload-drop { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; min-height: 78px; margin-top: 14px; padding: 14px 16px; border: 1px dashed var(--control); border-radius: 6px; cursor: pointer; }
.upload-drop:hover { border-color: var(--accent); background: #fff8f8; }
.upload-drop strong { color: var(--accent-ink); font-size: 14px; }
.upload-drop span { color: var(--muted); font-size: 12px; }
.upload-selection { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.comment-preview { padding: 19px 20px; min-height: 225px; display: flex; flex-direction: column; }
.comment-context { display: grid; grid-template-columns: 106px minmax(0, 1fr); gap: 14px; align-items: start; }
.comment-context img { width: 106px; height: 135px; border-radius: 4px; object-fit: cover; }
.comment-source { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.comment-text { margin: 0; font-size: 15px; line-height: 1.6; }
.comment-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 20px; }
.comment-actions .button { min-width: 68px; min-height: 32px; font-size: 13px; }
.photo-tabs { display: flex; gap: 6px; max-width: 100%; overflow-x: auto; margin-bottom: 18px; padding-bottom: 4px; }
.photo-tabs button { flex: 0 0 auto; padding: 8px 14px; background: transparent; border: 1px solid var(--control); border-radius: 6px; color: var(--muted); font-size: 13px; }
.photo-tabs button.is-active { background: var(--accent-soft); border-color: #f5bcc0; color: var(--accent-ink); font-weight: 600; }
.photo-list { padding: 0 18px; }
.photo-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) 110px 110px 140px; gap: 18px; align-items: center; min-height: 104px; border-top: 1px solid var(--rule); }
.photo-row:first-child { border-top: 0; }
.photo-row img { width: 72px; height: 72px; border-radius: 4px; object-fit: cover; }
.photo-row .photo-name { min-width: 0; }
.photo-name strong { display: block; font-size: 14px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.photo-name small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.photo-row label { color: var(--muted); font-size: 12px; }
.photo-row select { display: block; width: 100%; height: 32px; margin-top: 5px; border: 1px solid var(--control); border-radius: 6px; background: #fff; color: var(--text); font-size: 13px; }
.photo-row button { width: fit-content; border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 600; }
.photo-row button:hover { color: var(--accent-ink); text-decoration: underline; }
.photo-row button:disabled { color: #84928a; text-decoration: none; }
.photo-row .cover-yes { color: var(--accent-ink); }
.photo-sort { display: flex; align-items: center; justify-content: flex-end; gap: 8px; white-space: nowrap; }
.photo-sort span { color: var(--muted); font-size: 12px; }
.photo-sort button { padding: 2px 0; font-size: 12px; }
.section-footnote { margin: 15px 0 0; color: var(--muted); font-size: 13px; }
.settings-form { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; padding: 20px; margin-bottom: 18px; }
.settings-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.settings-form input { min-height: 36px; padding: 6px 10px; border: 1px solid var(--control); border-radius: 6px; }
.region-list { padding: 0 20px; }
.region-row { display: flex; align-items: center; gap: 24px; min-height: 62px; border-top: 1px solid var(--rule); font-size: 14px; }
.region-row:first-child { border: 0; }
.region-row span { margin-left: auto; color: var(--muted); }
.region-row button { border: 0; background: transparent; color: var(--text); font-weight: 600; }
.upload-panel #upload-files { display: block; max-width: 100%; margin: 12px 0; font-size: 13px; }
.upload-panel > button { margin-top: 4px; }
.photo-row .photo-name button { display: block; margin-top: 5px; padding: 0; }
.photo-sort { flex-wrap: wrap; }
.comments-summary { display: flex; gap: 20px; align-items: baseline; margin: 0 0 16px; }
.comments-summary strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.comments-summary span { color: var(--muted); font-size: 13px; }
.comment-queue { padding: 0 20px; }
.queue-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 15px; padding: 20px 0; }
.queue-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 15px; }
.queue-meta { display: flex; align-items: baseline; gap: 10px; }
.queue-meta strong { font-size: 14px; }
.queue-meta span { color: var(--muted); font-size: 12px; }
.queue-body p { margin: 7px 0; font-size: 14px; line-height: 1.6; }
.queue-body small { color: var(--muted); font-size: 12px; }
.queue-actions { display: flex; gap: 7px; align-self: center; }
.queue-actions .button { min-height: 32px; font-size: 13px; }
.empty-queue { margin: 0; padding: 26px 0; color: var(--muted); font-size: 14px; }
.edit-dialog { width: min(94vw, 520px); padding: 24px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); box-shadow: 0 18px 50px rgba(24,59,53,.14); }
.edit-dialog::backdrop { background: rgba(18,42,36,.52); }
.edit-dialog form { display: grid; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; font-size: 21px; }
.dialog-close { background: none; border: 0; font-size: 28px; line-height: 1; color: var(--muted); }
.edit-dialog label { margin: 0 0 7px; font-size: 14px; font-weight: 600; }
.edit-dialog input, .edit-dialog textarea { width: 100%; margin-bottom: 16px; padding: 9px 11px; border: 1px solid var(--control); border-radius: 6px; background: #fff; color: var(--text); font-size: 14px; }
.dialog-note { margin: 0 0 16px; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; padding: 12px 16px; border-radius: 6px; background: var(--primary); color: #fff; font-size: 13px; box-shadow: 0 8px 24px rgba(24,59,53,.2); }

.login-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(460px, .95fr); min-height: 100svh; }
.login-photo { position: relative; min-height: 100svh; overflow: hidden; background: var(--primary); }
.login-photo > img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.login-photo-footer { position: absolute; inset: auto 28px 28px; display: flex; justify-content: space-between; gap: 18px; padding: 10px 12px; background: rgba(18, 42, 36, .86); color: #fff; font-size: 13px; font-weight: 600; }
.login-content { background: var(--ground); }
.login-content-inner { display: flex; flex-direction: column; min-height: 100svh; padding: 30px clamp(30px, 5vw, 72px); }
.return-link { width: fit-content; color: var(--muted); text-decoration: none; font-size: 14px; }
.return-link:hover { color: var(--text); text-decoration: underline; }
.login-form-wrap { width: min(100%, 430px); margin: auto; padding: 65px 0; }
.login-form-wrap .small-mark { margin-bottom: 26px; }
.login-form-wrap h1 { margin: 0 0 13px; font-family: var(--font-display); font-size: 32px; line-height: 1.25; }
.login-description { margin: 0 0 34px; color: var(--muted); font-size: 16px; }
.login-form-wrap form { display: grid; }
.login-form-wrap label { margin-bottom: 9px; font-size: 14px; font-weight: 600; }
.login-form-wrap input { height: 46px; margin-bottom: 21px; padding: 0 13px; border: 1px solid var(--control); border-radius: 6px; background: #fff; color: var(--text); font-size: 16px; }
.login-submit { height: 46px; margin-top: 6px; font-size: 15px; }
.login-message { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.preview-link { display: inline-block; margin-top: 24px; color: var(--accent-ink); font-size: 14px; font-weight: 600; text-decoration: none; }
.preview-link:hover { text-decoration: underline; }
.login-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

@media (max-width: 1100px) {
  .album-list-head, .album-row { grid-template-columns: minmax(190px, 1.7fr) 85px 85px 140px; gap: 12px; }
  .album-list-head span:nth-child(2), .album-region { display: none; }
  .album-list-head span:nth-child(3) { grid-column: 2; }
  .work-grid { grid-template-columns: 1fr; }
  .comment-preview { min-height: 175px; }
}

@media (max-width: 900px) {
  .admin-shell { display: block; }
  .admin-sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(360px, 90vw); transform: translateX(-105%); transition: transform .25s ease; }
  .admin-sidebar.is-open { transform: translateX(0); }
  .sidebar-close { display: block; margin-left: auto; border: 0; background: none; color: var(--text); font-size: 26px; }
  .admin-topbar { height: 56px; }
  .mobile-menu-button { display: inline-flex; align-items: center; min-height: 44px; border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 600; }
  .topbar-left { padding-left: 20px; gap: 12px; }
  .topbar-account { min-width: 130px; }
  .admin-canvas { padding: 20px 24px 64px; }
  .login-layout { grid-template-columns: minmax(0, 1fr) minmax(380px, 1fr); }
}

@media (max-width: 640px) {
  .admin-topbar { height: 52px; }
  .topbar-left { padding-left: 16px; }
  .topbar-scope { display: none; }
  .topbar-account { min-width: auto; padding: 0 16px; }
  .topbar-account .account-dot { display: none; }
  .admin-canvas { padding: 18px 16px 60px; }
  .prototype-note { margin-bottom: 22px; font-size: 12px; }
  .screen-heading { align-items: start; margin-bottom: 22px; }
  .screen-heading h1 { font-size: 22px; }
  .screen-heading p { max-width: 29ch; font-size: 13px; }
  .screen-heading .button { min-height: 44px; padding: 8px 11px; font-size: 12px; }
  .list-toolbar { margin-bottom: 10px; }
  .search-field { flex: 1; }
  .list-total { white-space: nowrap; }
  .album-list { padding: 0 16px; }
  .album-list-head { display: none; }
  .album-row { grid-template-columns: 1fr auto; gap: 9px 10px; padding: 15px 0; }
  .album-row:first-of-type { border-top: 0; }
  .album-identity { grid-column: 1 / -1; }
  .album-count { grid-column: 1; text-align: left; color: var(--muted); font-size: 13px; }
  .album-row > div:nth-child(4) { grid-column: 2; }
  .row-actions { grid-column: 1 / -1; gap: 20px; padding-left: 68px; }
  .row-actions button, .row-actions a { min-height: 32px; display: inline-flex; align-items: center; }
  .work-grid { gap: 24px; margin-top: 26px; }
  .upload-fields { gap: 10px; }
  .upload-drop { display: block; }
  .upload-drop span { display: block; margin-top: 4px; line-height: 1.4; }
  .comment-preview { min-height: 180px; }
  .comment-context { grid-template-columns: 82px minmax(0, 1fr); gap: 12px; }
  .comment-context img { width: 82px; height: 82px; }
  .photo-row { grid-template-columns: 62px minmax(0, 1fr) auto; gap: 8px 12px; padding: 15px 0; }
  .photo-row img { width: 62px; height: 62px; grid-row: 1 / 3; }
  .photo-row .photo-name { grid-column: 2 / 4; }
  .photo-row label { grid-column: 2; }
  .photo-row > button { grid-column: 3; }
  .photo-sort { grid-column: 2 / 4; justify-content: flex-start; }
  .queue-row { grid-template-columns: 34px 1fr; }
  .queue-avatar { width: 34px; height: 34px; }
  .queue-actions { grid-column: 2; justify-content: start; }
  .queue-actions .button { min-height: 44px; }
  .login-layout { display: block; }
  .login-photo { min-height: 0; height: 29svh; }
  .login-photo-footer { inset: auto 16px 16px; font-size: 11px; }
  .login-photo-footer span:last-child { display: none; }
  .login-content-inner { min-height: 71svh; padding: 22px 22px 28px; }
  .login-form-wrap { padding: 48px 0; }
  .login-form-wrap h1 { font-size: 26px; }
}

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