:root {
  --bg: #f3f1eb;
  --surface: #fbfaf6;
  --surface-strong: #ffffff;
  --ink: #20231f;
  --muted: #6e746c;
  --line: #dcdcd2;
  --accent: #b63e2e;
  --accent-soft: #f4ddd7;
  --green: #344e41;
  --shadow: 0 16px 42px rgba(39, 43, 37, 0.12);
  --radius: 14px;
  --sidebar-width: 288px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.topbar-actions { display: flex; gap: 12px; align-items: center; justify-content: flex-end; }
.verification-button { flex-shrink: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer; font-size: 12px; }
.verification-dialog { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 24px; border: 0; border-radius: 14px; background: var(--surface); }
.verification-dialog::backdrop { background: rgba(25, 28, 24, .6); }
.verification-dialog h2 { margin-right: 30px; }
#verification-content { font-size: 13px; }
.verification-row { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.verification-row > div > button { padding: 0; border: 0; background: none; color: var(--green); cursor: pointer; font-weight: 650; text-align: left; }
.verification-row small { display: block; margin-top: 4px; color: var(--muted); }
.verification-coverage { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.verification-coverage > summary, .verification-category > summary { cursor: pointer; font-weight: 700; }
.verification-category { padding: 8px 0; border-top: 1px solid var(--line); }
.verification-card-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 2px; }
.verification-card-links button { padding: 5px 7px; border: 0; border-radius: 6px; background: var(--accent-soft); color: #74281e; cursor: pointer; font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 74px;
  display: grid;
  grid-template-columns: 260px minmax(280px, 660px) 1fr;
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  background: rgba(251, 250, 246, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: white; font: 700 21px Georgia, serif; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 18px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.search-wrap { position: relative; }
.search-wrap input { width: 100%; height: 44px; padding: 0 50px 0 17px; border: 1px solid var(--line); border-radius: 10px; background: white; outline: none; }
.search-wrap input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 78, 65, .12); }
.search-wrap kbd { position: absolute; right: 12px; top: 10px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--surface); }
.dataset-stats { justify-self: end; color: var(--muted); font-size: 13px; }
.search-results { position: absolute; top: 51px; left: 0; right: 0; max-height: 70vh; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.search-group + .search-group { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.search-group > strong { display: block; padding: 6px 9px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
.search-group button { display: flex; justify-content: space-between; width: 100%; border: 0; border-radius: 7px; background: none; padding: 8px 9px; cursor: pointer; text-align: left; }
.search-group button:hover { background: var(--bg); }
.search-group small { color: var(--muted); }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: calc(100vh - 74px); }
.sidebar { position: sticky; top: 74px; display: flex; flex-direction: column; height: calc(100vh - 74px); min-width: 190px; max-width: 520px; overflow: hidden; padding: 23px 15px 40px; border-right: 1px solid var(--line); background: #eae8e0; }
#tag-tree { flex: 1; overflow: auto; }
.sidebar-resizer { position: absolute; z-index: 3; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; transition: background .15s; }
.sidebar-resizer:hover, .sidebar-resizer.resizing { background: rgba(182, 62, 46, .28); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 15px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.icon-button { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer; }
#tag-tree details { margin: 1px 0; }
.tree-section-heading { margin: 0 8px 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
#tag-tree summary { display: flex; align-items: center; list-style: none; }
#tag-tree summary::-webkit-details-marker { display: none; }
.tree-chevron { flex: 0 0 20px; color: #8b8e87; text-align: center; transition: transform .15s; }
details[open] > summary .tree-chevron { transform: rotate(90deg); }
#tag-tree .tree-link { flex: 1; display: flex; min-width: 0; justify-content: space-between; gap: 7px; padding: 7px 5px 7px 8px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; text-align: left; }
#tag-tree .tree-link:hover, #tag-tree .tree-link.active { background: var(--surface-strong); }
#tag-tree .tree-link.active { color: var(--accent); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
#tag-tree .tree-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tag-tree .favorite-toggle { flex: 0 0 25px; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #aaa79d; cursor: pointer; opacity: .45; }
#tag-tree summary:hover .favorite-toggle, #tag-tree .favorite-toggle:focus-visible, #tag-tree .favorite-toggle.active { opacity: 1; }
#tag-tree .favorite-toggle:hover,
#tag-tree .favorite-toggle:focus-visible,
#tag-tree .favorite-toggle.active {
  background: #fff3bf;
  color: #d39100;
  box-shadow: 0 0 0 1px rgba(211, 145, 0, .2), 0 0 9px rgba(235, 176, 29, .72);
  text-shadow: 0 0 4px rgba(255, 196, 47, .9);
}
#tag-tree .drag-handle { flex: 0 0 18px; color: #99968d; cursor: grab; font-size: 17px; line-height: 25px; text-align: center; user-select: none; }
#tag-tree .drag-handle:active { cursor: grabbing; }
#tag-tree details[data-favorite-root] { transition: opacity .12s, transform .12s, box-shadow .12s; }
#tag-tree details[data-favorite-root].dragging { opacity: .32; transform: scale(.985); }
#tag-tree details[data-favorite-root].drop-before { box-shadow: 0 -3px 0 var(--accent); }
#tag-tree details[data-favorite-root].drop-after { box-shadow: 0 3px 0 var(--accent); }
#tag-tree summary small { color: var(--muted); font-variant-numeric: tabular-nums; }
.tree-children { margin-left: 16px; border-left: 1px solid #d4d2ca; padding-left: 2px; }
#tag-tree .category-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
#tag-tree .category-section > summary {
  margin: 0 8px 7px;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.category-section-empty { margin: 8px 28px; color: var(--muted); font-size: 11px; }

.main-content { min-width: 0; padding: 36px clamp(22px, 4vw, 60px) 80px; }
.context-header { max-width: 1320px; margin: 0 auto 26px; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 24px; margin-bottom: 15px; font-size: 12px; color: var(--muted); }
.breadcrumbs button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--green); }
.breadcrumbs i { font-style: normal; color: #aaa; }
.title-row { display: flex; justify-content: space-between; align-items: end; gap: 25px; }
.title-actions { display: flex; flex-shrink: 0; align-items: center; gap: 14px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(34px, 4vw, 52px); font-weight: 500; letter-spacing: -.035em; }
.view-title-row { display: flex; align-items: flex-start; gap: 10px; }
.view-result-count { margin-top: 5px; color: var(--ink); font-size: 14px; font-weight: 750; white-space: nowrap; }
.view-favorite-toggle { align-self: center; flex: 0 0 38px; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #aaa79d; cursor: pointer; font-size: 24px; line-height: 1; opacity: .55; }
.view-favorite-toggle:hover,
.view-favorite-toggle:focus-visible,
.view-favorite-toggle.active {
  background: #fff3bf;
  color: #d39100;
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(211, 145, 0, .2), 0 0 9px rgba(235, 176, 29, .72);
  text-shadow: 0 0 4px rgba(255, 196, 47, .9);
}
.description { max-width: 760px; margin: 11px 0 0; color: var(--muted); line-height: 1.55; }
.tagger-link, .primary-link { color: var(--accent); font-weight: 650; text-decoration: none; white-space: nowrap; }
.secondary-button, .primary-button { padding: 9px 12px; border-radius: 8px; cursor: pointer; font-weight: 650; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); }
.primary-button { border: 1px solid var(--green); background: var(--green); color: white; }
.danger-button { padding: 9px 12px; border: 1px solid #c9867d; border-radius: 8px; background: #fff4f1; color: var(--accent); cursor: pointer; font-weight: 650; }
.card-category-button { margin: 0 12px 12px 0; }
.child-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 23px; }
.child-tags button { display: inline-flex; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.child-tags button:hover { border-color: var(--green); }
.child-tags small { color: var(--muted); }

.toolbar { position: sticky; top: 74px; z-index: 10; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 10px; max-width: 1320px; margin: 0 auto 24px; padding: 12px 0; background: rgba(243, 241, 235, .94); backdrop-filter: blur(10px); }
.toolbar-row, .toolbar-primary-controls, .toolbar-toggles { display: contents; }
.toolbar label { display: grid; justify-items: center; gap: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.toolbar select { width: 172px; height: 34px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 28px 0 8px; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.toolbar .text-filter { display: grid; gap: 3px; }
.toolbar .text-filter input { width: 138px; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); outline: none; }
.toolbar .subtype-filter input { width: 112px; }
.toolbar .text-filter input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 78, 65, .1); }
.identity-filter { display: grid; flex: 0 0 auto; justify-items: center; gap: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.color-filter { display: flex; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.color-filter button { display: grid; width: 31px; height: 32px; overflow: hidden; place-items: center; border: 0; border-right: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 12px; line-height: 1; }
.color-filter .color-preset { width: 31px; min-width: 31px; padding: 0; font-size: 11px; font-weight: 750; }
.color-filter .identity-all { width: auto; min-width: 58px; padding: 0 9px; font-size: 10px; }
.color-filter button:last-child { border-right: 0; }
.identity-filter button.active { background: var(--green); color: white; }
.toggle { width: 76px; grid-template-rows: minmax(26px, auto) 34px; align-items: center; }
.toggle span { grid-row: 1; align-self: end; line-height: 1.12; text-align: center; white-space: normal; }
.toggle input { grid-row: 2; align-self: center; margin: 0; accent-color: var(--accent); }
.toggle-label { position: relative; cursor: help; text-decoration: underline dotted rgba(91, 92, 84, .55); text-underline-offset: 3px; }
.toggle-label::after { position: absolute; z-index: 40; top: calc(100% + 8px); left: 50%; width: max-content; max-width: min(260px, calc(100vw - 32px)); padding: 8px 10px; visibility: hidden; border: 1px solid rgba(35, 38, 32, .14); border-radius: 8px; background: rgba(35, 38, 32, .94); color: white; box-shadow: var(--shadow); content: attr(data-tooltip); font-size: 11px; font-weight: 500; line-height: 1.35; opacity: 0; pointer-events: none; text-align: left; text-decoration: none; transform: translateX(-50%) translateY(-2px); transition: opacity .14s, transform .14s, visibility .14s; white-space: normal; }
.toggle-label:hover::after, .toggle-label:focus-visible::after { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(0); }
.toggle:last-child .toggle-label::after { right: 0; left: auto; transform: translateY(-2px); }
.toggle:last-child .toggle-label:hover::after, .toggle:last-child .toggle-label:focus-visible::after { transform: translateY(0); }
.filter-control { display: flex; align-items: center; gap: 4px; }
.filter-popover { position: relative; }
.filter-popover > summary { display: flex; height: 34px; align-items: center; overflow: hidden; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); cursor: pointer; font-size: 12px; line-height: 1; list-style: none; white-space: nowrap; }
.filter-popover > summary::-webkit-details-marker { display: none; }
.filter-popover > summary::after { content: " ▾"; color: var(--muted); }
.filter-popover[open] > summary { border-color: var(--green); }
.filter-panel { position: absolute; z-index: 20; top: calc(100% + 7px); right: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.range-filter-panel { display: grid; width: 370px; gap: 10px; }
.range-filter-panel label { display: grid; grid-template-columns: 120px 1fr 10px 1fr; gap: 7px; }
.range-filter-panel label > span { color: var(--ink); }
.range-filter-panel i { align-self: center; color: var(--muted); font-style: normal; text-align: center; }
.range-filter-panel input { width: 100%; min-width: 0; height: 32px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); }
.filter-reset { display: grid; width: 34px; height: 34px; flex: 0 0 34px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.filter-reset:hover, .filter-reset:focus-visible { background: var(--accent-soft); color: var(--accent); }
.type-filter-panel { width: 310px; }
.filter-presets { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 10px; }
.filter-presets button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.type-chip-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.type-chip-grid button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); cursor: pointer; font-size: 12px; }
.type-chip-grid button::before { content: "✓ "; opacity: 0; }
.type-chip-grid button.active { border-color: var(--green); background: #e6efe8; color: var(--green); }
.type-chip-grid button.active::before { opacity: 1; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 22px; max-width: 1320px; margin: auto; }
.card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-strong); box-shadow: 0 4px 15px rgba(35, 38, 32, .055); cursor: pointer; transition: transform .16s, box-shadow .16s; }
.card:hover, .card:focus-visible { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(35, 38, 32, .13); outline: none; }
.card-image-wrap { position: relative; aspect-ratio: 488 / 680; overflow: hidden; background: #d8d6cd; }
.card-image-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-image-wrap img.failed-image, .detail-image img.failed-image { visibility: hidden; }
.image-placeholder { display: grid; height: 100%; place-items: center; color: var(--muted); }
.ranking-badges { position: absolute; bottom: 10px; left: 10px; display: flex; max-width: calc(100% - 64px); align-items: center; gap: 5px; }
.edhrec-badge, .cedh-badge, .power-badge, .bracket-playrate-badge { padding: 5px 8px; border-radius: 6px; color: white; font-size: 10px; font-weight: 750; backdrop-filter: blur(5px); }
.bracket-playrate-badge { background: rgba(85, 59, 20, .92); white-space: nowrap; }
.edhrec-badge { background: rgba(27, 30, 26, .88); white-space: nowrap; }
.cedh-badge { display: inline-grid; min-width: 24px; padding: 4px 5px; place-items: center; background: rgba(143, 44, 24, .92); font-size: 14px; line-height: 1; }
.power-badge { position: absolute; top: 10px; right: 10px; background: rgba(182, 62, 46, .92); }
.card-copy { padding: 13px 14px 14px; }
.card-name-row { display: flex; justify-content: space-between; align-items: start; gap: 7px; }
.card h2 { overflow: hidden; margin: 0; font-family: Georgia, serif; font-size: 17px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.card p { overflow: hidden; margin: 6px 0 14px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.card-metrics { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.card-metrics strong { color: var(--ink); }
.mana { display: inline-grid; width: 19px; height: 19px; margin-left: 2px; place-items: center; border-radius: 50%; background: #ddd9ca; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); font-size: 9px; font-weight: 800; }
.loading-state { padding: 60px; text-align: center; color: var(--muted); }
.empty-state { grid-column: 1 / -1; display: grid; gap: 7px; padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font-family: Georgia, serif; font-size: 25px; }
.load-more { display: block; min-width: 220px; margin: 35px auto 0; padding: 12px 20px; border: 1px solid var(--green); border-radius: 9px; background: var(--green); color: white; cursor: pointer; }

.card-dialog { width: min(920px, calc(100vw - 34px)); max-height: calc(100vh - 34px); padding: 0; overflow: auto; border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.card-dialog::backdrop { background: rgba(25, 28, 24, .68); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; z-index: 2; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); cursor: pointer; font-size: 24px; }
.detail-layout { display: grid; grid-template-columns: minmax(280px, 40%) 1fr; }
.detail-layout.dual { grid-template-columns: minmax(440px, 56%) 1fr; }
.detail-image { display: flex; min-width: 0; min-height: 0; align-items: center; justify-content: center; padding: 14px; background: #282b27; }
.detail-image img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100vh - 62px); object-fit: contain; }
.detail-image.multiple { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: center; gap: 10px; padding: 12px; }
.detail-image.multiple img { width: 100%; height: auto; max-height: calc(100vh - 82px); object-fit: contain; }
.detail-copy { padding: 42px; overflow: auto; }
.detail-copy h2 { margin: 0; font: 500 35px/1.05 Georgia, serif; }
.detail-mana { margin: 12px 0 20px; }
.oracle-text { line-height: 1.55; white-space: normal; }
.stats-list { display: grid; grid-template-columns: 1fr 1fr; margin: 25px 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.stats-list div { padding: 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats-list dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.stats-list dd { margin: 4px 0 0; font-weight: 700; }
.detail-section { margin: 24px 0; }
.detail-section h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-list button, .tag-list span { padding: 7px 9px; border: 0; border-radius: 7px; background: var(--accent-soft); color: #74281e; cursor: pointer; font-size: 12px; }
.tag-list.muted span { background: #e5e4dd; color: var(--ink); cursor: default; }

.category-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 26px; border: 0; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.category-dialog::backdrop { background: rgba(25, 28, 24, .6); }
.category-dialog h2 { margin: 0 42px 6px 0; font: 500 28px Georgia, serif; }
.category-dialog > p { color: var(--muted); line-height: 1.45; }
.virtual-category-list { display: grid; max-height: 240px; margin: 18px 0; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.virtual-category-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px 9px 12px; border-bottom: 1px solid var(--line); background: white; }
.virtual-category-row:last-child { border-bottom: 0; }
.virtual-category-row > span { display: grid; min-width: 0; gap: 2px; }
.virtual-category-row strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.virtual-category-row button { flex: 0 0 auto; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 12px; }
.virtual-category-row button:hover { border-color: var(--green); }
.virtual-category-row .remove-category-button { color: var(--accent); }
.virtual-category-list small { color: var(--muted); }
.new-category-form { display: grid; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.new-category-form h3 { margin: 0; font-size: 14px; }
.new-category-form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.new-category-form input, .new-category-form textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--ink); resize: vertical; }
.new-category-form .primary-button { justify-self: start; }
.form-status { min-height: 20px; margin-bottom: 0; color: var(--accent) !important; font-size: 13px; }
.dashboard-status { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(380px, calc(100vw - 44px)); padding: 11px 14px; border-radius: 9px; background: var(--green); color: white; box-shadow: var(--shadow); font-size: 13px; font-weight: 650; }
.dashboard-status.error { border: 1px solid rgba(161, 50, 37, .28); background: rgba(161, 50, 37, .9); }
.clipboard-buffer { position: fixed; opacity: 0; pointer-events: none; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px clamp(22px, 4vw, 60px); border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 18px; }
.site-footer a { color: var(--green); text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

.legal-page { min-height: 100vh; }
.legal-topbar { position: static; grid-template-columns: 1fr auto; height: 74px; }
.legal-topbar .brand { color: var(--ink); text-decoration: none; }
.legal-back-link { color: var(--green); font-size: 13px; font-weight: 700; text-decoration: none; }
.legal-back-link:hover, .legal-back-link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.legal-content { width: min(820px, calc(100% - 36px)); margin: 0 auto; padding: 64px 0 80px; }
.legal-content h1 { margin-bottom: 12px; }
.legal-content h2 { margin: 38px 0 12px; font: 500 25px/1.2 Georgia, serif; }
.legal-content h3 { margin: 25px 0 8px; font-size: 15px; }
.legal-content p, .legal-content li, .legal-content address { color: #444941; line-height: 1.7; }
.legal-content address { font-style: normal; }
.legal-content a { color: var(--green); }
.legal-content ul { padding-left: 22px; }
.legal-meta { margin: 0 0 36px; color: var(--muted) !important; font-size: 13px; }
.legal-card { padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.legal-content code { padding: 2px 5px; border-radius: 4px; background: #e9e7df; font-size: .9em; }

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 16px; }
  .brand small, .dataset-stats { display: none; }
  .app-shell { display: block; }
  .sidebar { position: relative; top: 0; width: 100%; height: auto; max-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-resizer { display: none; }
  .toolbar { top: 74px; }
}

@media (max-width: 620px) {
  .brand strong { display: none; }
  .topbar { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; }
  .main-content { padding: 25px 14px 60px; }
  .title-row { display: block; }
  .title-actions { align-items: flex-start; flex-direction: column; gap: 10px; margin-top: 18px; }
  .toolbar { gap: 10px; }
  .filter-panel { position: fixed; top: 150px; right: 14px; left: 14px; width: auto; }
  .toggle { width: 100%; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-copy { padding: 10px; }
  .card h2 { font-size: 14px; }
  .card-name-row > div, .card p { display: none; }
  .card-metrics { margin-top: 8px; }
  .detail-layout { display: block; }
  .detail-layout.dual { display: block; }
  .detail-image { min-height: auto; }
  .detail-image.multiple { grid-template-columns: 1fr; }
  .detail-image.multiple img { max-height: none; }
  .detail-copy { padding: 28px 20px; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .site-footer nav { justify-content: flex-start; }
  .legal-topbar { display: flex; justify-content: space-between; }
  .legal-topbar .brand strong { display: block; }
  .legal-content { padding-top: 42px; }
}
