:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e9ecef;
  --chip-bg: #f1f3f5;
  --tag-bg: #e9ecef;
  --ink: #1a1a1a;
  --ink-soft: #495057;
  --ink-faint: #868e96;
  --ink-faintest: #adb5bd;
  --accent: #212529;
  --accent-hover: #000000;
  --accent-contrast: #ffffff;
  --danger: #a15353;
  --radius-lg: 20px;
  --radius-md: 12px;
  --shadow-hover: 0 10px 20px rgba(0,0,0,0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151516;
    --surface: #1e1f20;
    --border: #2d2e30;
    --chip-bg: #26272a;
    --tag-bg: #2d2e30;
    --ink: #f1f1f0;
    --ink-soft: #c2c3c5;
    --ink-faint: #8b8c8e;
    --ink-faintest: #6a6b6d;
    --accent: #f1f1f0;
    --accent-hover: #ffffff;
    --accent-contrast: #151516;
    --danger: #d19a9a;
    --shadow-hover: 0 10px 24px rgba(0,0,0,0.35);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  display: flex;
  min-height: 100%;
}
[data-lucide] { display: block; }

.wrapper {
  display: flex;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  gap: 24px;
  align-items: flex-start;
}

/* ---------- Sidebar ---------- */
aside {
  width: 260px;
  flex: none;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 24px;
}

.logo-area { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 700; }
.logo-area svg { width: 20px; height: 20px; }

.side-nav-item {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  padding: 10px 12px; border-radius: var(--radius-md); cursor: pointer; font-size: 0.92rem;
  color: var(--ink-soft); font-family: inherit; font-weight: 600; text-align: left;
}
.side-nav-item svg { width: 17px; height: 17px; }
.side-nav-item:hover { background-color: var(--chip-bg); color: var(--ink); }

/* ---------- Calendar ---------- */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-header h2 { margin: 0; font-size: 1rem; }
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); text-align: center;
  font-size: 0.75rem; color: var(--ink-faint); font-weight: 600; margin-bottom: 8px;
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  aspect-ratio: 1; border-radius: var(--radius-md); background: var(--chip-bg);
  position: relative; overflow: hidden; display: flex; flex-direction: column;
}
.cal-cell.empty { background: transparent; }
.cal-cell.has-book { cursor: pointer; }
.cal-cell.has-book:hover { outline: 2px solid var(--ink-faintest); }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-day-num {
  font-size: 0.68rem; color: var(--ink-faint); padding: 4px 5px; z-index: 2;
  text-shadow: 0 0 4px var(--chip-bg);
}
.cal-cell.has-book .cal-day-num { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.7); font-weight: 700; }
.cal-cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cal-cover-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-faintest); background: var(--tag-bg);
}
.cal-cover-fallback svg { width: 22%; height: 22%; }

.cal-cover-stack { position: absolute; inset: 0; }
.cal-cover-stack > *:nth-child(1) {
  z-index: 1; transform: translate(18%, 14%) scale(0.9); opacity: 0.55;
  box-shadow: -2px -2px 4px rgba(0,0,0,0.15);
}
.cal-cover-stack > *:nth-child(2) {
  z-index: 2; transform: translate(9%, 7%) scale(0.95); opacity: 0.78;
  box-shadow: -2px -2px 4px rgba(0,0,0,0.12);
}
.cal-cover-stack > *:last-child { z-index: 4 !important; transform: none !important; opacity: 1 !important; box-shadow: none !important; }
.cal-badge {
  position: absolute; bottom: 3px; right: 3px; background: rgba(0,0,0,0.6); color: #fff;
  font-size: 0.62rem; font-weight: 700; padding: 1px 5px; border-radius: 999px; z-index: 2;
}
.cal-read-dot {
  position: absolute; bottom: 4px; left: 4px; width: 7px; height: 7px; border-radius: 50%; z-index: 3;
}
.cal-cell:not(.has-book) .cal-read-dot { background: var(--ink); box-shadow: 0 0 0 2px var(--chip-bg); }
.cal-cell.has-book .cal-read-dot { background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,0.45); }
.calendar-hint { font-size: 0.78rem; color: var(--ink-faintest); text-align: center; margin-top: 14px; }

.day-picker-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.day-picker-item {
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-md);
  cursor: pointer; transition: background-color .15s;
}
.day-picker-item:hover { background-color: var(--chip-bg); }
.day-picker-thumb {
  width: 42px; height: 60px; border-radius: 8px; background: var(--tag-bg); flex: none;
  display: flex; align-items: center; justify-content: center; color: var(--ink-faintest); overflow: hidden;
}
.day-picker-thumb svg { width: 18px; height: 18px; }
.day-picker-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.day-picker-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.day-picker-title { font-size: 0.9rem; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-picker-meta { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--ink-faint); }
.day-picker-meta .type-badge { font-size: 0.68rem; }

@media (max-width: 480px) {
  .cal-day-num { font-size: 0.6rem; padding: 2px 3px; }
}

.category-section h3 {
  font-size: 0.8rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  font-weight: 600;
}

.category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 40vh;
  overflow-y: auto;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--ink-soft);
  transition: background-color .15s, color .15s;
  gap: 8px;
}
.category-item .cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-item:hover { background-color: var(--chip-bg); }
.category-item.active { background-color: var(--chip-bg); color: var(--ink); font-weight: 600; }
.category-item .count {
  flex: none; font-size: 0.75rem; background-color: var(--tag-bg);
  padding: 2px 8px; border-radius: 20px; color: var(--ink-faint);
}
.category-item .cat-del {
  flex: none; display: none; width: 22px; height: 22px; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--ink-faintest); background: none; border: none; cursor: pointer;
}
.category-item .cat-del svg { width: 13px; height: 13px; }
.category-item:hover .cat-del { display: flex; }
.category-item:hover .count { display: none; }

.cat-node { display: flex; flex-direction: column; }
.cat-row {
  display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 4px;
  border-radius: var(--radius-md); cursor: pointer; font-size: 0.92rem; color: var(--ink-soft);
  transition: background-color .15s, color .15s;
}
.cat-row:hover { background-color: var(--chip-bg); }
.cat-row.active { background-color: var(--chip-bg); color: var(--ink); font-weight: 600; }
.cat-row .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-toggle {
  flex: none; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--ink-faint); cursor: pointer; padding: 0;
  transition: transform .15s;
}
.cat-toggle.open { transform: rotate(90deg); }
.cat-toggle-spacer { width: 18px; flex: none; }
.cat-row .count {
  flex: none; font-size: 0.75rem; background-color: var(--tag-bg); padding: 2px 8px;
  border-radius: 20px; color: var(--ink-faint);
}
.cat-row .cat-add-sub, .cat-row .cat-del {
  flex: none; display: none; width: 20px; height: 20px; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--ink-faintest); background: none; border: none; cursor: pointer;
}
.cat-row .cat-add-sub svg, .cat-row .cat-del svg { width: 12px; height: 12px; }
.cat-row:hover .cat-add-sub,
.cat-row:hover .cat-del { display: flex; }
.cat-row:hover .count { display: none; }
.cat-children { display: flex; flex-direction: column; padding-left: 18px; }
.cat-children.collapsed { display: none; }

.add-category-btn {
  display: flex; align-items: center; gap: 8px; background: none;
  border: 1px dashed var(--ink-faintest); padding: 10px; border-radius: var(--radius-md);
  cursor: pointer; font-size: 0.88rem; color: var(--ink-faint); justify-content: center;
  transition: all .15s; font-family: inherit;
}
.add-category-btn svg { width: 16px; height: 16px; }
.add-category-btn:hover { border-color: var(--ink-faint); color: var(--ink-soft); background-color: var(--chip-bg); }

.streak-badge {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--chip-bg); color: var(--ink); font-size: 0.85rem; font-weight: 700;
}
.streak-badge svg { width: 16px; height: 16px; flex: none; }

/* 로그인 전에는 쓰기/수정/삭제 관련 요소를 전부 숨김 */
body:not(.is-admin) .admin-only { display: none !important; }
body:not(.is-admin) .book-del,
body:not(.is-admin) .cat-del,
body:not(.is-admin) .cat-add-sub { display: none !important; }

.admin-toggle-btn {
  display: flex; align-items: center; gap: 8px; background: none;
  border: 1px solid var(--border); padding: 10px; border-radius: var(--radius-md);
  cursor: pointer; font-size: 0.85rem; color: var(--ink-faint); justify-content: center;
  transition: all .15s; font-family: inherit;
}
.admin-toggle-btn svg { width: 15px; height: 15px; }
.admin-toggle-btn:hover { background-color: var(--chip-bg); color: var(--ink-soft); }
body.is-admin .admin-toggle-btn { color: var(--ink); border-color: var(--ink-faintest); }

.admin-error { font-size: 0.8rem; color: var(--danger); margin: -8px 0 12px; min-height: 1em; }

/* ---------- Main ---------- */
main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

header {
  display: flex; justify-content: space-between; align-items: center;
  background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 20px; gap: 12px; position: sticky; top: 24px; z-index: 5;
}

.search-bar {
  display: flex; align-items: center; background-color: var(--chip-bg);
  padding: 8px 14px; border-radius: var(--radius-md); gap: 8px; width: 300px; max-width: 50vw;
}
.search-bar svg { color: var(--ink-faintest); flex: none; width: 18px; height: 18px; }
.search-bar input { border: none; background: none; outline: none; font-size: 0.9rem; width: 100%; color: var(--ink); font-family: inherit; }
.search-bar input::placeholder { color: var(--ink-faintest); }

.sort-select {
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--ink-soft);
  border-radius: var(--radius-md); padding: 9px 12px; font-size: 0.85rem; font-family: inherit;
  cursor: pointer; outline: none; flex: none;
}

.write-btn {
  display: flex; align-items: center; gap: 8px; background-color: var(--accent); color: var(--accent-contrast);
  border: none; padding: 10px 18px; border-radius: var(--radius-md); font-weight: 600; cursor: pointer;
  font-size: 0.88rem; font-family: inherit; transition: background-color .15s; flex: none;
}
.write-btn svg { width: 18px; height: 18px; }
.write-btn:hover { background-color: var(--accent-hover); }
.header-actions { display: flex; gap: 10px; flex: none; }
.stats-btn { background-color: var(--surface); color: var(--ink-soft); border: 1px solid var(--border); }
.stats-btn:hover { background-color: var(--chip-bg); }

/* ---------- Stats panel ---------- */
.stats-summary { display: flex; justify-content: center; margin-bottom: 20px; }
.stats-total {
  display: flex; align-items: baseline; gap: 6px; background: var(--chip-bg);
  padding: 14px 28px; border-radius: 999px;
}
.stats-total-num { font-size: 2.1rem; font-weight: 800; color: var(--ink); line-height: 1; }
.stats-total-label { font-size: 0.9rem; color: var(--ink-faint); font-weight: 600; }

.stats-chart-wrap { position: relative; margin-bottom: 24px; min-height: 60px; }
.stats-empty { text-align: center; color: var(--ink-faintest); font-size: 0.85rem; padding: 20px 0; }

.today-box {
  background: var(--chip-bg); border-radius: var(--radius-md); padding: 16px 18px; margin-bottom: 4px;
}
.today-head { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 10px; }
.today-head svg { width: 16px; height: 16px; }

.today-view-status { font-size: 0.92rem; color: var(--ink-soft); }
.today-view { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.today-streak-line { font-size: 0.78rem; color: var(--ink-faint); }

.today-edit { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.today-checkbox { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--ink); cursor: pointer; }
.today-checkbox input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.today-pages-row { display: flex; align-items: center; gap: 10px; }
.today-pages-row label { font-size: 0.85rem; color: var(--ink-faint); flex: none; }
.today-pages-row input {
  width: 100px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-md); padding: 8px 12px; font-size: 0.9rem; font-family: inherit; outline: none;
}
.today-edit .btn { flex: none; align-self: flex-start; padding: 9px 18px; }
.save-confirm {
  font-size: 0.82rem; color: var(--ink); font-weight: 600; margin-left: 10px;
  opacity: 0; transition: opacity .2s;
}
.save-confirm.show { opacity: 1; }
.today-save-row { display: flex; align-items: center; }
.today-save-row .btn { flex: none; }

/* ---------- Status picker / badge ---------- */
.status-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pick {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-soft); font-size: 0.85rem;
  cursor: pointer; font-family: inherit;
}
.status-pick.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.status-badge { font-size: 0.72rem; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.status-badge.want { background: var(--tag-bg); color: var(--ink-faint); }
.status-badge.reading { background: var(--ink); color: var(--accent-contrast); }

/* ---------- Read dates (여러 날짜 기록) ---------- */
.read-dates-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.read-date-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--chip-bg);
  border: 1px solid var(--border); padding: 6px 6px 6px 12px; border-radius: 999px;
  font-size: 0.82rem; color: var(--ink-soft);
}
.read-date-chip .rd-pages { color: var(--ink-faint); }
.read-date-chip .rd-del {
  width: 18px; height: 18px; border-radius: 50%; border: none; background: var(--tag-bg);
  color: var(--ink-faint); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.read-date-chip .rd-del svg { width: 10px; height: 10px; }
.read-dates-empty { font-size: 0.82rem; color: var(--ink-faintest); }

.read-dates-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.read-dates-add-row input[type="date"],
.read-dates-add-row input[type="number"] {
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--ink);
  border-radius: var(--radius-md); padding: 8px 12px; font-size: 0.85rem; font-family: inherit; outline: none;
}
.read-dates-add-row input[type="number"] { width: 110px; }
.read-dates-add-row .cover-btn { flex: none; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

.type-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.type-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft);
  font-size: 0.85rem; font-family: inherit; cursor: pointer;
}
.type-chip svg { width: 14px; height: 14px; }
.type-chip.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.type-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; padding: 2px 9px;
  border-radius: 20px; background: var(--tag-bg); color: var(--ink-faint); font-weight: 600;
}
.type-badge svg { width: 11px; height: 11px; }

.stats-type-tabs { justify-content: center; margin-bottom: 18px; }
.stats-mode-tabs { justify-content: center; margin-bottom: 16px; }

/* ---------- Stack view (쌓아보기) ---------- */
.stack-year-nav {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-size: 0.95rem; font-weight: 700; color: var(--ink); margin-bottom: 6px;
}
.stack-height-line { text-align: center; font-size: 0.82rem; color: var(--ink-faint); margin-bottom: 18px; }
.stack-height-line strong { color: var(--ink); font-weight: 700; }

.stack-tower {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  max-height: 420px; overflow-y: auto; padding: 4px 4px 4px 24px;
}
.stack-block {
  width: 100%; max-width: 320px; border-radius: 6px; display: flex; align-items: center;
  justify-content: flex-start; text-align: left; padding: 6px 16px; font-size: 0.8rem;
  font-weight: 600; overflow: hidden; cursor: pointer; flex: none; position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -1px 0 rgba(0,0,0,0.08);
}
.stack-block::before {
  content: ''; position: absolute; left: -10px; top: 0; bottom: 0; width: 10px;
  background: inherit; border-radius: 3px 0 0 3px; filter: brightness(0.88);
}
.stack-block span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.stack-block.tone-0 { background: var(--tag-bg); color: var(--ink-soft); }
.stack-block.tone-1 { background: var(--ink-faintest); color: var(--surface); }
.stack-block.tone-2 { background: var(--ink-faint); color: var(--surface); }
.stack-block.tone-3 { background: var(--ink); color: var(--accent-contrast); }

.book-card {
  background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; display: flex; gap: 16px; transition: transform .15s, box-shadow .15s; cursor: pointer; position: relative;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.book-del {
  position: absolute; top: 14px; right: 14px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--chip-bg); color: var(--ink-faint); display: flex; align-items: center;
  justify-content: center; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.book-del svg { width: 13px; height: 13px; }
.book-card:hover .book-del { opacity: 1; }

.book-cover-placeholder {
  width: 84px; height: 122px; background-color: var(--tag-bg); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; color: var(--ink-faintest);
  flex-shrink: 0; overflow: hidden;
}
.book-cover-placeholder svg { width: 30px; height: 30px; }
.book-cover-placeholder img { width: 100%; height: 100%; object-fit: cover; display: block; }

.book-info { display: flex; flex-direction: column; justify-content: space-between; flex: 1; min-width: 0; }
.book-title { font-size: 1.02rem; font-weight: 700; margin-bottom: 3px; line-height: 1.35; padding-right: 20px; }
.book-author { font-size: 0.83rem; color: var(--ink-faint); margin-bottom: 8px; }
.book-meta { display: flex; flex-direction: column; gap: 6px; }

.rating { display: flex; gap: 2px; }
.star-slot svg { width: 14px; height: 14px; color: var(--tag-bg); }
.star-slot.on svg { color: var(--ink); fill: currentColor; }

.card-bottom-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cat-tag { font-size: 0.72rem; color: var(--ink-faint); background-color: var(--tag-bg); padding: 2px 9px; border-radius: 20px; }
.date-badge { font-size: 0.78rem; color: var(--ink-faint); display: flex; align-items: center; gap: 4px; }
.date-badge svg { width: 12px; height: 12px; }

.comment {
  font-size: 0.85rem; color: var(--ink-soft); line-height: 1.45; margin-top: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.empty-state {
  text-align: center; padding: 90px 20px; color: var(--ink-faint);
  background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 12px; color: var(--ink-faintest); }
.empty-state p { margin: 4px 0; font-size: 0.92rem; }

.status-note { text-align: center; font-size: 0.78rem; color: var(--ink-faintest); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.overlay.show { display: flex; }
#adminOverlay { z-index: 80; }

.modal {
  background: var(--surface); width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  border-radius: var(--radius-lg); padding: 26px;
}
.modal-wide { max-width: 620px; }
.modal h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 18px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.78rem; color: var(--ink-faint); margin-bottom: 6px; font-weight: 600; }
.field input[type="text"], .field input[type="date"], .field select {
  width: 100%; border: 1px solid var(--border); background: var(--chip-bg); color: var(--ink);
  border-radius: var(--radius-md); padding: 10px 13px; font-size: 0.9rem; font-family: inherit; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--ink-faint); }

.cover-upload-row { display: flex; align-items: center; gap: 12px; }
.cover-preview {
  width: 56px; height: 80px; border-radius: 10px; background: var(--chip-bg); display: flex;
  align-items: center; justify-content: center; color: var(--ink-faintest); overflow: hidden; flex: none;
}
.cover-preview svg { width: 22px; height: 22px; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-upload-actions { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cover-btn-row { display: flex; gap: 8px; }
.cover-btn {
  font-size: 0.8rem; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-soft); cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 5px;
}
.cover-btn svg { width: 13px; height: 13px; }
.cover-btn:hover { background: var(--chip-bg); }
.cover-hint { font-size: 0.74rem; color: var(--ink-faintest); }

.star-picker { display: flex; gap: 6px; }
.star-pick { cursor: pointer; color: var(--tag-bg); }
.star-pick svg { width: 28px; height: 28px; }
.star-pick.on { color: var(--ink); }
.star-pick.on svg { fill: currentColor; }

.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { flex: 1; padding: 12px; border-radius: var(--radius-md); border: none; font-size: 0.9rem; font-weight: 700; font-family: inherit; cursor: pointer; }
.btn-ghost { background: var(--chip-bg); color: var(--ink-soft); }
.btn-solid { background: var(--accent); color: var(--accent-contrast); }
.btn-solid:hover { background: var(--accent-hover); }

.cat-modal { max-width: 340px; }
.cat-modal p.hint { font-size: 0.8rem; color: var(--ink-faint); margin: -10px 0 14px; }

/* ---------- Quill editor (블로그 에디터) ---------- */
.note-editor { background: var(--chip-bg); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.ql-toolbar.ql-snow {
  border: none !important; border-bottom: 1px solid var(--border) !important;
  background: var(--surface); border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.ql-container.ql-snow { border: none !important; font-family: inherit; font-size: 0.95rem; }
.ql-editor { min-height: 220px; line-height: 1.7; color: var(--ink); }
.ql-editor.ql-blank::before { color: var(--ink-faintest); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--ink-soft); }
.ql-snow .ql-fill { fill: var(--ink-soft); }
.ql-snow .ql-picker { color: var(--ink-soft); }
.ql-snow.ql-toolbar button:hover, .ql-snow .ql-toolbar button:hover,
.ql-snow.ql-toolbar button.ql-active, .ql-snow .ql-toolbar button.ql-active { color: var(--ink); }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke, .ql-snow .ql-toolbar button.ql-active .ql-stroke { stroke: var(--ink); }

/* ---------- Detail (blog reading) view ---------- */
.detail-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 60; display: none; overflow-y: auto;
}
.detail-overlay.show { display: block; }

.detail-topbar {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; background: var(--bg); z-index: 2;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-soft); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--chip-bg); }
.icon-btn.danger { color: var(--danger); }
.detail-actions { display: flex; gap: 8px; }

.detail-article { max-width: 640px; margin: 0 auto; padding: 10px 24px 100px; }
.detail-cover-row { display: flex; justify-content: center; margin-bottom: 22px; }
.detail-cover {
  width: 108px; height: 156px; background-color: var(--tag-bg); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; color: var(--ink-faintest); overflow: hidden;
}
.detail-cover svg { width: 36px; height: 36px; }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.detail-title { font-size: 1.7rem; font-weight: 700; line-height: 1.4; text-align: center; margin-bottom: 6px; letter-spacing: -0.01em; }
.detail-author { text-align: center; font-size: 0.92rem; color: var(--ink-faint); margin-bottom: 18px; }
.detail-summary {
  text-align: center; font-size: 1rem; color: var(--ink-soft); font-style: italic;
  line-height: 1.6; margin: 0 auto 22px; max-width: 480px;
}
.detail-meta-row {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border);
}
.detail-stars { display: flex; gap: 3px; }
.detail-stars svg { width: 17px; height: 17px; color: var(--tag-bg); }
.detail-stars svg.on { color: var(--ink); fill: currentColor; }

.detail-read-dates {
  display: flex; align-items: flex-start; gap: 6px; font-size: 0.78rem; color: var(--ink-faint);
  margin: -20px 0 28px; line-height: 1.6;
}
.detail-read-dates svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }

/* 에디터에서 쓴 서식이 블로그처럼 보이도록 하는 타이포그래피 */
.detail-body { font-size: 1.02rem; line-height: 1.9; color: var(--ink-soft); word-break: keep-all; }
.detail-body.empty { color: var(--ink-faintest); font-style: italic; text-align: center; padding: 30px 0; }
.detail-body p { margin: 0 0 1.1em; }
.detail-body h1, .detail-body h2, .detail-body h3 { color: var(--ink); font-weight: 700; margin: 1.4em 0 0.6em; line-height: 1.4; }
.detail-body h1 { font-size: 1.4rem; }
.detail-body h2 { font-size: 1.25rem; }
.detail-body h3 { font-size: 1.1rem; }
.detail-body blockquote {
  margin: 1.2em 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--ink-faintest);
  color: var(--ink-faint); font-style: italic;
}
.detail-body ul, .detail-body ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.detail-body li { margin-bottom: 0.4em; }
.detail-body img { max-width: 100%; border-radius: var(--radius-md); margin: 1.2em 0; display: block; }
.detail-body a { color: var(--ink); text-decoration: underline; }
.detail-body .ql-align-center { text-align: center; }
.detail-body .ql-align-right { text-align: right; }
.detail-body .ql-align-justify { text-align: justify; }

@media (max-width: 860px) {
  .wrapper { flex-direction: column; padding: 16px; }
  aside { width: 100%; position: static; max-height: none; }
  .category-list { max-height: none; }
  .search-bar { width: auto; flex: 1; }
  .write-btn span { display: none; }
  .write-btn { padding: 10px; }
  .field-row { grid-template-columns: 1fr; }
  .detail-article { padding: 6px 18px 80px; }
  .detail-title { font-size: 1.4rem; }
}
