/* 纸上画廊 — quiet, editorial presentation space */
:root {
  --chalk-0: oklch(0.978 0.004 115);
  --chalk-1: oklch(0.951 0.007 115);
  --chalk-2: oklch(0.917 0.009 115);
  --ink-0: oklch(0.255 0.015 150);
  --ink-1: oklch(0.43 0.014 150);
  --ink-2: oklch(0.52 0.012 150);
  --sage: oklch(0.48 0.065 145);
  --sage-soft: oklch(0.91 0.025 145);
  --line: oklch(0.875 0.009 120);
  --overlay: oklch(0.18 0.015 150 / 0.48);
  --surface: var(--chalk-0);
  --surface-subtle: var(--chalk-1);
  --text: var(--ink-0);
  --text-muted: var(--ink-1);
  --accent: var(--sage);
  --border: var(--line);
  --font-body: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "Iowan Old Style", "Baskerville", "Songti SC", "STSong", "SimSun", serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { min-height: 100dvh; scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  background: var(--surface);
  color: var(--text);
  font: 16px/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
::selection { color: var(--text); background: var(--sage-soft); }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  background: var(--text);
  color: var(--surface);
  transform: translateY(-150%);
  transition: transform 180ms ease-out;
}
.skip-link:focus { transform: translateY(0); }

.site-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.site-header {
  min-height: 84px;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand__mark { width: 36px; height: 36px; flex: 0 0 auto; }
.brand__type { display: flex; flex-direction: column; gap: 1px; }
.brand__name { font-family: var(--font-display); font-size: 20px; line-height: 1.25; letter-spacing: .08em; }
.brand__sub { color: var(--text-muted); font-size: 9px; line-height: 1.4; letter-spacing: .2em; }
.header-actions, .viewer__actions { display: flex; align-items: center; gap: 8px; }
.header-divider { width: 1px; height: 20px; margin: 0 8px; background: var(--border); }
.header-button {
  min-height: 44px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  transition: color 160ms ease-out, border-color 160ms ease-out, background-color 160ms ease-out;
}
.header-button:hover { color: var(--text); border-color: var(--border); background: var(--surface-subtle); }
.header-button:active { transform: translateY(1px); }
.header-button svg { width: 17px; height: 17px; }
.collections-trigger { display: none; }
.lang-switch { display: flex; align-items: center; gap: 4px; color: var(--text-muted); font-size: 12px; }
.lang-switch button { min-width: 44px; min-height: 44px; padding: 8px; color: var(--text-muted); transition: color 150ms ease-out; }
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { color: var(--text); font-weight: 600; }

.workspace { --sidebar-width: 280px; position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
  min-width: 0;
  min-height: 100%;
  padding: 12px 20px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--surface-subtle);
}
.sidebar__toolbar { min-height: 44px; margin-bottom: 8px; display: flex; align-items: center; justify-content: flex-end; }
.sidebar-resizer { position: absolute; z-index: 3; top: 0; bottom: 0; left: calc(var(--sidebar-width) - 6px); width: 12px; cursor: col-resize; touch-action: none; }
.sidebar-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px; background: transparent; transition: background-color 150ms ease-out; }
.sidebar-resizer:hover::after, .sidebar-resizer.is-dragging::after, .sidebar-resizer:focus-visible::after { background: var(--accent); }
.sidebar-resizer:focus-visible { outline: none; }
.is-resizing { cursor: col-resize; user-select: none; }
.icon-button.sidebar-open { display: none; }
.sidebar-collapsed .workspace { grid-template-columns: minmax(0, 1fr); }
.sidebar-collapsed .sidebar, .sidebar-collapsed .sidebar-resizer { display: none; }
.overline { color: var(--accent); font-size: 10px; font-weight: 600; line-height: 1.5; letter-spacing: .18em; text-transform: uppercase; }
.deck-list { list-style: none; }
.deck-list li + li { margin-top: 4px; }
.deck-link {
  min-height: 92px;
  padding: 12px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  text-decoration: none;
  transition: border-color 180ms ease-out, background-color 180ms ease-out, transform 180ms ease-out;
}
.deck-link:hover { border-color: var(--border); background: var(--surface); }
.deck-link:active { transform: scale(.99); }
.deck-link[aria-current="page"] { border-color: var(--border); background: var(--surface); }
.deck-link__image { width: 64px; height: 64px; object-fit: cover; background: var(--chalk-2); filter: saturate(.82); }
.deck-link[aria-current="page"] .deck-link__image { filter: none; }
.deck-link__body { min-width: 0; display: block; }
.deck-link__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-muted); font-size: 10px; letter-spacing: .08em; }
.deck-link__active { color: var(--accent); opacity: 0; }
.deck-link[aria-current="page"] .deck-link__active { opacity: 1; }
.deck-link__title { display: block; margin-top: 5px; overflow: hidden; font-family: var(--font-display); font-size: 16px; font-weight: 500; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.deck-link__count { display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; }
.sidebar__foot { margin-top: auto; padding: 32px 12px 0; display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 11px; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

.viewer { min-width: 0; outline: none; }
.viewer-content { width: 100%; max-width: none; margin: 0; padding: 20px 40px 24px; }
.viewer__header { min-height: 44px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.deck-heading { min-width: 0; display: flex; align-items: center; gap: 12px; }
.deck-heading .sidebar-open { flex: 0 0 auto; }
.deck-heading h1 { min-width: 0; font-family: var(--font-display); font-size: clamp(25px, 2.2vw, 32px); font-weight: 400; line-height: 1.25; letter-spacing: -.02em; text-wrap: balance; }
.viewer__actions { flex: 0 0 auto; }
.fullscreen-exit-icon { display: none; }
.viewer:fullscreen .fullscreen-enter-icon { display: none; }
.viewer:fullscreen .fullscreen-exit-icon { display: block; }

.slide { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 40px; align-items: stretch; }
.artboard {
  position: relative;
  min-width: 0;
  height: max(420px, calc(100dvh - 281px));
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  touch-action: pan-y;
}
.artboard__mat { width: 100%; height: 100%; padding: 32px 40px; display: flex; align-items: center; justify-content: center; }
.artboard__mat img { width: 100%; height: 100%; object-fit: contain; opacity: 1; transform: scale(1); transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out); }
.artboard__mat img.is-switching { opacity: .18; transform: scale(.985); }
.artboard__arrow {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 18px oklch(0.25 0.015 150 / .06);
  transform: translateY(-50%);
  transition: color 150ms ease-out, background-color 150ms ease-out, opacity 150ms ease-out, transform 150ms ease-out;
}
.artboard__arrow:hover { background: var(--text); color: var(--surface); }
.artboard__arrow:active { transform: translateY(-50%) scale(.96); }
.artboard__arrow:disabled { opacity: 0; pointer-events: none; }
.artboard__arrow--prev { left: 14px; }
.artboard__arrow--next { right: 14px; }
.image-error { color: var(--text-muted); text-align: center; }
.image-error svg { width: 32px; height: 32px; margin: 0 auto 12px; }
.image-error p { font-size: 13px; }
.caption { min-width: 0; padding: 22px 0 4px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; border-top: 1px solid var(--text); }
.caption__position { margin-bottom: 22px; color: var(--accent); font-family: var(--font-display); font-size: 13px; letter-spacing: .16em; }
.caption h2 { font-family: var(--font-display); font-size: clamp(27px, 2.8vw, 38px); font-weight: 400; line-height: 1.25; letter-spacing: -.015em; text-wrap: balance; }
.caption__artist { margin-top: 16px; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.caption__description { max-width: 68ch; color: var(--text-muted); font-size: 15px; line-height: 1.85; }
.source-link { width: fit-content; min-height: 44px; margin-top: 18px; display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 12px; text-decoration: none; }
.source-link svg { width: 15px; height: 15px; transition: transform 150ms ease-out; }
.source-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.source-link:hover svg { transform: translate(2px, -2px); }

.viewer__footer { margin-top: 24px; }
.progress-track { width: 100%; height: 1px; overflow: hidden; background: var(--border); }
.progress-track span { display: block; width: 25%; height: 100%; background: var(--accent); transform-origin: left; transition: width 220ms var(--ease-out); }
.viewer__footer-row { min-height: 64px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.slide-dots { display: flex; align-items: center; gap: 2px; }
.slide-dot { min-width: 44px; min-height: 44px; padding: 8px; color: var(--text-muted); font-family: var(--font-display); font-size: 12px; transition: color 150ms ease-out, background-color 150ms ease-out; }
.slide-dot:hover { color: var(--text); background: var(--surface-subtle); }
.slide-dot[aria-current="page"] { color: var(--accent); text-decoration: underline; text-underline-offset: 6px; }
.keyboard-hint { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 11px; }
.keyboard-hint svg { width: 18px; height: 18px; }
.footer-navigation { justify-self: end; display: flex; align-items: center; gap: 4px; }
.text-button { min-height: 44px; padding: 8px 10px; display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 12px; transition: color 150ms ease-out; }
.text-button:hover { color: var(--text); }
.text-button:disabled { opacity: .3; cursor: default; }
.text-button svg { width: 15px; height: 15px; }

.loading-state, .error-state { min-height: 60vh; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.loading-state { gap: 20px; color: var(--text-muted); font-size: 13px; }
.loading-mark { width: 34px; height: 34px; border: 1px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: loading-turn 800ms linear infinite; }
@keyframes loading-turn { to { transform: rotate(360deg); } }
.error-state h1 { margin-top: 12px; font-family: var(--font-display); font-size: 34px; font-weight: 400; }
.error-state > p:not(.overline) { max-width: 52ch; margin-top: 12px; color: var(--text-muted); }
.primary-button { min-height: 46px; margin-top: 24px; padding: 10px 20px; background: var(--text); color: var(--surface); transition: opacity 150ms ease-out; }
.primary-button:hover { opacity: .82; }

/* Dialogs */
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
dialog::backdrop { background: var(--overlay); }
dialog[open] { animation: dialog-enter 220ms var(--ease-out); }
@keyframes dialog-enter { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--text-muted); transition: color 150ms ease-out, background-color 150ms ease-out; }
.icon-button:hover { color: var(--text); background: var(--surface-subtle); }
.deck-drawer { width: min(88vw, 380px); max-width: none; height: 100dvh; max-height: none; margin: 0 0 0 auto; padding: 24px 16px; overflow-y: auto; }
.deck-drawer__header { padding: 0 8px 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.deck-drawer__header h2 { margin-top: 6px; font-family: var(--font-display); font-size: 28px; font-weight: 400; }
.deck-drawer nav { margin-top: 16px; }
.deck-drawer__foot { margin: 28px 12px 0; color: var(--text-muted); font-size: 11px; }
.overview-dialog { width: min(calc(100% - 48px), 980px); max-width: 980px; max-height: min(88dvh, 800px); padding: 32px; overflow-y: auto; }
.overview-dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.overview-dialog__header h2 { margin-top: 6px; font-family: var(--font-display); font-size: 34px; font-weight: 400; }
.overview-dialog__header p:last-child { margin-top: 5px; color: var(--text-muted); font-size: 13px; }
.overview-grid { margin-top: 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.overview-item { min-height: 150px; padding: 12px; display: grid; grid-template-columns: 152px minmax(0, 1fr); align-items: center; gap: 16px; border: 1px solid var(--border); text-align: left; transition: border-color 150ms ease-out, background-color 150ms ease-out; }
.overview-item:hover { border-color: var(--accent); background: var(--surface-subtle); }
.overview-item img { width: 152px; height: 112px; object-fit: contain; background: var(--surface-subtle); }
.overview-item__number { color: var(--accent); font-family: var(--font-display); font-size: 11px; }
.overview-item__title { display: block; margin-top: 8px; font-family: var(--font-display); font-size: 18px; line-height: 1.35; }
.overview-item__artist { display: block; margin-top: 8px; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.overview-dialog__hint { margin-top: 24px; color: var(--text-muted); font-size: 12px; text-align: center; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); padding: 12px 18px; background: var(--text); color: var(--surface); font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity 180ms ease-out, transform 180ms ease-out; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.noscript { position: fixed; inset: auto 16px 16px; padding: 16px; background: var(--text); color: var(--surface); text-align: center; }

.viewer:fullscreen { width: 100vw; min-height: 100dvh; overflow-y: auto; background: var(--surface); }
.viewer:fullscreen .viewer-content { max-width: none; padding-top: 24px; }
.viewer:fullscreen .artboard { height: max(420px, calc(100dvh - 201px)); }

@media (min-width: 901px) {
  .sidebar-collapsed .icon-button.sidebar-open { display: grid; }
}

@media (max-width: 1180px) {
  .sidebar { padding-inline: 12px; }
  .viewer-content { padding-inline: 28px; }
  .slide { grid-template-columns: minmax(0, 1fr) 270px; gap: 28px; }
  .artboard__mat { padding: 28px; }
  .viewer__footer-row { grid-template-columns: 1fr 1fr; }
  .keyboard-hint { display: none; }
}

@media (max-width: 900px) {
  .collections-trigger { display: inline-flex; }
  .workspace { display: block; }
  .sidebar, .sidebar-resizer, .icon-button.sidebar-open { display: none; }
  .viewer-content { padding-inline: 32px; }
  .slide { grid-template-columns: minmax(0, 1fr) 290px; gap: 32px; }
  .site-header { padding-inline: 24px; }
}

@media (max-width: 720px) {
  .site-header { min-height: 72px; padding: 12px 16px; gap: 12px; }
  .brand { gap: 8px; }
  .brand__mark { width: 30px; height: 30px; }
  .brand__name { font-size: 17px; }
  .header-actions { gap: 2px; }
  .header-divider { margin-inline: 2px; }
  .collections-trigger span { display: none; }
  .collections-trigger { width: 44px; padding: 8px; }
  .lang-switch button { min-width: 40px; }
  .viewer-content { padding: 20px 16px 20px; }
  .viewer__header { margin-bottom: 16px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .deck-heading h1 { font-size: 27px; }
  .viewer__actions { width: 100%; justify-content: flex-end; }
  .slide { display: flex; flex-direction: column; gap: 24px; }
  .artboard { height: clamp(300px, 78vw, 500px); }
  .artboard__mat { padding: 24px; }
  .artboard__arrow--prev { left: 10px; }
  .artboard__arrow--next { right: 10px; }
  .caption { padding-top: 18px; gap: 24px; }
  .caption__position { margin-bottom: 14px; }
  .caption h2 { font-size: 30px; }
  .caption__description { font-size: 16px; line-height: 1.75; }
  .viewer__footer { margin-top: 20px; }
  .viewer__footer-row { grid-template-columns: 1fr auto; gap: 8px; }
  .footer-navigation { gap: 0; }
  .text-button { padding-inline: 8px; }
  .text-button span { display: none; }
  .text-button svg { width: 20px; height: 20px; }
  .overview-dialog { width: calc(100% - 24px); max-height: 92dvh; padding: 20px; }
  .overview-grid { grid-template-columns: 1fr; gap: 12px; }
  .overview-item { grid-template-columns: 116px minmax(0, 1fr); min-height: 128px; gap: 12px; }
  .overview-item img { width: 116px; height: 96px; }
  .toast { right: 16px; bottom: 16px; }
  .viewer:fullscreen .viewer-content { padding: 16px; }
  .viewer:fullscreen .artboard { height: 60dvh; }
}

@media (max-width: 380px) {
  .header-button { padding-inline: 8px; }
  .slide-dot { min-width: 40px; }
  .overview-item { grid-template-columns: 96px minmax(0, 1fr); }
  .overview-item img { width: 96px; height: 88px; }
}

/* Keep every actionable target comfortable on touch screens. */
.brand, .text-button, .slide-dot { min-width: 44px; min-height: 44px; }

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