/* Layout: a librarian's worksheet — picking tools on the left, a sticky purchase list on the right. Minse green and gold on warm cream. */
:root {
  --bg: #fffaf0;
  --surface: #ffffff;
  --sunk: #fdf6e8;
  --text: #22312c;
  --muted: #6b7772;
  --line: #efe6d4;
  --brand: #00684f;
  --brand-deep: #004f3c;
  --brand-soft: #e4f2ec;
  --gold: #f5b21b;
  --good: #2f8a3e;
  --bad: #a33838;
  --warn: #a35a00;
  --saved: #6a45b5;
  --sheet: #137333;
  --sheet-soft: #e6f4ea;
  --owned-row: #fff8c5;
  --review-row: #dcf1fb;
  --shadow: 0 10px 30px rgb(92 70 20 / 8%);
  --font: "IBM Plex Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13140f;
    --surface: #1c1e17;
    --sunk: #171912;
    --text: #e6efe8;
    --muted: #9db0a3;
    --line: #33352a;
    --brand: #7fd4b4;
    --brand-deep: #ade6cf;
    --brand-soft: #1b362c;
    --good: #5fcf96;
    --bad: #f08a8a;
    --warn: #f0b860;
    --saved: #b9a0f0;
    --sheet: #81c995;
    --sheet-soft: #1d3326;
    --owned-row: #3a3514;
    --review-row: #15313f;
    --shadow: 0 10px 30px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}
button, input { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2 { margin: 0; text-wrap: balance; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar { background: var(--brand-deep); color: #fff; border-bottom: 4px solid var(--gold); }
@media (prefers-color-scheme: dark) { .topbar { background: #0f3a2d; } }
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) 18px max(16px, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 14px;
}
.school-mark { width: 52px; height: 52px; border-radius: 50%; background: #fff; padding: 2px; }
.eyebrow { margin: 0; font-size: 0.8rem; letter-spacing: 0.08em; opacity: 0.8; }
h1 { font-size: clamp(1.25rem, 3vw, 1.6rem); font-weight: 700; line-height: 1.3; }

/* Layout */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
  gap: 24px;
  align-items: start;
}
.pick { display: grid; gap: 20px; min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  display: grid;
  gap: 14px;
  min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font-size: 1.1rem; font-weight: 700; }

/* Kyobo */
.connection {
  margin: 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--muted);
  font-size: 0.8rem;
}
.connection.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.howto { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; }
.howto li { padding-left: 4px; }
.howto li::marker { color: var(--brand); font-weight: 700; }
.howto strong { font-weight: 600; }
.howto-hint { display: block; color: var(--muted); font-size: 0.85rem; }
.bookmarklet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--gold);
  color: #2a2006;
  font-weight: 700;
  text-decoration: none;
  cursor: grab;
  border: 2px dashed rgb(42 32 6 / 35%);
}
.bookmarklet::before { content: "⠿"; opacity: 0.6; }
.bookmarklet.disabled { opacity: 0.5; cursor: not-allowed; }
.store-links { display: grid; gap: 8px; }
.store-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.store-name { min-width: 4.5em; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.store-links a {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}
.store-links a:hover { text-decoration: underline; }
.store-links .sheet-link { background: var(--sheet-soft); color: var(--sheet); }

/* Search */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sunk);
}
button {
  cursor: pointer;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: var(--surface);
  font-weight: 600;
}
button:hover:not(:disabled) { background: var(--brand-deep); }
button:disabled { cursor: default; opacity: 0.55; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button.owned { background: var(--bad); }
button.added { background: var(--good); opacity: 1; }

.results { display: grid; gap: 10px; }
.result {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.result-cover, .item-cover { width: 56px; height: 80px; object-fit: cover; border-radius: 4px; background: var(--sunk); }
.item-cover { width: 44px; height: 64px; }
.cover-empty { display: grid; place-items: center; font-size: 0.7rem; color: var(--muted); text-align: center; }
.result-info, .item-info { min-width: 0; }
.book-title { margin: 0; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
a.book-title { display: block; color: var(--text); text-decoration: none; }
a.book-title:hover { text-decoration: underline; }
.book-meta { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.small-link { font-size: 0.85rem; }
.holding { margin: 4px 0 2px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.holding-owned { color: var(--bad); }
.holding-none { color: var(--good); }
.holding-similar { color: var(--warn); }
.holding-saved { color: var(--saved); }
.holding-error { color: var(--bad); font-weight: 400; }

/* 내 도서목록 소장 확인 */
.panel-hint { margin: 0; color: var(--muted); font-size: 0.9rem; }
.drop {
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
  padding: 18px 16px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--sunk);
  cursor: pointer;
}
.drop:hover, .drop.dragging { border-color: var(--sheet); background: var(--sheet-soft); }
.drop:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.drop strong { color: var(--sheet); font-size: 1rem; }
.drop span { font-size: 0.88rem; color: var(--muted); }
.drop .drop-hint { font-size: 0.8rem; }
.drop b { font-weight: 600; color: var(--text); }
.paste summary { cursor: pointer; color: var(--brand); font-size: 0.9rem; font-weight: 600; }
.paste[open] { display: grid; gap: 8px; }
.paste textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  color: var(--text);
  font: 0.85rem/1.5 ui-monospace, Consolas, monospace;
  resize: vertical;
}
.paste button { justify-self: start; }
.check-setup { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.check-source { margin: 0; font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.check-source strong { color: var(--text); font-weight: 600; }
.check-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}
.check-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.check-results { display: grid; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip:hover:not(:disabled) { background: var(--sunk); }
.chip[aria-pressed="true"], .chip[aria-pressed="true"]:hover { background: var(--brand); border-color: var(--brand); color: var(--surface); }
.check-table-wrap { max-height: 480px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.check-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.check-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--sunk);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.check-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.check-table tr:last-child td { border-bottom: 0; }
.check-table .book-title { font-size: 0.9rem; }
.check-num { color: var(--muted); font-variant-numeric: tabular-nums; width: 3em; }
.check-isbn { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.check-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
}
.check-owned-isbn, .check-owned-author, .check-owned-title { color: var(--bad); }
.check-author-diff { color: var(--saved); }
.check-similar { color: var(--warn); }
.check-row-owned td { background: var(--owned-row); }
.check-row-review td { background: var(--review-row); }
.check-none { color: var(--good); }
.check-error { color: var(--bad); border-style: dashed; }
.check-in-cart { margin: 4px 0 0; font-size: 0.8rem; font-weight: 600; color: var(--good); }

/* Log */
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.9rem; }
.log li { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); gap: 8px; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.log .log-owned span, .log .log-error span, .log .log-forced span { color: var(--bad); }
.log .log-removed span { color: var(--muted); }
.log .log-added span, .log .log-saved span, .log .log-imported span { color: var(--good); }
.log-empty { color: var(--muted); display: block !important; }

/* Cart */
.cart { position: sticky; top: 16px; min-width: 0; }
.cart-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }
.field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  color: var(--text);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.summary {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--sunk);
}
.summary div { display: grid; gap: 0; }
.summary dt { font-size: 0.78rem; color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-main { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 8px; }
.summary-main dd { font-size: 1.5rem; color: var(--brand); }
.budget { display: grid; gap: 6px; font-size: 0.88rem; }
.budget p { margin: 0; }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--good); border-radius: inherit; }
.budget.over .meter span { background: var(--bad); }
.budget.over p { color: var(--bad); font-weight: 600; }
.note { margin: 0; font-size: 0.85rem; color: var(--muted); }
.empty { margin: 0; color: var(--muted); font-size: 0.9rem; padding: 16px; border: 1px dashed var(--line); border-radius: 10px; }
.items { list-style: none; margin: 0; padding: 0; display: grid; }
.item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.item:first-child { padding-top: 0; }
.item-cover { grid-row: span 2; }
.item-price { margin: 4px 0 0; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.item-note {
  justify-self: start;
  width: fit-content;
  margin: 4px 0 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sunk);
  border: 1px solid var(--bad);
  color: var(--bad);
  font-size: 0.78rem;
  font-weight: 600;
}
.item-controls { display: flex; align-items: center; gap: 6px; }
.step { width: 30px; height: 30px; padding: 0; border-radius: 8px; background: var(--brand-soft); color: var(--brand); }
.step:hover:not(:disabled) { background: var(--line); }
.qty {
  width: 52px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.remove { margin-left: auto; padding: 4px 10px; background: transparent; color: var(--bad); border: 1px solid var(--line); }
.remove:hover:not(:disabled) { background: var(--sunk); }
.actions { display: flex; gap: 8px; align-items: stretch; }
.actions .primary { flex: 1; }
.side-actions { display: grid; gap: 6px; }
.primary { padding: 12px; font-size: 1rem; }
.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.ghost:hover:not(:disabled) { background: var(--sunk); }
.danger { background: var(--bad); }

/* Dialogs */
.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 22px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog[open] { display: grid; gap: 12px; }
.dialog::backdrop { background: rgb(10 16 28 / 55%); }
.dialog h2 { font-size: 1.15rem; }
.dialog p { margin: 0; }
.dialog-note { color: var(--muted); font-size: 0.88rem; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dialog-actions .primary { padding: 8px 18px; font-size: 0.95rem; }
.import-lists { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 45vh; overflow: auto; }
.import-lists:empty { display: none; }
.import-item {
  width: 100%;
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sunk);
  color: var(--text);
  font-weight: 400;
}
.import-item:hover:not(:disabled) { background: var(--brand-soft); }
.import-item:disabled { opacity: 0.6; }
.import-item[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.import-item strong { font-weight: 600; overflow-wrap: anywhere; }
.import-item span { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.import-mode { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 4px; }
.import-mode legend { padding: 0 4px; font-size: 0.88rem; font-weight: 600; }
.import-mode label { display: flex; gap: 8px; align-items: center; font-size: 0.92rem; }

.status { margin: 0; font-size: 0.9rem; min-height: 0; }
.status:empty { display: none; }
.status.error { color: var(--bad); }
.status.success { color: var(--good); }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .cart { position: static; order: -1; }
  .cart-inner { max-height: none; }
}
@media (max-width: 480px) {
  .result { grid-template-columns: 48px minmax(0, 1fr); }
  .result button { grid-column: 1 / -1; }
  .fields { grid-template-columns: 1fr; }
  .check-table th:nth-child(3), .check-table td:nth-child(3) { display: none; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
