@font-face {
  font-family: "HBQ Serif";
  src: url("../public/fonts/hbq-serif.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "HBQ Sans";
  src: url("../public/fonts/hbq-serif.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #f3eee5;
  --paper-deep: #e7dfd2;
  --ink: #191916;
  --muted: #746f67;
  --line: rgba(25, 25, 22, 0.14);
  --red: #9c3023;
  --red-dark: #772117;
  --white: #fffdf8;
  --sidebar: #171816;
  --success: #416747;
  --danger: #a02720;
  font-family: "HBQ Sans", "HBQ Serif", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-size: 16px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at 75% 15%, rgba(156,48,35,.12), transparent 32%), var(--paper); }
.login-card { width: min(480px, 100%); padding: 52px; background: rgba(255,253,248,.82); border: 1px solid var(--line); box-shadow: 0 24px 80px rgba(35,27,18,.09); }
.login-brand, .admin-topbar p, .dialog-frame header p { margin: 0 0 18px; color: var(--red); font-size: 14px; font-weight: 700; letter-spacing: .14em; }
.login-card h1 { margin: 0; font-family: "HBQ Serif", "HBQ Serif", "Songti SC", "STSong", serif; font-size: clamp(38px, 7vw, 58px); font-weight: 500; }
.login-note { margin: 20px 0 30px; color: var(--muted); line-height: 1.8; }
.login-card form { display: grid; gap: 20px; }
.login-card label, .form-grid label { display: grid; gap: 9px; color: var(--muted); font-size: 14px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 2px; background: var(--white); color: var(--ink); padding: 12px 14px; outline: none; }
textarea { min-height: 118px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(156,48,35,.09); }
.primary-button, .secondary-button { min-height: 44px; padding: 10px 20px; border: 1px solid transparent; cursor: pointer; font-weight: 700; }
.primary-button { color: white; background: var(--red); }
.primary-button:hover { background: var(--red-dark); }
.secondary-button { color: var(--ink); background: transparent; border-color: var(--line); }
.form-message { min-height: 24px; margin: 0; color: var(--danger); }
.back-link { display: inline-block; margin-top: 24px; color: var(--muted); text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar); color: #eee9df; padding: 28px 20px; }
.admin-brand { display: grid; gap: 6px; color: inherit; text-decoration: none; padding: 0 10px 25px; border-bottom: 1px solid rgba(255,255,255,.1); }
.admin-brand small { color: #bda58d; letter-spacing: .15em; }
.admin-brand strong { font-family: "HBQ Serif", "Songti SC", serif; font-size: 20px; font-weight: 500; }
.admin-nav { display: grid; gap: 5px; padding: 24px 0; }
.admin-nav button { border: 0; border-left: 2px solid transparent; background: transparent; color: #aaa79f; text-align: left; padding: 12px 16px; cursor: pointer; }
.admin-nav button:hover, .admin-nav button.is-active { color: white; border-left-color: #c16b56; background: rgba(255,255,255,.05); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #aaa79f; font-size: 13px; padding: 16px 10px 0; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot button { color: #d3a291; border: 0; background: transparent; cursor: pointer; }
.admin-main { min-width: 0; }
.admin-topbar { min-height: 124px; display: flex; align-items: center; gap: 24px; padding: 28px clamp(28px, 4vw, 68px); border-bottom: 1px solid var(--line); background: rgba(243,238,229,.92); }
.admin-topbar p { margin-bottom: 5px; }
.admin-topbar h1 { margin: 0; font-family: "HBQ Serif", "Songti SC", serif; font-size: clamp(28px, 3vw, 40px); font-weight: 500; }
.museum-switch { margin-left: auto; display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.museum-switch select { min-width: 190px; padding: 8px 10px; }
.view-site { color: var(--ink); text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 5px; white-space: nowrap; }
.mobile-menu { display: none; }
.content-panel { padding: 42px clamp(28px, 4vw, 68px) 80px; }

.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.panel-head h2 { margin: 0 0 6px; font-family: "HBQ Serif", "Songti SC", serif; font-size: 29px; font-weight: 500; }
.panel-head p { margin: 0; color: var(--muted); line-height: 1.6; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { min-height: 150px; padding: 25px; border: 1px solid var(--line); background: rgba(255,253,248,.5); }
.stat-card strong { display: block; color: var(--red); font-family: "HBQ Serif", Georgia, serif; font-size: 42px; font-weight: 500; }
.stat-card span { display: block; margin-top: 15px; color: var(--muted); }
.welcome-card { margin-top: 20px; display: grid; grid-template-columns: 1.2fr .8fr; border: 1px solid var(--line); background: var(--white); }
.welcome-card > div { padding: 28px; }
.welcome-card > div + div { border-left: 1px solid var(--line); }
.welcome-card h3 { margin: 0 0 14px; font-family: "HBQ Serif", "Songti SC", serif; font-size: 24px; font-weight: 500; }
.welcome-card p { margin: 0; color: var(--muted); line-height: 1.8; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar input { max-width: 360px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .primary-button { margin-left: auto; }
.data-table { width: 100%; border-collapse: collapse; background: rgba(255,253,248,.48); border-top: 1px solid var(--line); }
.data-table th { color: var(--muted); font-size: 13px; text-align: left; font-weight: 600; }
.data-table th, .data-table td { padding: 15px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table td strong { font-family: "HBQ Serif", "Songti SC", serif; font-size: 18px; font-weight: 500; }
.data-table td small { color: var(--muted); }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.text-button { border: 0; background: transparent; color: var(--red); cursor: pointer; padding: 6px; }
.text-button.danger { color: var(--danger); }
.empty-state { padding: 60px 20px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }
.type-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.type-tabs button { border: 1px solid var(--line); background: transparent; padding: 9px 15px; cursor: pointer; }
.type-tabs button.is-active { color: white; background: var(--red); border-color: var(--red); }
.page-list, .media-grid, .artist-grid { display: grid; gap: 14px; }
.page-card { display: grid; grid-template-columns: 170px 1fr auto; gap: 20px; align-items: center; padding: 20px; border-top: 1px solid var(--line); }
.page-card small { color: var(--red); font-weight: 700; }
.page-card p { margin: 0; color: var(--muted); line-height: 1.65; }
.media-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.media-card { overflow: hidden; border: 1px solid var(--line); background: var(--white); }
.media-preview { aspect-ratio: 4/3; display: grid; place-items: center; background: #ded8ce; overflow: hidden; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; }
.media-preview span { font-size: 38px; color: var(--muted); }
.media-card div:last-child { padding: 13px; }
.media-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.media-card button { margin-top: 8px; padding: 0; }
.upload-box { margin-bottom: 24px; display: flex; align-items: center; gap: 15px; padding: 22px; border: 1px dashed rgba(156,48,35,.35); background: rgba(255,253,248,.5); }
.upload-box input { background: transparent; border: 0; padding: 0; }
.artist-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.artist-card { padding: 22px; border: 1px solid var(--line); background: rgba(255,253,248,.5); }
.artist-card h3 { margin: 0; font-family: "HBQ Serif", "Songti SC", serif; font-size: 24px; font-weight: 500; }
.artist-card p { color: var(--muted); }
.status-pill { display: inline-block; margin-top: 10px; padding: 4px 9px; color: var(--success); border: 1px solid rgba(65,103,71,.3); font-size: 12px; }

.editor-dialog { width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; color: var(--ink); background: var(--paper); box-shadow: 0 30px 100px rgba(0,0,0,.28); }
.editor-dialog::backdrop { background: rgba(16,15,13,.65); }
.dialog-frame { display: grid; grid-template-rows: auto minmax(0,1fr) auto; max-height: calc(100vh - 32px); }
.dialog-frame header, .dialog-frame footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 26px; border-bottom: 1px solid var(--line); }
.dialog-frame footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.dialog-frame header p { margin-bottom: 4px; }
.dialog-frame h2 { margin: 0; font-family: "HBQ Serif", "Songti SC", serif; font-size: 28px; font-weight: 500; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 27px; }
.editor-body { overflow-y: auto; padding: 26px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-hint { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100vw - 48px)); padding: 14px 18px; color: white; background: var(--success); box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast.is-error { background: var(--danger); }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 10; width: 250px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-menu { display: inline-block; border: 1px solid var(--line); background: transparent; padding: 8px 10px; }
  .admin-topbar { min-height: 100px; padding: 20px 24px; }
  .museum-switch { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .welcome-card { grid-template-columns: 1fr; }
  .welcome-card > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .page-card { grid-template-columns: 1fr auto; }
  .page-card p { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .login-card { padding: 32px 24px; }
  .admin-topbar { gap: 14px; }
  .admin-topbar p { display: none; }
  .view-site { margin-left: auto; }
  .content-panel { padding: 28px 18px 60px; }
  .stats-grid, .form-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar input, .toolbar select { width: 100%; max-width: none; }
  .toolbar .primary-button { margin-left: 0; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .data-table td { padding: 5px 10px; border: 0; }
  .row-actions { justify-content: flex-start; }
  .upload-box { align-items: stretch; flex-direction: column; }
}
