:root {
  --thumbnail-ratio: 3 / 5;
  --ink: #1d1b19;
  --muted: #756f68;
  --paper: #f5f2eb;
  --surface: #fffdf9;
  --line: #ddd7cd;
  --gold: #9b7745;
  --forest: #34443b;
  --danger: #9d3d35;
  --shadow: 0 16px 45px rgba(36, 31, 25, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "DM Sans", "Noto Sans SC", sans-serif; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.wordmark { display: inline-flex; flex-direction: column; gap: 2px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 700; letter-spacing: .18em; line-height: 1; }
.wordmark span { color: var(--muted); font-size: 8px; letter-spacing: .24em; font-weight: 600; }
.wordmark.light { color: #f7f2e8; }
.wordmark.light span { color: rgba(255,255,255,.52); }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .24em; }
.eyebrow.light { color: #d1b88f; }
.muted { color: var(--muted); }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-visual { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 32px 7%; color: #f5f1e9; background: radial-gradient(circle at 72% 33%, rgba(189,159,111,.18), transparent 32%), linear-gradient(145deg, #18201c, #314239 60%, #18201c); }
.login-visual::before { content: ""; position: absolute; inset: 0; opacity: .14; background-image: linear-gradient(90deg, transparent 49.5%, #fff 50%, transparent 50.5%), linear-gradient(0deg, transparent 49.5%, #fff 50%, transparent 50.5%); background-size: 90px 90px; mask-image: linear-gradient(to bottom, transparent, #000, transparent); }
.login-visual > * { position: relative; z-index: 1; }
.login-copy { max-width: 600px; padding: 6vh 0; }
.login-copy h1 { margin: 0 0 16px; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(38px, 4.5vw, 64px); font-weight: 400; line-height: 1.18; letter-spacing: -.04em; }
.login-copy > p:last-child { width: min(440px, 86%); margin: 0; color: rgba(255,255,255,.64); font-size: 15px; line-height: 1.9; }
.visual-seal { width: 104px; height: 104px; align-self: flex-end; border: 1px solid rgba(255,255,255,.32); border-radius: 50%; display: grid; place-content: center; text-align: center; transform: rotate(-8deg); }
.visual-seal span { font-size: 7px; letter-spacing: .26em; color: #cbb998; }
.visual-seal b { margin: 4px 0; font-family: Georgia, serif; font-size: 30px; font-weight: 400; }
.login-panel { display: grid; place-items: center; padding: 32px; background: #f9f7f2; }
.login-form-wrap { width: min(410px, 100%); }
.mobile-brand { display: none; }
.login-form-wrap h2 { margin: 0 0 8px; font-family: Georgia, "Noto Serif SC", serif; font-size: 34px; font-weight: 400; }
.login-form-wrap > .muted { margin: 0 0 22px; font-size: 14px; }
.login-form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
label em { color: var(--danger); font-style: normal; }
input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 2px; outline: 0; padding: 0 16px; color: var(--ink); background: rgba(255,255,255,.72); transition: .2s ease; }
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(155,119,69,.12); }
.primary-button { min-height: 44px; border: 0; border-radius: 2px; display: inline-flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 20px; color: #fff; background: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; letter-spacing: .04em; cursor: pointer; transition: transform .2s, background .2s; }
.primary-button:hover { background: #34302c; transform: translateY(-1px); }
.primary-button span { font-size: 20px; font-weight: 400; }
.login-form .primary-button { margin-top: 2px; }
.login-note { margin: 20px 0 0; text-align: center; color: #9a948c; font-size: 11px; letter-spacing: .08em; }
.login-note span { color: var(--gold); margin-right: 6px; }

.alert { margin: 0 0 24px; border: 1px solid; padding: 13px 15px; font-size: 13px; }
.alert.error { border-color: #dfb8b3; color: #7c302a; background: #fff3f1; }
.alert.success { border-color: #b9cbbc; color: #2f5a39; background: #f0f8f1; }
.alert.floating { position: fixed; z-index: 20; top: 66px; right: 24px; min-width: 280px; box-shadow: var(--shadow); background-clip: padding-box; }
.alert[data-dismiss-alert] button { float: right; border: 0; background: transparent; font-size: 18px; cursor: pointer; }

.topbar { position: sticky; z-index: 40; top: 0; grid-template-rows: 55px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 clamp(20px, 4vw, 64px); background: rgba(250,248,243,.94); backdrop-filter: blur(14px); }
.main-nav { position: relative; align-self: stretch; display: flex; gap: 24px; }
.main-nav a { position: relative; display: flex; align-items: center; color: var(--muted); text-decoration: none; font-size: 13px; }
.main-nav a.active { color: var(--ink); font-weight: 600; }
.main-nav a.active::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--gold); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 18px; }
.admin-badge { font-size: 12px; color: var(--muted); }
.admin-badge i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #688c6c; box-shadow: 0 0 0 3px rgba(104,140,108,.13); }
.logout-button { border: 0; border-left: 1px solid var(--line); padding: 5px 0 5px 18px; color: var(--muted); background: none; font-size: 12px; cursor: pointer; }

.dashboard { width: min(1240px, calc(100% - 48px)); min-height: calc(100vh - 100px); margin: 0 auto; padding: 26px 0 36px; }
.tab-panel { scroll-margin-top: 68px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h1 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(26px, 3vw, 38px); font-weight: 400; letter-spacing: -.03em; }
.year-guide { align-self: stretch; }
.year-guide-trigger { position: relative; height: 100%; border: 0; display: flex; align-items: center; padding: 0; color: var(--muted); background: transparent; font-size: 13px; font-weight: 400; list-style: none; cursor: pointer; }
.year-guide-trigger::-webkit-details-marker { display: none; }
.year-guide-trigger:hover, .year-guide[open] .year-guide-trigger { color: var(--ink); }
.year-guide[open] .year-guide-trigger { font-weight: 600; }
.year-guide[open] .year-guide-trigger::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--gold); }
.year-guide-trigger:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.year-guide-panel { position: absolute; left: 50%; top: 100%; width: min(560px, calc(100vw - 48px)); border: 1px solid var(--line); background: var(--surface); box-shadow: 0 18px 55px rgba(36,31,25,.2); transform: translateX(-50%); }
.year-guide:not([open]) .year-guide-panel { display: none; }
.year-guide-scroll { max-height: min(60vh, 500px); overflow: auto; padding: 22px; overscroll-behavior: contain; }
.guide-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.guide-heading > div { display: grid; gap: 3px; }
.guide-heading b { font-size: 18px; }
.guide-heading span, .guide-section p, .guide-note, .guide-sources { color: var(--muted); font-size: 11px; line-height: 1.65; }
.guide-search { height: 42px; margin-top: 14px; background: #fff; font-size: 12px; }
.guide-no-results { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.guide-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.guide-section h2 { margin: 0 0 4px; font-size: 14px; }
.guide-section p { margin: 0 0 12px; }
.guide-subtitle { margin: 12px 0 8px; font-size: 11px; font-weight: 600; }
.guide-era-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.guide-era { display: grid; gap: 4px; padding: 10px; background: #f4f0e8; }
.guide-era b { font-size: 11px; }
.guide-era-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
.guide-era-codes span { display: flex; justify-content: space-between; gap: 2px; padding: 3px 5px; background: var(--surface); }
.guide-era-codes strong { font-size: 10px; }
.guide-era-codes small { color: var(--muted); font-size: 9px; }
.guide-code-grid, .guide-metal-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.guide-metal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.guide-code-grid > span, .guide-metal-grid > span { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 7px 8px; background: #f8f5ef; white-space: nowrap; }
.guide-code-grid b { font-size: 11px; }
.guide-code-grid small { color: var(--muted); font-size: 10px; }
.guide-metal-grid b { font-size: 11px; }
.guide-metal-grid small { color: var(--muted); font-size: 10px; }
.guide-era[hidden], .guide-section[hidden], [data-guide-entry][hidden] { display: none; }
.guide-note { display: block; margin-top: 10px; }
.guide-sources { margin: 18px 0 0; }
.guide-sources a { color: var(--gold); text-underline-offset: 2px; }
.upload-panel { max-width: 960px; margin-inline: auto; }
.upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 14px 12px;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(38,32,24,.035);
}
.upload-form > label, .record-edit-form label { min-width: 0; font-size: 14px; }
.source-field { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.source-field[hidden] { display: none; }
.source-field label { min-width: 0; font-size: 14px; }
.source-field input, .source-dialog input { width: 100%; }
.source-dialog { width: min(440px, calc(100% - 32px)); }
.source-dialog form { display: grid; gap: 12px; }
.source-dialog form > button { justify-self: end; }
.upload-photos { grid-column: span 2; min-width: 0; }
.upload-photo-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; line-height: normal; }
.upload-photo-heading label { font-size: 14px; }
.upload-photo-heading span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dropzone {
  position: relative;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  border: 1px dashed #beb5a7;
  color: var(--muted);
  background: #faf8f3;
  text-align: center;
  cursor: pointer;
  transition: .2s;
}
.dropzone:hover, .dropzone.dragging, .dropzone:focus-within { border-color: var(--gold); background: #f7f2e8; }
.dropzone:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { color: var(--ink); font-size: 14px; }
.dropzone small { font-size: 12px; font-weight: 400; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; margin-top: 8px; }
.preview-grid:empty { display: none; }
.preview-item { position: relative; aspect-ratio: var(--thumbnail-ratio); overflow: hidden; background: #eee; }
.preview-item:first-child::after { content: "默认头图"; position: absolute; left: 4px; bottom: 4px; padding: 3px 5px; color: #fff; background: rgba(29,27,25,.8); font-size: 8px; }
.preview-remove { position: absolute; z-index: 1; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(29,27,25,.82); color: #fff; cursor: pointer; font-size: 18px; line-height: 1; }
.preview-remove:hover, .preview-remove:focus-visible { background: #9a493e; }
.form-footer { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.form-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.submit-button { min-width: 144px; margin-inline-start: auto; justify-content: center; }
.submit-button:disabled { cursor: wait; opacity: .72; }

.section-heading.staging-heading { flex-direction: row; align-items: center; }
.staging-heading a { color: var(--forest); font-size: 13px; text-underline-offset: 3px; }
.staging-alert { margin-bottom: 12px; overflow-wrap: anywhere; }
.staging-dropzone { min-height: 84px; }
.staging-dropzone.is-uploading { cursor: progress; }
.staging-status, .staging-errors { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.staging-errors summary { color: var(--danger); cursor: pointer; }
.staging-errors ul { margin: 8px 0 0; padding-inline-start: 22px; overflow-wrap: anywhere; }
.staging-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 10px; }
.staging-summary, .staging-hint { margin: 0; }
.staging-summary { font-size: 14px; font-weight: 600; }
.staging-hint { margin-top: 4px; color: var(--muted); font-size: 12px; }
.staging-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.staging-actions button { white-space: nowrap; }
.staging-empty { margin: 0; color: var(--muted); font-size: 14px; }
.staging-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
.staging-photo {
  min-width: 0;
  border: 1px solid var(--line);
  padding: 0;
  text-align: left;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y pinch-zoom;
}
.staging-photo[aria-pressed="true"] { border-color: var(--forest); box-shadow: 0 0 0 1px var(--forest); }
.staging-photo:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.staging-photo-preview { position: relative; display: block; aspect-ratio: 4 / 5; background: #e9e5dd; }
.staging-photo-preview img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.staging-photo-check { position: absolute; top: 6px; right: 6px; display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: #fff; background: var(--forest); font-size: 14px; visibility: hidden; }
.staging-photo[aria-pressed="true"] .staging-photo-check { visibility: visible; }
.staging-photo-name { display: block; padding: 6px 8px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
#staging-brand-dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100dvh - 32px); }
.staging-brand-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 8px; max-height: 45dvh; overflow: auto; padding: 4px; margin-bottom: 8px; }
.staging-brand-list button { min-width: 0; min-height: 44px; white-space: normal; overflow-wrap: anywhere; }
.staging-brand-form [data-new-brand] { justify-self: start; }
.staging-brand-form [hidden] { display: none; }
.staging-brand-form .primary-button:disabled { opacity: .55; cursor: default; background: var(--ink); transform: none; }

.library-toolbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); }
.library-toolbar[hidden], .library-stats[hidden] { display: none; }
#library { scroll-margin-top: 122px; }
.search-field { position: relative; width: min(360px, 100%); }
.search-field span { position: absolute; left: 15px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 22px; }
.search-field input { padding-left: 43px; border-radius: 30px; background: var(--surface); }
.library-switch { display: inline-flex; gap: 2px; margin-bottom: 12px; padding: 3px; border: 1px solid var(--line); background: var(--surface); }
.library-switch a { display: grid; min-height: 38px; place-items: center; padding: 0 14px; color: var(--muted); text-decoration: none; font-size: 14px; }
.library-switch a:hover { color: var(--ink); }
.library-switch a[aria-current] { color: #fff; background: var(--forest); font-weight: 600; }
.library-stats { display: flex; flex: none; }
.library-stats div { display: flex; align-items: baseline; gap: 8px; padding-right: 16px; margin-right: 16px; border-right: 1px solid var(--line); }
.library-stats div:last-child { border-right: 0; padding-right: 0; margin-right: 0; }
.library-stats b { font-family: Georgia, serif; font-size: 24px; font-weight: 400; }
.library-stats span { color: var(--muted); font-size: 11px; }
.brands { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); align-items: start; gap: 10px; }
.brand-group { min-width: 0; }
.brand-card { display: block; width: 100%; border: 1px solid var(--line); padding: 0; text-align: left; background: var(--surface); cursor: pointer; transition: transform .2s, box-shadow .2s; }
.brand-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.brand-image-wrap { position: relative; display: block; aspect-ratio: var(--thumbnail-ratio); overflow: hidden; background: #e9e5dd; }
.thumbnail-placeholder { display: grid; height: 100%; place-items: center; color: var(--muted); font-size: 12px; }
.brand-image-wrap .thumbnail-placeholder { padding-top: 10px; }
.brand-image-wrap i { position: absolute; right: 7px; top: 7px; padding: 4px 6px; color: #fff; background: rgba(29,27,25,.76); font-size: 9px; font-style: normal; }
.brand-card-label { display: block; padding: 7px 9px; }
.brand-card-label strong { display: block; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.brand-dialog { width: min(680px, calc(100% - 32px)); max-height: calc(100vh - 44px); border: 0; padding: 0; background: var(--surface); box-shadow: 0 35px 90px rgba(0,0,0,.3); }
.brand-dialog::backdrop { background: rgba(20,19,17,.75); backdrop-filter: blur(4px); }
.brand-dialog header > div { min-width: 0; overflow-wrap: anywhere; }
.brand-archives { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; gap: 10px; }
.archive-card { display: block; width: 100%; border: 1px solid var(--line); padding: 0; text-align: left; background: var(--surface); cursor: pointer; }
.archive-card:hover { border-color: var(--gold); }
.archive-thumb { position: relative; display: block; aspect-ratio: var(--thumbnail-ratio); overflow: hidden; background: #e9e5dd; }
.archive-card-info { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; padding: 6px 8px; }
.archive-card-info :is(strong, small) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-card-info small { color: var(--muted); font-size: 12px; }
.archive-card-info strong { font-size: 13px; font-weight: 600; }

.bag-dialog { width: min(1080px, calc(100% - 32px)); max-height: calc(100vh - 44px); border: 0; padding: 0; background: var(--surface); box-shadow: 0 35px 90px rgba(0,0,0,.3); }
.bag-dialog::backdrop { background: rgba(20,19,17,.75); backdrop-filter: blur(4px); }
.dialog-shell { padding: clamp(16px, 2.5vw, 28px); }
.dialog-shell > header { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.bag-dialog .dialog-shell > header { position: sticky; z-index: 2; top: 0; padding-top: 8px; background: var(--surface); }
.dialog-shell h2 { margin: 0 0 5px; font-family: Georgia, "Noto Serif SC", serif; font-size: 26px; font-weight: 400; }
.dialog-shell header span { color: var(--muted); font-size: 12px; }
.dialog-shell header span { overflow-wrap: anywhere; }
.dialog-close { flex-shrink: 0; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 25px; font-weight: 300; cursor: pointer; }
.record-edit-form { display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(0, 1fr)); align-items: start; gap: 12px; margin-bottom: 14px; padding: 12px; background: #f3efe7; }
.record-edit-form label { gap: 7px; }
.record-edit-form :is(input, select) { height: 42px; background: var(--surface); }
.secondary-button { min-height: 42px; border: 1px solid var(--ink); padding: 0 18px; color: #fff; background: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer; transition: .2s; }
.secondary-button:hover { background: var(--gold); border-color: var(--gold); }
.record-edit-form .secondary-button { grid-column: 1 / -1; justify-self: end; }
.move-dialog { width: min(760px, calc(100% - 32px)); }
.move-brand-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.move-brand-heading h3 { margin: 0; font-size: 16px; }
.move-source-switch { margin: 0; }
.move-source-switch button { min-height: 38px; padding: 6px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.move-source-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.move-brand-list { display: flex; flex-wrap: wrap; gap: 8px; }
.move-selection { margin: 12px 0; font-size: 13px; }
.move-targets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.move-target { position: relative; display: grid; align-content: start; gap: 5px; padding: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; overflow-wrap: anywhere; }
.move-target[hidden] { display: none; }
.move-target:has(input:checked), .move-target:focus-within { outline: 2px solid var(--gold); outline-offset: -2px; }
.move-target input { position: absolute; top: 10px; left: 10px; width: 18px; height: 18px; margin: 0; accent-color: var(--gold); }
.move-target strong { font-size: 13px; }
.move-target small { color: var(--muted); font-size: 11px; }
#move-image-form > button { margin-top: 14px; }
.secondary-button:disabled { opacity: .65; cursor: default; }
.dialog-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gallery-image { position: relative; aspect-ratio: var(--thumbnail-ratio); overflow: hidden; background: #eee; }
.preview-item img, .brand-image-wrap img, .archive-thumb img, .gallery-image img {
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  width: auto;
  max-width: none;
  height: 100%;
  transform: translateX(-50%);
}
.bag-image-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.image-type-hint { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.image-type-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.image-type-status { min-height: 1.4em; margin: 0; font-size: 13px; }
.bag-category-status:not(:empty) { display: block; margin-top: 4px; color: var(--forest); }
.image-type-mobile { display: none; }
@media (max-width: 900px), (pointer: coarse) {
  .image-type-mobile { display: inline-block; min-height: 44px; }
  .image-type-hint { display: none; }
}
.gallery-image img { -webkit-touch-callout: none; user-select: none; min-width: 100%; object-fit: contain; cursor: zoom-in; transition: filter .25s; }
.gallery-image img:hover { filter: brightness(.94); }
.gallery-image img:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }
.image-lightbox { width: 100vw; max-width: none; height: 100vh; height: 100dvh; max-height: none; border: 0; padding: 0; overflow: hidden; color: #fff; background: transparent; }
.image-lightbox::backdrop { background: rgba(12,11,10,.92); backdrop-filter: blur(8px); }
.lightbox-shell { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; gap: 12px; width: 100%; height: 100%; padding: max(70px, calc(env(safe-area-inset-top) + 58px)) clamp(18px, 5vw, 70px) max(16px, env(safe-area-inset-bottom)); }
.lightbox-viewport { position: relative; width: 100%; height: 100%; min-height: 0; overflow: hidden; touch-action: none; }
.lightbox-viewport img { position: absolute; top: 50%; left: 50%; display: block; max-width: none; transform: translate(-50%, -50%); user-select: none; }
.lightbox-viewport[data-zoomed] { cursor: grab; }
.lightbox-viewport[data-dragging] { cursor: grabbing; }
.lightbox-viewport[data-grid]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(255,255,255,.7) 1px, transparent 1px) 0 0 / 96px 100% repeat-x,
    linear-gradient(to bottom, rgba(255,255,255,.7) 1px, transparent 1px) 0 0 / 100% 96px repeat-y,
    linear-gradient(to right, rgba(255,255,255,.35) 1px, transparent 1px) 0 0 / 24px 100% repeat-x,
    linear-gradient(to bottom, rgba(255,255,255,.35) 1px, transparent 1px) 0 0 / 100% 24px repeat-y;
  filter: drop-shadow(0 0 1px #000);
}
.lightbox-zoom, .lightbox-rotate { display: flex; gap: 6px; }
.lightbox-zoom button, .lightbox-rotate button { min-width: 44px; min-height: 44px; }
.lightbox-zoom [data-zoom-reset] { min-width: 74px; }
.lightbox-close { position: fixed; z-index: 1; top: max(18px, env(safe-area-inset-top)); right: max(22px, env(safe-area-inset-right)); width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.4); border-radius: 50%; padding: 0; color: #fff; background: rgba(0,0,0,.28); font-size: 30px; font-weight: 200; line-height: 1; cursor: pointer; }
.lightbox-close:hover, .lightbox-close:focus-visible { border-color: #fff; background: rgba(255,255,255,.14); outline: none; }
.lightbox-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.lightbox-actions .secondary-button { border-color: rgba(255,255,255,.6); }
.lightbox-actions button[aria-pressed="true"] { color: var(--ink); background: var(--surface); }
.lightbox-status { flex-basis: 100%; margin: 0; text-align: center; font-size: 13px; }
.lightbox-status:empty { display: none; }
.section-heading.compare-heading { flex-direction: row; align-items: center; }
.compare-count { display: flex; align-items: center; gap: 8px; }
.compare-heading select, .compare-slot select { min-width: 0; min-height: 42px; padding: 0 8px; border: 1px solid var(--line); border-radius: 2px; color: var(--ink); background: var(--surface); font: inherit; }
.compare-status { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.compare-status:empty { display: none; }
.compare-columns { display: grid; grid-template-columns: repeat(var(--compare-count, 2), minmax(min(218px, 48%), 1fr)); gap: 10px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.compare-slot { display: grid; min-width: 0; gap: 10px; padding: 10px; border: 1px solid var(--line); background: var(--surface); }
.compare-slot h2 { margin: 0; font-size: 14px; font-weight: 600; }
.compare-slot select { width: 100%; }
.compare-zoom { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; width: min(100%, 152px); justify-self: center; }
.compare-zoom button { min-width: 0; padding: 0; }
.compare-image { display: grid; place-items: center; min-width: 0; height: clamp(210px, 49dvh, 500px); background: var(--paper); }
.compare-image p { padding: 0 8px; color: var(--muted); font-size: 13px; text-align: center; }
.compare-image button { width: 100%; height: 100%; min-height: 0; overflow: hidden; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.compare-image button[data-zoomed] { touch-action: none; cursor: grab; }
.compare-image button[data-panning] { cursor: grabbing; }
.compare-image img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; pointer-events: none; }
.compare-photos { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 4px; }
.compare-photos[hidden] { display: none; }
.compare-photos button { flex: 0 0 48px; height: 48px; padding: 0; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.compare-photos button[aria-pressed="true"] { border-color: var(--forest); box-shadow: 0 0 0 1px var(--forest); }
.compare-photos img { display: block; width: 100%; height: 100%; object-fit: contain; }
.empty-state, .no-results { border: 1px dashed #c9c0b3; padding: 32px 16px; text-align: center; background: rgba(255,255,255,.3); }
.empty-state > span, .no-results > span { color: var(--gold); font-size: 34px; }
.empty-state h2, .no-results h2 { margin: 13px 0 8px; font-family: Georgia, "Noto Serif SC", serif; font-size: 26px; font-weight: 400; }
.empty-state p, .no-results p { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.empty-state .primary-button { justify-content: center; }
.site-footer { height: 44px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 4vw, 64px); color: #999188; font-size: 9px; letter-spacing: .12em; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 32px 24px; }
  .mobile-brand { display: block; margin-bottom: 28px; font-size: 15px; font-weight: 700; letter-spacing: .18em; }
  .topbar { grid-template-columns: 1fr auto; backdrop-filter: none; }
  .main-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: 52px; gap: 0; justify-content: space-around; border-top: 1px solid var(--line); background: #faf8f3; }
  .main-nav a, .main-nav .year-guide { flex: 1; justify-content: center; white-space: nowrap; }
  .year-guide-trigger { width: 100%; justify-content: center; }
  .year-guide[open] .year-guide-trigger::after { top: -1px; bottom: auto; }
  .year-guide-panel { top: auto; bottom: 100%; left: 14px; right: 14px; width: auto; transform: none; }
  .year-guide-scroll { max-height: min(60vh, calc(100vh - 86px)); }
  .main-nav a.active::after { top: -1px; bottom: auto; }
  .top-actions .admin-badge { display: none; }
  .record-edit-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brands { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .dashboard { padding-bottom: 68px; }
  .site-footer { display: none; }
}

@media (max-width: 760px) {
  .section-heading { align-items: stretch; flex-direction: column; gap: 10px; }
}

@media (max-width: 620px) {
  .topbar { grid-template-rows: 51px; padding: 0 18px; }
  .topbar .wordmark { font-size: 15px; }
  .dashboard { width: min(100% - 28px, 1240px); padding-top: 16px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 14px; }
  .year-guide-scroll { padding: 16px; }
  .guide-era-grid { grid-template-columns: 1fr; }
  .guide-era-codes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .guide-code-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .guide-metal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-form { gap: 12px 8px; padding: 12px; }
  .upload-form input:not([type="file"]), .record-edit-form :is(input, select) { padding-inline: 8px; font-size: 16px; }
  .submit-button { min-width: 0; padding-inline: 12px; }
  .staging-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
  .staging-brand-form input[name="new_brand"] { font-size: 16px; }
  .library-toolbar { flex-direction: column; align-items: stretch; gap: 6px; }
  .library-toolbar .search-field { width: 100%; }
  .library-toolbar input { font-size: 16px; }
  .library-stats div { flex: 1; justify-content: center; gap: 4px; margin: 0; padding: 0 4px; }
  #library { scroll-margin-top: 150px; }
  .library-stats b { font-size: 22px; }
  .brands { gap: 6px; }
  .brand-image-wrap i { top: 3px; right: 3px; padding: 2px 4px; white-space: nowrap; }
  .brand-image-wrap i span { display: none; }
  .brand-card-label { padding: 5px 4px; }
  .brand-card-label strong { font-size: 12px; }
  .brand-archives { gap: 6px; }
  .archive-card-info { padding: 5px 4px; }
  .archive-card-info strong { font-size: 12px; }
  .dialog-gallery { gap: 6px; }
  .move-targets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-shell { padding: 14px; }
  .alert.floating { left: 14px; right: 14px; top: 76px; min-width: 0; }
}
