:root {
  --bg: #f4f4f2; --panel: #ffffff; --ink: #111111; --muted: #6b6b66; --line: #dcdcd6;
  --accent: #111111; --accent-ink: #ffffff; --danger: #c0392b; --ok: #1e8a4c; --warn: #b8730a;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c0c0c; --panel: #171717; --ink: #f2f2ee; --muted: #9a9a94; --line: #2c2c2a; --accent: #f2f2ee; --accent-ink: #111111; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "DM Sans", system-ui, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1 { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; font-size: 44px; line-height: 1; margin: 0 0 6px; }
h2 { font-size: 13px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 34px 0 12px; }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 28px 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 22px; }
.brand { font-family: "Instrument Serif", Georgia, serif; font-size: 28px; display: flex; align-items: center; gap: 12px; }
.brand img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a, nav .soon { padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit; }
nav a:hover { background: var(--panel); }
nav a.on { background: var(--panel); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line); }
nav .soon { color: var(--muted); }
nav .soon em { font-size: 11px; font-style: normal; border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; margin-left: 4px; }
.side-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.side-note { font-size: 12.5px; color: var(--muted); margin: 0; }
.main { padding: 36px 44px 120px; }
.main.editor > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.main.editor > .savebar { max-width: none; margin: 0; }
.btn { font: inherit; font-weight: 500; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 9px 16px; text-decoration: none; display: inline-block; text-align: center; }
.btn:hover { opacity: 0.88; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13.5px; border-radius: 8px; }
.btn.block { display: block; width: 100%; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.lead { color: var(--muted); margin: 0 0 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.card .thumb { background: var(--bg); }
.card .thumb img { width: 100%; height: auto; display: block; }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .name { font-family: "Instrument Serif", Georgia, serif; font-size: 24px; line-height: 1.05; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .row { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge { font-size: 11.5px; border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; color: var(--muted); }
.badge.hot { color: var(--ok); border-color: var(--ok); }
.badge.off { color: var(--warn); border-color: var(--warn); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; margin-bottom: 18px; }
.panel > h3 { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
.panel > .hint { margin: 0 0 14px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-title { display: block; font-weight: 500; margin-bottom: 5px; }
input[type=text], textarea, select { width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--bg); color: inherit; border-radius: 99px; padding: 5px 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips input { width: 220px; border-radius: 99px; padding: 5px 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
.check input { margin-top: 4px; }
.image-field { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.image-field:first-of-type { border-top: 0; }
.image-field .pic { width: 180px; height: 130px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--line); overflow: hidden; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.image-field .pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.image-field .info { flex: 1; min-width: 0; }
.image-field .path { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.image-field .alt { margin-top: 6px; }
.image-field .acts { display: flex; gap: 6px; margin-top: 6px; }
.block-item { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; background: var(--bg); }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.block-head strong { font-weight: 500; }
.block-head .acts { display: flex; gap: 5px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tools { display: flex; gap: 6px; margin-bottom: 6px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.savebar { position: fixed; left: 240px; right: 0; bottom: 0; padding: 14px 44px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; z-index: 5; }
.savebar .spacer { flex: 1; }
.note { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--warn); color: var(--warn); margin-bottom: 16px; }
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order-list li { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.order-list img { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; }
.order-list .n { color: var(--muted); width: 18px; }
.order-list .t { flex: 1; }
.toast { position: fixed; right: 24px; top: 20px; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; max-width: 420px; opacity: 0; transform: translateY(-8px); transition: 0.25s; pointer-events: none; z-index: 30; white-space: pre-wrap; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 20; display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.dialog { background: var(--panel); border-radius: 18px; width: min(980px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.dialog.narrow { width: min(560px, 100%); }
.dialog header { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.dialog header h3 { margin: 0; flex: 1; font-size: 17px; font-weight: 500; }
.dialog .content { padding: 18px 22px; overflow: auto; }
.dialog footer { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.picker-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.picker-bar input, .picker-bar select { width: auto; flex: 1; min-width: 160px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pick { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 6px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.pick:hover { outline: 2px solid var(--accent); }
.pick img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px; display: block; background: var(--panel); }
.pick span { display: block; font-size: 12px; margin-top: 5px; word-break: break-all; }
.pick small { color: var(--muted); font-size: 11.5px; }
pre.log { background: var(--bg); border-radius: 10px; padding: 14px; font-size: 12.5px; white-space: pre-wrap; margin: 0; }
.lib-section { margin-bottom: 26px; }
.lib-section h3 { font-size: 15px; font-weight: 500; margin: 0 0 10px; }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .savebar { left: 0; padding: 12px 18px; }
  .main { padding: 24px 18px 120px; }
  .pair { grid-template-columns: 1fr; }
}
.info-wrap { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.info-pic { background: var(--bg); border-radius: 12px; padding: 10px; }
.info-pic img { width: 100%; max-height: 62vh; object-fit: contain; display: block; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 12px 6px 0; width: 38%; vertical-align: top; }
.info-table td { padding: 6px 0; word-break: break-all; }
.used { margin: 6px 0 0; padding-left: 18px; }
@media (max-width: 860px) { .info-wrap { grid-template-columns: 1fr; } }
.used a { color: inherit; }
.card .thumb.light { background: #f2f2ee; padding: 14px; }
.card .thumb.light img { max-height: 160px; object-fit: contain; }
.order-list img.light { background: #f2f2ee; object-fit: contain; }
.date-row { display: flex; gap: 8px; }

.paper { background: #000; color: #fff; border: 1px solid var(--line); border-radius: 18px; margin-bottom: 18px; font-size: 20px; }
.paper-bar { position: sticky; top: 0; z-index: 4; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 14px; background: #141414; border-radius: 18px 18px 0 0; border-bottom: 1px solid #2a2a2a; font-size: 15px; }
.paper-bar .btn.ghost { color: #fff; border-color: #333; }
.paper-bar .sep { width: 1px; height: 22px; background: #333; margin: 0 4px; }
.paper-bar .count { margin-left: auto; color: #8a8a85; font-size: 13px; }
.paper-col { max-width: 700px; margin: 0 auto; padding: 40px 28px 90px; }
.paper-tags { list-style: none; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; padding: 0; font-size: 12.5px; font-weight: 300; }
.paper-tags li { display: flex; align-items: center; gap: 7px; }
.paper-tags li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: #fff; flex: none; }
.paper-tags input { width: auto; background: transparent; border: 0; border-bottom: 1px dotted #555; border-radius: 0; color: #fff; padding: 2px 0; font-size: 12.5px; font-weight: 300; }
.paper-tags input:focus { outline: none; border-bottom-color: #fff; }
.link-btn { font: inherit; background: none; border: 0; color: #8a8a85; text-decoration: underline; cursor: pointer; padding: 0; }
.read-toggle { font: inherit; background: none; border: 0; color: #fff; cursor: pointer; padding: 0; }
.read-toggle.off { color: #666; text-decoration: line-through; }
.paper hr { border: 0; border-top: 1px solid #fff; margin: 0 -28px 18px; }
.paper-title, .paper-sub { display: block; width: 100%; background: transparent; border: 0; color: #fff; resize: none; overflow: hidden; padding: 0; border-radius: 0; }
.paper-title:focus, .paper-sub:focus { outline: none; background: rgba(255, 255, 255, 0.04); }
.paper-title { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; font-size: 58px; line-height: 1; letter-spacing: -0.01em; padding-bottom: 6px; }
.paper-sub { font-family: "DM Sans", system-ui, sans-serif; font-weight: 600; font-style: italic; font-size: 1.25em; line-height: 1.3; margin-bottom: 70px; }
.article-edit { font-family: "DM Sans", system-ui, sans-serif; font-weight: 200; line-height: 1.6; outline: none; min-height: 320px; caret-color: #fff; }
.article-edit p, .article-edit ul, .article-edit h2, .article-edit figure { margin: 0; }
.article-edit p + p, .article-edit p + figure, .article-edit figure + p { margin-top: 1.2em; }
.article-edit h2 { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; font-size: 1.9em; line-height: 1.1; letter-spacing: -0.01em; margin-top: 1.6em; margin-bottom: 0.5em; }
.article-edit ul { list-style: disc; padding-left: 1.3em; margin-top: 1.2em; margin-bottom: 1.2em; }
.article-edit li + li { margin-top: 0.6em; }
.article-edit strong, .article-edit b { font-weight: 600; }
.article-edit em, .article-edit i { font-style: italic; }
.article-edit a { color: inherit; text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.article-edit figure { margin-top: 2em; margin-bottom: 2em; position: relative; }
.article-edit figure img { display: block; width: 100%; height: auto; }
.article-edit figcaption { font-size: 0.72em; font-weight: 300; font-style: italic; line-height: 1.4; opacity: 0.75; text-align: right; margin-top: 0.8em; outline: none; min-height: 1.4em; }
.article-edit figcaption:empty::before { content: attr(data-ph); opacity: 0.5; }
.fig-tools { display: flex; gap: 6px; align-items: center; margin-top: 10px; font-size: 14px; flex-wrap: wrap; }
.fig-tools .alt-input { flex: 1; min-width: 200px; background: #111; border: 1px solid #333; color: #fff; padding: 6px 10px; font-size: 13px; font-weight: 400; }
.fig-tools .btn.ghost { color: #fff; border-color: #333; }

.string-list { display: grid; gap: 8px; justify-items: start; }
.string-row { display: flex; gap: 6px; align-items: center; width: 100%; }
.string-row input { flex: 1; }
.mini-pic { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.mini-edit { min-height: 44px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; }
.mini-edit:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.mini-edit a { color: inherit; text-decoration: underline; }
.cv-col-edit { margin-bottom: 18px; }
.cv-entry-edit { border-top: 1px solid var(--line); padding: 12px 0 4px; }

.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 14px; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); color: var(--ink); }
.upload-list { display: grid; gap: 8px; margin-bottom: 10px; }
.upload-row { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.upload-row .info { flex: 1; min-width: 0; word-break: break-all; }
.upload-row select { width: auto; max-width: 260px; }
.upload-row.conflict { border-color: var(--warn); }
.warn-text { color: var(--warn); font-size: 13.5px; }
.ok-text { color: var(--ok); font-size: 13.5px; }

.status-line { font-size: 13px; color: var(--muted); margin: 0 0 2px; }
.boot { padding-top: 40px; }
.boot.error h1 { color: var(--danger); }
.paper-bar .btn, .paper-bar button { touch-action: manipulation; }

@media (max-width: 860px) {
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { font-size: 22px; gap: 8px; }
  .brand img { width: 30px; height: 30px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  nav a, nav .soon { padding: 6px 9px; }
  .side-actions { margin-top: 0; width: 100%; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .side-actions .btn.block { width: auto; flex: 1 1 auto; padding: 8px 10px; font-size: 14px; }
  .side-actions .status-line { width: 100%; }
  .side-note { display: none; }
  .main { padding: 18px 14px 120px; }
  h1 { font-size: 34px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card .name { font-size: 20px; }
  .panel { padding: 16px; }
  .savebar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .savebar .btn { padding: 8px 12px; font-size: 14px; }
  .savebar .spacer { display: none; }
  input[type=text], textarea, select { font-size: 16px; }
  .image-field { flex-direction: column; align-items: stretch; }
  .image-field .pic { width: 100%; height: auto; aspect-ratio: 3 / 2; }
  .string-row { flex-wrap: wrap; }
  .paper-bar { gap: 4px; padding: 8px; }
  .paper-bar .btn { padding: 6px 9px; font-size: 13px; }
  .paper-bar .sep { display: none; }
  .paper-col { padding: 24px 16px 60px; }
  .paper { font-size: 18px; }
  .toast { left: 12px; right: 12px; top: 12px; max-width: none; }
  .modal { padding: 10px; align-items: end; }
  .dialog { max-height: 92vh; }
  .upload-row { flex-wrap: wrap; }
  .order-list li { flex-wrap: wrap; }
}

.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.lib-head h3 { margin: 0; }
