:root {
  /* A4 paper tone — almost white, very subtle warm tint */
  --bg: #fdfcf8;
  --paper: #ffffff;
  --text: #2a2824;
  --text-muted: rgba(42, 40, 36, 0.62);
  --text-subtle: rgba(42, 40, 36, 0.38);
  --border: rgba(42, 40, 36, 0.12);
  --hover: rgba(42, 40, 36, 0.05);
  --card-bg: #ffffff;
  --card-shadow: rgba(15, 15, 15, 0.07) 0px 0px 0px 1px, rgba(15, 15, 15, 0.08) 0px 3px 8px;
  --card-shadow-hover: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, rgba(15, 15, 15, 0.14) 0px 10px 24px;
  --blue: rgb(35, 131, 226);
  --radius: 14px;

  /* Stronger tag palette — solid, not transparent */
  --tag-default-bg: #e7e3d8;
  --tag-gray-bg:    #d8d5cc;
  --tag-brown-bg:   #e6cdb8;
  --tag-orange-bg:  #f5c89a;
  --tag-yellow-bg:  #f3dc8b;
  --tag-green-bg:   #b6d9a7;
  --tag-blue-bg:    #a7c8e5;
  --tag-purple-bg:  #cbb6e0;
  --tag-pink-bg:    #e8b4cb;
  --tag-red-bg:     #f0b2a7;

  --tag-text: #2a2824;

  --mode-icon-light-display: inline;
  --mode-icon-dark-display: none;
}

html[data-mode="dark"] {
  --bg: #1c1a16;
  --paper: #24211c;
  --text: #ece6d6;
  --text-muted: rgba(236, 230, 214, 0.65);
  --text-subtle: rgba(236, 230, 214, 0.4);
  --border: rgba(236, 230, 214, 0.14);
  --hover: rgba(236, 230, 214, 0.06);
  --card-bg: #2a2620;
  --card-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.4);
  --card-shadow-hover: 0 0 0 1px rgba(236, 230, 214, 0.2), 0 14px 30px rgba(0,0,0,0.5);
  --blue: #7ab5ff;

  --tag-default-bg: #3a3429;
  --tag-gray-bg:    #3a3429;
  --tag-brown-bg:   #6b4e33;
  --tag-orange-bg:  #8a5223;
  --tag-yellow-bg:  #8a6f1a;
  --tag-green-bg:   #2f6a3e;
  --tag-blue-bg:    #2a4f82;
  --tag-purple-bg:  #513770;
  --tag-pink-bg:    #6f2f55;
  --tag-red-bg:     #7a3228;

  --tag-text: #ece6d6;

  --mode-icon-light-display: none;
  --mode-icon-dark-display: inline;
}

* { box-sizing: border-box; }

/* Text IS selectable (so copying a single name / link works).
   Friction comes from JS: blocked right-click, blocked Ctrl+A/S/U.
   Drag-save of images is still blocked. */
img { -webkit-user-drag: none; user-drag: none; pointer-events: auto; }

html, body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Page header ---------- */

.page-header {
  max-width: 1400px;
  margin: 0 auto;
  padding: 64px 96px 0 96px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.page-icon {
  font-size: 38px;
  line-height: 1;
}

.page-header h1 {
  font-size: 40px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.view-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.tab {
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.1s;
  position: relative;
  bottom: -1px;
  border-bottom: 2px solid transparent;
}
.tab:hover { background: var(--hover); }
.tab.active {
  color: var(--text);
  font-weight: 500;
  border-bottom-color: var(--text);
}
.tab-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* Saved view sub-toggle */
.saved-sub-toggle {
  display: flex;
  gap: 6px;
  margin: 0 0 18px 0;
}
.saved-pill {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
}
.saved-pill:hover { color: var(--text); background: var(--hover); }
.saved-pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; opacity: 0.4; margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-hint { font-size: 14px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 16px 0;
  gap: 12px;
}

.filter-bar {
  display: flex;
  gap: 4px;
}

.filter-add, .sort-add {
  color: var(--text-subtle);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  user-select: none;
}
.filter-add:hover, .sort-add:hover { background: var(--hover); color: var(--text); }
.sort-add.active { background: var(--tag-orange-bg); color: var(--text); }

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#search {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  width: 220px;
  outline: none;
  transition: border-color 0.15s;
}
#search:focus { border-color: var(--blue); }

.theme-picker {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-right: 4px;
}
.theme-btn {
  background: transparent;
  border: none;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.theme-btn:last-child { border-right: none; }
.theme-btn:hover { background: var(--hover); }
.theme-btn.active {
  background: var(--text);
  color: var(--bg);
}

.mode-toggle {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 90;
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  transition: transform 0.15s, background 0.15s;
}
.mode-toggle:hover { background: var(--hover); transform: scale(1.08); }
.mode-icon-light { display: var(--mode-icon-light-display); }
.mode-icon-dark { display: var(--mode-icon-dark-display); }

.channel-thumb-link {
  display: inline-block;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 3px;
  transition: box-shadow 0.15s, transform 0.15s;
  line-height: 0;
  cursor: zoom-in;
}
.channel-thumb-link:hover {
  box-shadow: 0 0 0 2px var(--blue);
  transform: scale(1.03);
}
.channel-thumb-link img { display: block; border-radius: 3px; }

.new-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.new-btn:hover { filter: brightness(1.05); }
.caret { font-size: 10px; opacity: 0.8; }

/* ---------- Main area ---------- */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 96px 8px 96px;
}

/* ---------- Gallery view ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.card-image-wrap {
  position: relative;
}

/* ---- Skeleton loading cards (YouTube-style shimmer) ---- */

.skeleton { pointer-events: none; }
.skeleton .skeleton-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
}
.skeleton-img,
.skeleton-line,
.skeleton-tags span {
  background: linear-gradient(90deg,
    var(--hover) 0%,
    var(--border) 40%,
    var(--hover) 80%);
  background-size: 200% 100%;
  animation: nh-shimmer 1.4s infinite linear;
  border-radius: 4px;
}
.skeleton-line {
  height: 12px;
  margin-bottom: 7px;
}
.skeleton-line.short { width: 55%; }
.skeleton-title {
  height: 18px;
  width: 75%;
  margin-bottom: 14px;
}
.skeleton-tags {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.skeleton-tags span {
  width: 70px;
  height: 18px;
  border-radius: 999px;
}

@keyframes nh-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Per-image loading (pulse until image loads, then fade in) ---- */

.card-image-wrap.img-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    var(--hover) 0%,
    var(--border) 40%,
    var(--hover) 80%);
  background-size: 200% 100%;
  animation: nh-shimmer 1.4s infinite linear;
  z-index: 0;
}
.card-image-wrap img {
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease-out;
}
.card-image-wrap:not(.img-loading) img {
  opacity: 1;
}

.card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: top;
  background: #f1f0ee;
  display: block;
  border-bottom: 1px solid var(--border);
}

.flag-buttons {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 3;
}

.flag-btn {
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
  border: 1px solid rgba(0,0,0,0.08);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.12s, background 0.12s;
}
html[data-mode="dark"] .flag-btn {
  background: rgba(40, 38, 34, 0.92);
  color: var(--text);
  border-color: rgba(255,255,255,0.1);
}
.flag-btn:hover { transform: scale(1.12); }
.flag-btn .flag-icon-on  { display: none; }
.flag-btn .flag-icon-off { display: inline; }
.flag-btn.on .flag-icon-on  { display: inline; }
.flag-btn.on .flag-icon-off { display: none; }
.flag-btn.flag-bm.on    { background: #ffc33c; color: #4a2f00; border-color: #ffc33c; }
.flag-btn.just-clicked { transform: scale(1.25); }

/* Like button at bottom of card body, with count */
.like-row {
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  align-items: center;
}
.like-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform 0.12s, background 0.12s, color 0.12s, border-color 0.12s;
  font-variant-numeric: tabular-nums;
}
.like-btn:hover { color: var(--text); background: var(--hover); }
.like-btn .flag-icon-on  { display: none; font-size: 15px; line-height: 1; }
.like-btn .flag-icon-off { display: inline; font-size: 15px; line-height: 1; }
.like-btn.on .flag-icon-on  { display: inline; }
.like-btn.on .flag-icon-off { display: none; }
.like-btn.on {
  background: rgba(255, 91, 110, 0.12);
  color: #ff5b6e;
  border-color: rgba(255, 91, 110, 0.4);
}
.like-btn.just-clicked { transform: scale(1.08); }

/* Table flags (like + bookmark inline) */
.cell-flags-row { display: flex; gap: 4px; }
.cell-flags .flag-btn {
  width: 26px; height: 26px; font-size: 14px;
  background: transparent; border: 1px solid var(--border); box-shadow: none;
}
.cell-flags .flag-like-sm.on { background: rgba(255, 91, 110, 0.15); color: #ff5b6e; border-color: rgba(255, 91, 110, 0.5); }
.cell-flags .flag-bm.on { background: #ffc33c; color: #4a2f00; border-color: #ffc33c; }

.card-body {
  padding: 14px 16px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.card-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--tag-default-bg);
  color: var(--tag-text);
  line-height: 1.5;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-gray    { background: var(--tag-gray-bg); }
.tag-brown   { background: var(--tag-brown-bg); }
.tag-orange  { background: var(--tag-orange-bg); }
.tag-yellow  { background: var(--tag-yellow-bg); }
.tag-green   { background: var(--tag-green-bg); }
.tag-blue    { background: var(--tag-blue-bg); }
.tag-purple  { background: var(--tag-purple-bg); }
.tag-pink    { background: var(--tag-pink-bg); }
.tag-red     { background: var(--tag-red-bg); }

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Table view ---------- */

.table-scroll {
  overflow: scroll;
  max-height: calc(100vh - 270px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--paper);
  scrollbar-width: auto;
  scrollbar-color: var(--text-muted) var(--hover);
  overflow-anchor: none;        /* kill browser scroll-anchor teleport */
  scroll-behavior: auto;        /* no smooth animation that can overshoot */
}
.table-scroll * { overflow-anchor: none; }

/* Chrome / Edge / Safari — always-visible, Notion-style fat scrollbar with arrows */
.table-scroll::-webkit-scrollbar {
  height: 16px;
  width: 16px;
  background: var(--hover);
}
.table-scroll::-webkit-scrollbar-track {
  background: var(--hover);
}
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--text-subtle);
  border-radius: 8px;
  min-height: 50px;
  min-width: 50px;
}
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.table-scroll::-webkit-scrollbar-thumb:active { background: var(--text); }
.table-scroll::-webkit-scrollbar-corner { background: var(--hover); }

/* Arrow buttons at the ends (Notion-style) */
.table-scroll::-webkit-scrollbar-button:single-button {
  background: var(--hover);
  display: block;
  height: 16px;
  width: 16px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 8px 8px;
}
.table-scroll::-webkit-scrollbar-button:single-button:hover {
  background-color: var(--border);
}
.table-scroll::-webkit-scrollbar-button:horizontal:single-button:decrement {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M6 1L2 4l4 3' fill='none' stroke='%238b90a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.table-scroll::-webkit-scrollbar-button:horizontal:single-button:increment {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M2 1l4 3-4 3' fill='none' stroke='%238b90a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.table-scroll::-webkit-scrollbar-button:vertical:single-button:decrement {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M1 6l3-4 3 4' fill='none' stroke='%238b90a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.table-scroll::-webkit-scrollbar-button:vertical:single-button:increment {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M1 2l3 4 3-4' fill='none' stroke='%238b90a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.table-scroll::-webkit-scrollbar-button:double-button,
.table-scroll::-webkit-scrollbar-button:start:increment,
.table-scroll::-webkit-scrollbar-button:end:decrement {
  display: none;
}

/* Sticky header so column labels stay visible while scrolling rows */
.table-scroll table.channels-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
}

table.channels-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
  contain: layout style;        /* isolate reflow inside the table */
}

table.channels-table th,
table.channels-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

table.channels-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: var(--paper);
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  letter-spacing: 0.02em;
}

table.channels-table a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--blue) 45%, transparent);
  padding-bottom: 1px;
}
table.channels-table a:hover {
  border-bottom-color: var(--blue);
}

table.channels-table tbody tr { cursor: pointer; }
table.channels-table tbody tr:hover { background: var(--hover); }

table.channels-table td.cell-image img {
  width: 40px;
  height: 24px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

table.channels-table td.cell-name {
  font-weight: 500;
}
.row-icon { color: var(--text-subtle); margin-right: 6px; }

/* ---------- Modal (detail) ---------- */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  z-index: 100;
  overflow-y: auto;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.4);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  max-width: 900px;
  width: 100%;
  background: var(--paper);
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.25);
  padding: 56px 72px 72px 72px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  line-height: 1;
}
.modal-close:hover { background: var(--hover); }

.modal-title {
  font-size: 40px;
  font-weight: 700;
  margin: 0 0 24px 0;
  letter-spacing: -0.02em;
}

.properties {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 6px 12px;
  font-size: 14px;
  margin-bottom: 24px;
}

.prop-label {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 4px;
}

.prop-value {
  padding: 4px 6px;
  border-radius: 4px;
}
.prop-value a { color: inherit; text-decoration: underline; }

.prop-value .tag { font-size: 13px; padding: 2px 8px; }

.prop-value.channel-thumb img {
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: 3px;
}

.body-section {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.7;
}
.body-section p { margin: 0.15em 0; }
.body-section p.section-head {
  font-weight: 600;
  margin-top: 1em;
}
.body-empty {
  color: var(--text-subtle);
  font-style: italic;
}

.prop-icon { opacity: 0.5; font-size: 14px; }

/* ---------- Responsive ---------- */

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}
.lightbox.hidden { display: none; }
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.85);
  cursor: zoom-out;
}
.lightbox img {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  background: #222;
}
.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  z-index: 201;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ---------- Filter panel ---------- */

.filter-add.active {
  background: var(--tag-blue-bg);
  color: var(--text);
}

.filter-panel {
  position: absolute;
  z-index: 150;
  background: var(--paper);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.15);
  padding: 14px 16px;
  width: 420px;
  max-width: 92vw;
  max-height: 70vh;
  overflow-y: auto;
}
.filter-panel.hidden { display: none; }
.filter-group { margin-bottom: 14px; }
.filter-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.filter-chip {
  cursor: pointer;
  border: 1px solid transparent;
  opacity: 0.65;
  transition: opacity 0.1s, border-color 0.1s;
}
.filter-chip:hover { opacity: 1; }
.filter-chip.selected {
  opacity: 1;
  border-color: var(--text);
  font-weight: 500;
}
.sort-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.sort-row {
  display: grid;
  grid-template-columns: 16px 1fr 140px 24px;
  gap: 6px;
  align-items: center;
}
.sort-drag {
  color: var(--text-subtle);
  cursor: grab;
  font-size: 11px;
  text-align: center;
  line-height: 1;
}
.sort-select {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.sort-select:focus { border-color: var(--blue); }
.sort-remove {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 16px;
  cursor: pointer;
  width: 24px; height: 24px;
  border-radius: 4px;
  line-height: 1;
}
.sort-remove:hover { background: var(--hover); color: var(--text); }

.sort-add-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.sort-add-btn {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.sort-add-btn:hover { border-style: solid; color: var(--text); background: var(--hover); }

.filter-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  justify-content: flex-end;
}
.filter-clear {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}
.filter-clear:hover { background: var(--hover); }

@media (max-width: 900px) {
  .page-header, main { padding-left: 24px; padding-right: 24px; }
  .modal-card { padding: 40px 24px; }
  .properties { grid-template-columns: 140px 1fr; }
  .modal-title { font-size: 30px; }
}
