:root {
  --ink: #171813;
  --muted: #777970;
  --line: #deded6;
  --panel: #fbfaf6;
  --canvas: #f1f0e9;
  --accent: #badc50;
  --accent-deep: #85983e;
  --danger: #b44f49;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; }

.app-shell { min-height: 100vh; overflow: hidden; }
.topbar { height: 76px; position: relative; z-index: 20; border-bottom: 1px solid var(--line); background: rgba(251,250,246,.96); padding: 0 26px; display: grid; grid-template-columns: minmax(190px, 1fr) minmax(280px, 560px) minmax(240px, 1fr); align-items: center; gap: 22px; backdrop-filter: blur(16px); }
.brand { justify-self: start; color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 11px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--ink); color: var(--accent); display: grid; place-items: center; font-weight: 900; letter-spacing: -.06em; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 14px; }
.brand-copy small { color: var(--muted); font-size: 10px; }
.search-box { min-width: 0; height: 42px; border: 1px solid #d6d5cd; border-radius: 11px; background: #fff; padding: 0 12px; display: flex; align-items: center; gap: 9px; box-shadow: 0 5px 18px rgba(43,44,38,.04); }
.search-box > span { color: #777970; font-size: 20px; transform: rotate(-12deg); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 12px; }
.search-box kbd { border: 1px solid #d7d6cf; border-bottom-width: 2px; border-radius: 6px; background: #f2f1eb; padding: 3px 6px; color: #85877e; font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 6px; }
.snapshot-label { color: #92948a; font-size: 9px; white-space: nowrap; }
.quiet-button { min-height: 36px; border: 0; border-radius: 9px; background: transparent; padding: 0 11px; color: #5d5f57; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; font-size: 11px; font-weight: 650; }
.quiet-button:hover { background: #ecebe4; }
.library-drawer-button { display: none; }
.eyebrow { font: 700 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; color: #8a8c83; }

.loading-state { height: calc(100vh - 76px); display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 12px; }
.loader { width: 15px; height: 15px; border: 2px solid #cccac2; border-top-color: var(--ink); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.workspace { height: calc(100vh - 76px); display: grid; grid-template-columns: minmax(235px, 280px) minmax(440px, 1.45fr) minmax(420px, .95fr); }
.library-sidebar, .image-panel, .prompt-panel { min-width: 0; min-height: 0; }
.library-sidebar { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.library-sidebar-header { min-height: 68px; padding: 18px 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.library-sidebar-header > div { display: grid; gap: 5px; }
.library-sidebar-header strong { font-size: 15px; }
.library-sidebar-header > span { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: #e7e6df; color: var(--muted); display: grid; place-items: center; font-size: 10px; }
.record-list { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.sidebar-record-list { flex: 1; padding: 0 8px 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: max-content; align-content: start; gap: 8px; }
.record-card { min-width: 0; border: 1px solid transparent; border-radius: 11px; background: transparent; padding: 5px; position: relative; cursor: pointer; text-align: left; }
.record-card:hover { background: #efeee7; }
.record-card.active { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--ink), 0 6px 18px rgba(42,44,37,.08); }
.record-thumb { width: 100%; aspect-ratio: 1; position: relative; border-radius: 8px; background: #e1e0d8; overflow: hidden; display: block; }
.record-thumb img { width: 100%; height: 100%; object-fit: cover; }
.record-thumb b { position: absolute; top: 6px; right: 6px; min-width: 21px; height: 20px; padding: 0 6px; border-radius: 99px; background: rgba(23,24,19,.72); color: white; display: grid; place-items: center; font-size: 8px; backdrop-filter: blur(8px); }
.series-card-index { position: absolute; top: 6px; left: 6px; min-width: 22px; height: 20px; border-radius: 99px; background: rgba(23,24,19,.72); color: white; display: grid; place-items: center; font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; backdrop-filter: blur(8px); }
.series-card-label { display: block; margin: 7px 2px 2px; overflow: hidden; color: #7f8178; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.library-sidebar-footer { min-height: 42px; border-top: 1px solid var(--line); padding: 0 15px; display: flex; align-items: center; justify-content: space-between; color: #94968d; font-size: 9px; }

.image-panel { padding: 25px 28px 28px; display: flex; flex-direction: column; }
.panel-heading, .prompt-heading { min-height: 34px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-heading > div:first-child, .prompt-heading > div:first-child { display: flex; align-items: center; gap: 14px; }
.result-count { color: var(--muted); font-size: 11px; }
.panel-actions { display: flex; align-items: center; gap: 13px; }
.icon-text-button { border: 0; background: none; padding: 0; color: #565850; cursor: pointer; font-size: 11px; }
.icon-text-button span { margin-left: 4px; }
.version-toolbar { min-height: 50px; margin-bottom: 10px; display: flex; align-items: center; }
.version-switcher { min-width: 0; display: flex; align-items: center; gap: 9px; }
.version-switch-label { color: #8a8c83; font-size: 10px; font-weight: 700; white-space: nowrap; }
.version-tabs { min-width: 0; display: flex; align-items: center; gap: 5px; overflow-x: auto; padding: 3px 1px; scrollbar-width: none; }
.version-tabs::-webkit-scrollbar { display: none; }
.version-tabs button { min-height: 32px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.64); padding: 0 10px; color: #676960; white-space: nowrap; cursor: pointer; font-size: 11px; font-weight: 650; }
.version-tabs button:hover { border-color: #b6b8ae; background: #fff; }
.version-tabs button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.final-dot { width: 15px; height: 15px; margin-left: 6px; border-radius: 50%; background: var(--accent); color: var(--ink); display: inline-grid; place-items: center; font-size: 9px; }

.image-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background-color: #ecebe4; background-image: linear-gradient(45deg,rgba(255,255,255,.34) 25%,transparent 25%),linear-gradient(-45deg,rgba(255,255,255,.34) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,rgba(255,255,255,.34) 75%),linear-gradient(-45deg,transparent 75%,rgba(255,255,255,.34) 75%); background-size: 24px 24px; background-position: 0 0,0 12px,12px -12px,-12px 0; display: grid; place-items: center; touch-action: none; overscroll-behavior: contain; }
.image-stage::before { content: ""; position: absolute; inset: 0; background: rgba(228,227,220,.72); backdrop-filter: blur(1px); }
.image-button { position: absolute; z-index: 1; inset: 0; border: 0; background: transparent; padding: 0; cursor: zoom-in; overflow: hidden; }
.image-button img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 18px 30px rgba(34,35,30,.14)); }
.image-page-dots { min-height: 28px; max-width: calc(100% - 120px); position: absolute; z-index: 3; top: 14px; left: 50%; translate: -50% 0; border: 1px solid rgba(23,24,19,.06); border-radius: 99px; background: rgba(251,250,246,.86); box-shadow: 0 3px 12px rgba(30,31,27,.05); padding: 0 10px; display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.image-page-dots:empty { display: none; }
.image-page-dots button { width: 8px; height: 8px; flex: 0 0 8px; border: 0; border-radius: 50%; background: #c5c6be; padding: 0; cursor: pointer; }
.image-page-dots button:hover { background: #8d8f86; transform: scale(1.18); }
.image-page-dots button.active { background: var(--ink); box-shadow: 0 0 0 3px var(--accent); }
.nav-arrow { position: absolute; z-index: 4; top: 50%; translate: 0 -50%; width: 42px; height: 42px; border: 1px solid rgba(23,24,19,.14); border-radius: 50%; background: rgba(251,250,246,.9); box-shadow: 0 4px 18px rgba(0,0,0,.09); opacity: 0; cursor: pointer; transition: opacity .18s, transform .18s; }
.image-stage:hover .nav-arrow, .nav-arrow:focus-visible { opacity: 1; }
.nav-arrow:hover { transform: scale(1.06); }
.nav-arrow.previous { left: 18px; }
.nav-arrow.next { right: 18px; }
.gesture-hint { position: absolute; z-index: 3; bottom: 13px; left: 14px; border-radius: 99px; background: rgba(251,250,246,.88); color: #676960; padding: 5px 9px; font-size: 9px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.image-position { position: absolute; z-index: 3; right: 14px; bottom: 13px; border-radius: 99px; background: rgba(23,24,19,.75); color: #fff; padding: 5px 9px; font-size: 10px; letter-spacing: .03em; }

.prompt-panel { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.prompt-detail { flex: 1; min-height: 0; padding: 26px 27px 24px; display: flex; flex-direction: column; }
.prompt-heading { align-items: center; }
.version-pill { border: 1px solid #cccdc4; border-radius: 99px; padding: 4px 8px; color: #606259; font-size: 10px; font-weight: 700; }
.final-badge { border-radius: 99px; padding: 4px 8px; background: var(--accent); color: #384015; font-size: 10px; font-weight: 750; }
.copy-icon-button { width: 30px; height: 30px; border: 1px solid #dddcd4; border-radius: 8px; background: #fff; padding: 0; display: grid; place-items: center; cursor: pointer; }
.copy-icon-button:hover { border-color: #b9bbb1; background: #f4f3ed; }
.copy-icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.prompt-reading-area { flex: 1; min-height: 0; margin: 20px 0 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: auto; scrollbar-width: thin; box-shadow: inset 0 1px 0 rgba(255,255,255,.6); }
.prompt-copy { min-height: 100%; margin: 0; padding: 19px 20px 24px; color: var(--ink); font-family: inherit; font-size: 16px; line-height: 1.78; letter-spacing: -.01em; white-space: pre-wrap; overflow-wrap: anywhere; }
.reference-preview-section { margin: 0 0 14px; }
.reference-preview-heading { margin-bottom: 7px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reference-preview-heading span { color: #7a806d; font-size: 8px; font-weight: 750; letter-spacing: .1em; }
.reference-preview-heading small { color: #94988d; font-size: 9px; }
.reference-preview-list { min-height: 76px; display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 4px; scrollbar-width: thin; }
.reference-preview-item { position: relative; flex: 0 0 72px; width: 72px; height: 72px; }
.reference-preview-image { position: relative; width: 100%; height: 100%; overflow: hidden; border: 1px solid #d8ddd0; border-radius: 9px; background: #dedfd8; padding: 3px; cursor: zoom-in; }
.reference-preview-image img { width: 100%; height: 100%; border-radius: 6px; object-fit: cover; }
.reference-preview-image span { position: absolute; left: 6px; bottom: 6px; min-width: 17px; height: 17px; border-radius: 99px; background: rgba(23,24,19,.76); color: #fff; display: grid; place-items: center; font-size: 8px; }
.reference-empty { flex: 1; min-height: 72px; border: 1px dashed #d7d8d0; border-radius: 9px; color: #9a9c93; display: grid; place-items: center; font-size: 9px; }
.version-note { margin: 0 0 14px; border-left: 3px solid var(--accent-deep); border-radius: 0 8px 8px 0; background: #f0f2e8; padding: 10px 12px; }
.version-note > span { display: block; margin-bottom: 4px; color: #74776a; font-size: 9px; font-weight: 750; letter-spacing: .1em; }
.version-note p { margin: 0; color: #4b4e44; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
.prompt-meta { margin: 0 1px; display: flex; align-items: center; justify-content: space-between; color: #96988f; font-size: 9px; }

.search-empty { height: calc(100vh - 76px); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #92948a; }
.search-empty > span { font-size: 36px; transform: rotate(-12deg); }
.search-empty strong { margin-top: 12px; color: #696b63; font-size: 14px; }
.search-empty button { margin-top: 10px; border: 0; background: none; color: #596628; font-size: 11px; font-weight: 700; cursor: pointer; }

.mobile-bar, .mobile-library, .drawer-backdrop { display: none; }
.drawer-backdrop { position: fixed; z-index: 44; inset: 0; background: rgba(17,18,15,.38); }
.mobile-library { position: fixed; z-index: 45; inset: 0 auto 0 0; width: min(390px,92vw); background: var(--panel); box-shadow: 20px 0 70px rgba(0,0,0,.2); flex-direction: column; }
.mobile-library-header { min-height: 68px; padding: 0 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.mobile-library-header > div { display: flex; align-items: baseline; gap: 10px; }
.mobile-library-header span { color: var(--muted); font-size: 11px; }
.mobile-library-header button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #ecebe4; cursor: pointer; font-size: 22px; }
.mobile-library-list { padding: 10px; overflow-y: auto; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; gap: 10px; }

.lightbox, .reference-lightbox { position: fixed; z-index: 80; inset: 0; background: rgba(12,13,11,.96); padding: 62px 70px 82px; display: grid; place-items: center; overflow: auto; touch-action: pan-y; }
.lightbox-close { position: fixed; z-index: 5; top: 18px; right: 20px; width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; background: rgba(24,25,22,.78); color: #fff; cursor: pointer; font-size: 24px; }
.lightbox-version-tabs { position: fixed; z-index: 4; top: 18px; left: 50%; max-width: calc(100vw - 150px); translate: -50% 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.lightbox-version-tabs button { flex: none; min-height: 36px; border: 1px solid rgba(255,255,255,.18); border-radius: 99px; background: rgba(24,25,22,.72); color: rgba(255,255,255,.72); padding: 0 12px; cursor: pointer; font-size: 10px; }
.lightbox-version-tabs button.active { border-color: var(--accent); background: var(--accent); color: var(--ink); }
.lightbox-image-canvas { width: 100%; min-height: calc(100vh - 144px); display: grid; place-items: center; }
.lightbox-image-canvas img { display: block; width: auto; max-width: 100%; height: auto; max-height: none; object-fit: contain; }
.lightbox-nav { position: fixed; z-index: 3; top: 50%; translate: 0 -50%; width: 50px; height: 50px; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; font-size: 18px; }
.lightbox-nav:hover { background: rgba(255,255,255,.2); transform: scale(1.05); }
.lightbox-nav.previous { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-caption { position: fixed; z-index: 3; left: 24px; right: 24px; bottom: 16px; display: flex; justify-content: center; align-items: center; gap: 18px; color: rgba(255,255,255,.7); font-size: 11px; pointer-events: none; }
.lightbox-caption > * { pointer-events: auto; }
.lightbox-caption button { border: 0; border-radius: 99px; background: var(--accent); color: var(--ink); padding: 8px 12px; cursor: pointer; font-size: 11px; font-weight: 700; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; translate: -50% 0; border-radius: 99px; background: var(--ink); color: #fff; padding: 11px 17px; box-shadow: 0 10px 35px rgba(0,0,0,.2); font-size: 12px; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1400px) {
  .topbar { grid-template-columns: minmax(170px,1fr) minmax(240px,560px) max-content; gap: 14px; padding-inline: 20px; }
  .snapshot-label { display: none; }
  .top-actions .library-drawer-button { display: inline-flex; }
  .library-sidebar { display: none; }
  .workspace { grid-template-columns: minmax(0,1.35fr) minmax(360px,.85fr); }
  .panel-actions .library-drawer-button { display: inline-block; }
  .drawer-backdrop:not([hidden]) { display: block; }
  .mobile-library:not([hidden]) { display: flex; animation: drawer-in .2s ease-out; }
  @keyframes drawer-in { from { transform: translateX(-20px); opacity: 0; } }
  .mobile-library-list .record-card { display: block; }
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto minmax(180px,1fr) auto; padding: 0 16px; gap: 12px; }
  .brand-copy { display: none; }
  .top-actions > a { display: none; }
  .workspace { grid-template-columns: 1.15fr .85fr; }
  .image-panel { padding: 20px; }
  .prompt-detail { padding: 22px 20px; }
  .prompt-heading > div:first-child { display: grid; grid-template-columns: auto auto; gap: 5px; }
  .prompt-heading .eyebrow { grid-column: 1/-1; }
  .version-toolbar { align-items: flex-start; }
  .version-switcher { width: 100%; align-items: flex-start; flex-direction: column; gap: 6px; }
  .version-tabs { width: 100%; }
}

@media (max-width: 680px) {
  .app-shell { overflow: auto; padding-bottom: 66px; }
  .topbar { height: 66px; position: sticky; top: 0; grid-template-columns: auto 1fr auto; gap: 9px; padding: 0 11px; }
  .brand-mark { width: 34px; height: 34px; }
  .search-box { min-width: 0; height: 40px; padding-inline: 12px; }
  .search-box kbd { display: none; }
  .top-actions .library-drawer-button { width: 40px; height: 40px; padding: 0; border-radius: 50%; background: var(--ink); color: #fff; justify-content: center; font-size: 0; }
  .top-actions .library-drawer-button::after { content: "系列"; font-size: 9px; }
  .workspace { height: auto; min-height: calc(100vh - 132px); display: flex; flex-direction: column; }
  .image-panel { height: 62vh; min-height: 470px; padding: 16px 12px 12px; }
  .panel-heading { padding-inline: 3px; align-items: center; }
  .panel-heading .eyebrow { font-size: 8px; }
  .result-count { font-size: 9px; }
  .panel-actions .library-drawer-button { display: none; }
  .version-toolbar { margin: 7px 1px 10px; }
  .nav-arrow { opacity: 1; width: 36px; height: 36px; }
  .gesture-hint { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .prompt-panel { overflow: visible; border-top: 1px solid var(--line); border-left: 0; }
  .prompt-detail { min-height: 520px; }
  .prompt-reading-area { min-height: 350px; }
  .mobile-bar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: 66px; padding: 9px 6px; border-top: 1px solid var(--line); background: rgba(251,250,246,.94); backdrop-filter: blur(15px); display: grid; grid-template-columns: 1.15fr .72fr .72fr 1fr 1fr; gap: 4px; }
  .mobile-bar button { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; font-weight: 650; }
  .mobile-bar button:last-child { border-color: var(--ink); background: var(--ink); color: #fff; }
  .mobile-library { inset: 0; width: auto; }
  .mobile-library-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .lightbox, .reference-lightbox { padding: 60px 12px 92px; }
  .lightbox-image-canvas { min-height: calc(100vh - 152px); }
  .lightbox-nav { top: auto; bottom: 76px; width: 44px; height: 44px; translate: none; background: rgba(20,21,18,.65); }
  .lightbox-nav.previous { left: 14px; }
  .lightbox-nav.next { right: 14px; }
  .lightbox-version-tabs { left: 12px; right: 64px; max-width: none; translate: none; }
  .lightbox-caption { left: 68px; right: 68px; bottom: 24px; }
  .lightbox-caption span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

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