:root {
  --bg: #fff7e8;
  --bg-pattern: radial-gradient(circle at 12% 18%, rgba(50, 99, 74, 0.045) 0, transparent 38%),
                radial-gradient(circle at 88% 82%, rgba(246, 202, 86, 0.10) 0, transparent 42%);
  --surface: #ffffff;
  --surface-alt: #f7eedb;
  --border: #e5d8be;
  --text: #1f2a22;
  --text-muted: #5d695f;
  --accent: #32634a;
  --accent-deep: #224734;
  --accent-soft: #e4efe8;
  --saffron: #f6ca56;
  --tomato: #e9472f;
  --warm: #9e5619;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(34, 71, 52, 0.07);
}

[data-theme="dark"] {
  --bg: #14181d;
  --bg-pattern: radial-gradient(circle at 15% 20%, rgba(232, 184, 109, 0.06) 0, transparent 40%),
                radial-gradient(circle at 85% 80%, rgba(126, 174, 143, 0.06) 0, transparent 45%);
  --surface: #1e242b;
  --surface-alt: #262e37;
  --border: #313b46;
  --text: #eceae4;
  --text-muted: #9fa8b2;
  --accent: #7eae8f;
  --accent-deep: #e8b86d;
  --accent-soft: #24362c;
  --saffron: #e8b86d;
  --tomato: #e67e67;
  --warm: #e8b86d;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .topbar {
  background: rgba(20, 24, 29, 0.92);
}

[data-theme="dark"] .sidebar {
  background: rgba(30, 36, 43, 0.94);
}

[data-theme="dark"] .hero {
  background: linear-gradient(135deg, #1d2723 0%, #24221c 100%);
}

[data-theme="dark"] .note-box {
  background: #242118;
}

[data-theme="dark"] .original-panel {
  background: #1a1f25;
  border-color: #3a4450;
  color: #cfd5dc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  color: var(--text);
  line-height: 1.75;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  text-decoration: none;
  color: var(--accent-deep);
  font-family: 'Noto Serif KR', serif;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.search-wrap input {
  width: 230px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(50, 99, 74, 0.14);
}

.icon-btn, .pill-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.15s ease;
}

.pill-btn {
  border-radius: 999px;
  padding: 7px 14px;
  white-space: nowrap;
  font-weight: 500;
}

.pill-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pill-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.layout {
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

.sidebar {
  width: 306px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid var(--border);
  padding: 20px 18px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Noto Serif KR', serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent-deep);
  margin-bottom: 12px;
}

.progress-box {
  font-size: 0.82rem;
  color: var(--accent-deep);
  background: linear-gradient(135deg, var(--accent-soft) 0%, #fbf3dc 100%);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.toc-group-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--warm);
  text-transform: uppercase;
  margin: 18px 0 8px;
  letter-spacing: 0.05em;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
}

.toc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.88rem;
  margin-bottom: 3px;
  transition: background 0.12s ease;
}

.toc-item:hover {
  background: var(--surface-alt);
}

.toc-item.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.toc-item.active .toc-badge {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.toc-item.pending {
  color: var(--text-muted);
}

.toc-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  flex-shrink: 0;
}

.toc-badge.done {
  background: var(--saffron);
  color: #2b2612;
  font-weight: 700;
}

.main-content {
  flex: 1;
  padding: 32px 38px 72px;
  max-width: 880px;
  margin: 0 auto;
}

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #f3f7ef 0%, #fff4d8 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 30px;
  margin-bottom: 26px;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "🌿";
  position: absolute;
  right: 24px;
  top: 20px;
  font-size: 2.4rem;
  opacity: 0.28;
}

.hero h1 {
  font-family: 'Noto Serif KR', serif;
  margin: 0 0 8px;
  font-size: 1.95rem;
  color: var(--accent-deep);
}

.hero-sub {
  color: var(--warm);
  font-weight: 500;
  margin: 0 0 12px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.card-title {
  font-family: 'Noto Serif KR', serif;
  font-weight: 700;
  font-size: 1.04rem;
  color: var(--accent-deep);
  margin-bottom: 4px;
}

.card-en {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.reader-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 26px;
}

.reader-top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.reader-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.9rem;
  color: var(--accent-deep);
  margin: 0 0 6px;
}

.reader-subtitle {
  color: var(--text-muted);
  font-size: 0.96rem;
  font-style: italic;
  margin: 0;
}

.yield-pill {
  display: inline-block;
  margin-top: 12px;
  background: var(--saffron);
  padding: 4px 13px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #2c240d;
  font-weight: 700;
}

.reader-body p {
  margin: 0 0 15px;
  font-size: 1.03rem;
}

.recipe-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 24px 0;
  box-shadow: var(--shadow);
}

.recipe-box h2 {
  font-family: 'Noto Serif KR', serif;
  margin: 0 0 14px;
  font-size: 1.15rem;
  color: var(--accent-deep);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--surface-alt);
  padding-bottom: 8px;
}

.ingredient-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ingredient-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 8px 6px;
  border-bottom: 1px dashed var(--border);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.ingredient-item:last-child {
  border-bottom: none;
}

.ingredient-item input[type="checkbox"] {
  margin-top: 5px;
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.ingredient-item.checked span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.step-list {
  padding-left: 22px;
  margin: 0;
}

.step-list li {
  margin-bottom: 14px;
  padding-left: 4px;
}

.step-list li::marker {
  color: var(--tomato);
  font-weight: 700;
}

.note-box {
  background: #fdf4e1;
  border-left: 4px solid var(--saffron);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 10px;
  margin: 20px 0;
  font-size: 0.94rem;
}

.original-panel {
  background: #f6f4ec;
  border: 1px dashed #b9b39d;
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 24px;
  font-size: 0.94rem;
  color: #363c35;
}

.original-panel h3 {
  font-family: 'Noto Serif KR', serif;
  margin: 0 0 12px;
  font-size: 0.98rem;
  color: var(--accent-deep);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.pager a {
  text-decoration: none;
  color: var(--accent-deep);
  font-weight: 700;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  max-width: 48%;
  box-shadow: var(--shadow);
}

.pager a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pending-box {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  color: var(--text-muted);
}

.mobile-only { display: none; }

@media (max-width: 860px) {
  .mobile-only { display: inline-block; }
  .sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    z-index: 50;
    transition: left 0.2s ease;
  }
  .sidebar.open {
    left: 0;
  }
  .search-wrap input {
    width: 150px;
  }
  .main-content {
    padding: 20px 16px 52px;
  }
}
