/* ===== Design tokens (Linear style) ===== */
:root {
  --primary: #5e6ad2;
  --primary-hover: #4d59c9;
  --primary-soft: rgba(94, 106, 210, 0.1);
  --primary-ring: rgba(94, 106, 210, 0.18);

  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --surface-hover: #f5f6f8;
  --card: #ffffff;

  --text: #16181d;
  --text-2: #51555e;
  --muted: #8a8f98;
  --border: #e6e8eb;
  --border-strong: #d6d9de;

  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.1);

  --shadow-sm: 0 1px 2px rgba(16, 18, 23, 0.04), 0 1px 3px rgba(16, 18, 23, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 18, 23, 0.08);
  --shadow-lg: 0 16px 48px rgba(16, 18, 23, 0.16);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --view-size: 100;
  --view-text-min: 12px;
  --view-text-max: 22px;

  --topbar-h: 82px;
  --sidebar-w: 280px;
  --feed-sidebar-w: 300px;
  --link-detail-h: 240px;

  --ease: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --primary: #7c84e8;
  --primary-hover: #8b93f0;
  --primary-soft: rgba(124, 132, 232, 0.16);
  --primary-ring: rgba(124, 132, 232, 0.28);

  --bg: #0c0d10;
  --surface: #16181d;
  --surface-2: #1c1f26;
  --surface-hover: #1f232b;
  --card: #16181d;

  --text: #f2f3f5;
  --text-2: #b8bcc4;
  --muted: #7c818c;
  --border: #25282f;
  --border-strong: #32363f;

  --danger: #ff6166;
  --danger-soft: rgba(255, 97, 102, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--ease), color var(--ease);
}

.app { display: flex; flex-direction: column; height: 100vh; }

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: height var(--ease);
  overflow: visible;
}
body.is-resizing-topbar .topbar {
  transition: none;
}
.topbar-inner {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  min-height: 0;
  min-width: 0;
  transition: padding var(--ease), gap var(--ease);
}
.topbar-center {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 8px;
  transition: gap var(--ease), transform var(--ease);
}
.topbar-center .web-search-wrap {
  width: min(calc(560px * 2 / 3), 100%);
  max-width: 100%;
  margin-left: 28px;
}
.topbar .search-input {
  height: 40px;
  font-size: 14px;
  box-sizing: border-box;
}
.web-search-wrap .topbar-hover-icon.link-icon {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: calc(var(--radius-sm, 8px));
  font-size: 13px;
  padding: 0;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  pointer-events: auto;
  opacity: 1;
  box-shadow: inset 0 0 0 1px var(--border);
}
.web-search-wrap .topbar-hover-icon:hover,
.web-search-wrap .topbar-hover-icon[aria-expanded="true"] {
  color: var(--primary);
  background: var(--primary-soft) !important;
}
.web-search-wrap .topbar-hover-icon svg {
  display: block;
  flex-shrink: 0;
}
.web-search-wrap .topbar-hover-icon .link-icon-letter {
  font-size: 13px;
}
.web-pinned-search-menu {
  position: absolute;
  top: calc(50% + 25px);
  left: 50%;
  transform: translateX(calc(-50% + 14px));
  width: min(calc(560px * 2 / 3), calc(100% - 28px));
  max-height: min(320px, calc(100dvh - var(--topbar-h) - 24px));
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  box-shadow: var(--shadow-lg);
  z-index: 130;
}
.web-pinned-search-menu[hidden] {
  display: none;
}
.web-pinned-search-item,
.web-pinned-search-empty {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: transparent;
  text-align: left;
}
.web-pinned-search-item {
  cursor: pointer;
}
.web-pinned-search-item:hover {
  background: var(--surface-hover);
}
.web-pinned-search-item .link-icon {
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  border-radius: 7px;
}
.web-pinned-search-title {
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.web-pinned-search-empty {
  color: var(--muted);
  font-size: 13px;
}
.topbar-resizer {
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
  color: var(--text);
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: min(320px, 36vw);
  min-width: 160px;
}
.search-icon {
  position: absolute; left: 12px; color: var(--muted); pointer-events: none;
}
.search-input {
  width: 100%;
  height: 34px;
  padding: 0 36px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
.web-search-wrap .web-search-input {
  padding-left: calc(68px - 1.5em);
  padding-right: 76px;
}
.web-search-tool-btn {
  position: absolute;
  right: 38px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--ease), background var(--ease);
}
.web-search-tool-btn svg {
  display: block;
  flex-shrink: 0;
}
.web-search-tool-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.web-search-tool-btn.is-active {
  color: var(--primary);
}
.web-search-mode-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--ease), background var(--ease), box-shadow var(--ease);
}
.web-search-mode-btn svg {
  display: block;
  flex-shrink: 0;
}
.web-search-mode-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.web-search-mode-btn.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 28%, transparent);
}
.web-search-mode-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.site-search-mode .web-search-wrap .web-search-input {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}
.search-kbd {
  position: absolute; right: 10px;
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 1px 6px;
  background: var(--surface);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  position: relative;
  z-index: 1;
}

/* ===== Buttons ===== */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
  cursor: pointer;
  transition: background var(--ease), color var(--ease), transform var(--ease);
}
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: none; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--ease), transform var(--ease), box-shadow var(--ease);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost, .btn-danger {
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}
.btn-ghost:active, .btn-danger:active { transform: scale(0.97); }

/* ===== More menu ===== */
.menu-wrap { position: relative; }
.topbar-right > .menu-wrap::after {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: 100%;
  height: 14px;
  z-index: 59;
}
.menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 160px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 60;
  animation: menuIn 0.14s ease;
}
@keyframes menuIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  font-size: 14px; font-family: inherit; cursor: pointer;
  transition: background var(--ease);
}
.menu[hidden] {
  display: none !important;
}
.menu-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}
.menu.more-menu {
  min-width: 120px;
  width: max-content;
  padding: 4px;
}
.menu.more-menu .menu-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 6px 14px;
  white-space: nowrap;
}
.menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--border);
  display: none;
}
.menu.more-menu:has(#forkNavMenuBtn:not([hidden])) .menu-sep,
.menu.more-menu:has(#resetOfficialBtn:not([hidden])) .menu-sep,
.edit-mode .menu.more-menu .menu-sep {
  display: block;
}

/* View menu - click to show */
.view-wrap { position: relative; outline: none; }
.view-float-title {
  display: none;
}
.view-wrap::after {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: 100%;
  height: 14px;
  z-index: 59;
}
.view-wrap .view-menu {
  display: block;
  top: calc(100% + 2px);
  right: 0;
  min-width: 280px;
  width: 280px;
  background: var(--surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 6px 0 10px;
  animation: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  transition-delay: 0s;
}
.view-wrap.is-open .view-menu,
.view-wrap:focus-within .view-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0.02s;
}
.view-menu-section {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.view-menu-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 2px;
}
.view-display-current {
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  letter-spacing: 0;
}
.view-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 2px 10px 10px;
}
.view-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 72px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), color var(--ease), box-shadow var(--ease);
}
.view-type-option:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  background: var(--surface-2);
  color: var(--text);
}
.view-type-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}
.view-type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  opacity: 0.82;
}
.view-type-option.active .view-type-icon { opacity: 1; }
.view-type-label {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
}
.view-display-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 6px;
  padding: 2px 8px 8px;
}

.view-options-grid + .view-menu-section {
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.view-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background var(--ease);
}
.view-check:hover:not(.is-disabled) { background: var(--surface-2); }
.view-check.is-disabled {
  opacity: 0.55;
  cursor: default;
}
.view-check.is-disabled:hover { background: transparent; }
.view-check.is-disabled input { cursor: default; }
.view-check input {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: transparent;
  position: relative;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.view-check input:hover:not(:disabled) {
  border-color: var(--primary);
}
.view-check input:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.view-check input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.view-check input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.view-check input:disabled {
  opacity: 0.45;
  cursor: default;
}
.view-check input:disabled:checked {
  background: var(--muted);
  border-color: var(--muted);
}
.view-size-block {
  margin: 0 10px;
  padding: 10px 4px 0;
  border-top: 1px solid var(--border);
}
.view-size-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
  margin-bottom: 8px;
}
.view-size-value {
  font-size: 12px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.view-size-slider {
  width: 100%; height: 4px;
  appearance: none; -webkit-appearance: none;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.view-size-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.view-size-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.view-size-slider:active::-webkit-slider-thumb { cursor: grabbing; }
.view-size-slider:active::-moz-range-thumb { cursor: grabbing; }
.view-size-tip {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* ===== Body layout ===== */
.body { display: flex; flex: 1; min-height: 0; min-width: 0; }
body.is-resizing,
.body.is-resizing {
  user-select: none;
}
body.is-resizing .sidebar-wrap,
body.is-resizing .feed-sidebar-wrap,
.body.is-resizing .sidebar-wrap,
.body.is-resizing .feed-sidebar-wrap {
  transition: none;
}

.sidebar-wrap {
  position: relative;
  flex-shrink: 0;
  width: var(--sidebar-w);
  min-width: 0;
  transition: width var(--ease);
}
.sidebar-wrap:has(.sidebar.collapsed) {
  width: 0;
}

.sidebar {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.sidebar.collapsed {
  border-right: none;
  overflow: hidden;
}

/* 左侧网站预览区 */
.link-detail {
  flex-shrink: 0;
  height: var(--link-detail-h);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 10px;
  overflow: hidden;
}
.link-detail-preview {
  position: relative;
  flex: 1;
  min-height: 72px;
  overflow: hidden;
  background: transparent;
}
.link-detail-img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  background: var(--surface);
}
.link-detail.is-loading .link-detail-img,
.link-detail.has-preview .link-detail-img {
  display: block;
}
.link-detail-img[hidden] {
  display: none !important;
}
.link-detail.has-preview .link-detail-img {
  border-radius: var(--radius-sm);
}
.link-detail-preview-empty,
.link-detail-preview-loading,
.link-detail-preview-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.link-detail-preview-loading,
.link-detail-preview-error { display: none; }
.link-detail.is-loading .link-detail-preview-empty { display: none; }
.link-detail.is-loading .link-detail-preview-loading { display: flex; }
.link-detail.is-error .link-detail-preview-empty { display: none; }
.link-detail.is-error .link-detail-preview-error {
  display: flex;
  color: var(--danger);
}
.link-detail.has-preview .link-detail-preview-empty { display: none; }
.link-detail-text {
  display: none;
  flex-shrink: 0;
  max-height: 42%;
  overflow-y: auto;
  min-height: 0;
}
.link-detail.has-link .link-detail-text {
  display: block;
}
.link-detail-title:empty,
.link-detail-desc:empty {
  display: none;
}
.link-detail-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}
.link-detail-desc {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
  word-break: break-word;
  white-space: pre-wrap;
}
.link-detail-url {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}
.link-detail-url:hover { text-decoration: underline; }
.link-detail-meta {
  display: none;
  margin: 8px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--border);
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  font-size: 10px;
  line-height: 1.45;
}
.link-detail.has-link .link-detail-meta:not(:empty) {
  display: grid;
}
.link-detail-meta dt {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}
.link-detail-meta dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.link-hover-tip {
  position: fixed;
  z-index: 120;
  max-width: min(280px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text);
}
.link-hover-tip-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 4px;
  word-break: break-word;
}
.link-hover-tip-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  color: var(--muted);
  font-size: 10px;
}
.link-hover-tip-meta dt { margin: 0; white-space: nowrap; }
.link-hover-tip-meta dd { margin: 0; color: var(--text); word-break: break-word; }

.link-detail-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 0;
  padding-bottom: 2px;
}
.link-detail-controls .panel-resizer-h {
  align-self: stretch;
  width: 100%;
}
.link-detail-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  padding: 0 4px;
  line-height: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  transition: color var(--ease);
}
.link-detail-collapse-btn:hover {
  color: var(--text);
  background: transparent;
}
.link-detail-collapse-btn svg {
  display: block;
  transition: transform var(--ease);
}
.link-detail-preview-collapsed .link-detail:not(.has-link) {
  display: none;
}
.link-detail-preview-collapsed .link-detail.has-link {
  height: auto;
  min-height: 0;
  padding: 6px 12px 0;
  gap: 4px;
}
.link-detail-preview-collapsed .link-detail-preview {
  display: none;
}
.link-detail-preview-collapsed .link-detail-controls {
  padding: 0 0 2px;
}
.link-detail-preview-collapsed .link-detail-controls .panel-resizer-h {
  height: 0;
  pointer-events: none;
}
.link-detail-preview-collapsed .link-detail-controls .panel-resizer-h::after {
  display: none;
}
.link-detail-preview-collapsed .link-detail-collapse-btn svg {
  transform: rotate(180deg);
}
.link-detail-preview-collapsed .sidebar-main {
  padding-top: 4px;
}

.panel-resizer-h {
  flex-shrink: 0;
  height: 6px;
  cursor: ns-resize;
  position: relative;
  touch-action: none;
}
.panel-resizer-h::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border);
  transition: background var(--ease), height var(--ease);
}
.panel-resizer-h:hover::after,
.panel-resizer-h.is-active::after,
.body.is-resizing-row .panel-resizer-h::after {
  height: 2px;
  background: var(--primary);
}

.sidebar-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px 12px;
}

.col-resizer {
  flex-shrink: 0;
  width: 6px;
  cursor: col-resize;
  position: relative;
  touch-action: none;
  background: transparent;
}
.col-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: var(--border);
  transition: background var(--ease), width var(--ease);
}
#rightColResizer::after {
  left: auto;
  right: 0;
}
.col-resizer:hover::after,
.col-resizer.is-active::after,
.body.is-resizing-col .col-resizer::after {
  width: 2px;
  background: var(--primary);
}
body:has(.sidebar.collapsed) #leftColResizer { display: none; }
body:has(.feed-sidebar.collapsed) #rightColResizer { display: none; }

.sidebar-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  bottom: auto;
  transform: translate(100%, -50%);
  z-index: 45;
  width: 20px;
  height: 40px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  transition: color var(--ease), background var(--ease), border-color var(--ease), transform var(--ease);
}
.sidebar-wrap .sidebar-toggle,
.sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.sidebar-toggle svg,
.feed-sidebar-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
  transition: transform var(--ease);
}
.sidebar-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.sidebar-toggle:active {
  transform: translate(100%, -50%) scale(0.96);
}
.sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle {
  transform: translate(100%, -50%);
}
.sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle svg {
  transform: rotate(180deg);
}
.sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle:active {
  transform: translate(100%, -50%) scale(0.96);
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 28px;
  padding: 0 8px 8px;
}
.sidebar-head .icon-btn.edit-only {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}
.edit-mode .sidebar-head .icon-btn.edit-only {
  visibility: visible;
  pointer-events: auto;
}
.sidebar-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.category-drop-line {
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
  pointer-events: none;
  z-index: 6;
  will-change: transform;
  contain: layout style paint;
  transform: translate3d(0, 0, 0);
}
.category-drop-line.is-sub {
  left: 44px;
  right: 36px;
}
.category-drop-line::before,
.category-drop-line::after {
  content: "";
  position: absolute;
  top: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  transform: translateY(-1.5px);
}
.category-drop-line::before { left: 0; }
.category-drop-line::after { right: 0; }

.category-item.category-drop-nest {
  background: var(--primary-soft) !important;
  box-shadow: inset 0 0 0 1px var(--primary-ring);
}

/* 分类拖拽：隐藏 ghost 占位与跟随鼠标的 fallback，原分类项保持可见，仅显示指示线 */
.category-list.is-dragging .sortable-ghost,
.category-list.is-dragging .sortable-drag,
.category-sortable-fallback {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important;
  box-shadow: none !important;
}
.category-list.is-dragging > .category-item.sortable-chosen {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  min-height: unset !important;
  overflow: visible !important;
  pointer-events: none;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--primary-ring);
}

.category-toggle,
.category-toggle-spacer {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.category-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin: -2px 0;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  transition: color var(--ease), background var(--ease);
}
.category-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}
.category-toggle svg {
  display: block;
  transition: transform var(--ease);
  transform: rotate(90deg);
}
.category-toggle.collapsed svg {
  transform: rotate(0deg);
}

.category-item {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  min-height: 34px;
  padding: 4px 10px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background var(--ease), color var(--ease);
}
.category-item::before {
  display: none;
}
.category-item:hover { background: var(--surface-2); color: var(--text); }
.category-item.active { background: var(--primary-soft); color: var(--primary); }
.category-item.active .category-toggle {
  color: var(--primary);
}
.category-item.active .category-toggle:hover {
  color: var(--primary);
  background: var(--surface);
}

.category-name { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-count {
  font-size: 12px; color: var(--muted);
  background: var(--surface-2); border-radius: 10px;
  padding: 1px 8px; min-width: 22px; text-align: center;
}
.category-item.active .category-count { background: var(--surface); color: var(--primary); }
.category-trail {
  position: relative;
  flex-shrink: 0;
  min-width: 52px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.category-trail .category-count {
  transition: opacity var(--ease);
}
.category-actions {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
}
.edit-mode .category-item:hover .category-actions {
  opacity: 1;
  pointer-events: auto;
}
.edit-mode .category-item:hover .category-trail .category-count {
  opacity: 0;
}
.edit-mode .category-trail .icon-btn.sm {
  width: 24px;
  height: 24px;
}

/* 二级分类：缩进 + 左侧树形引导线 */
.category-item-parent.category-item-expanded {
  position: relative;
  z-index: 1;
}
.category-item-sub {
  position: relative;
  z-index: 1;
  margin-left: 0;
  padding: 4px 10px 4px 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
}
.category-item-sub::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 0;
  width: 1px;
  background: var(--border-strong);
  pointer-events: none;
  z-index: 0;
}
.category-item-sub:not(.category-sub-last)::before {
  bottom: -4px;
}
.category-item-sub.category-sub-last::before {
  bottom: 0;
}
.category-item-sub.category-sub-first {
  margin-top: 2px;
}
.category-item-sub + .category-item-sub {
  margin-top: 2px;
}
.category-item-sub .category-name {
  font-size: 13px;
}

/* Edit mode only elements */
.edit-only { display: none !important; }
.edit-mode .icon-btn.edit-only,
.edit-mode .btn-primary.edit-only { display: inline-flex !important; }
.edit-mode .menu-item.edit-only { display: block !important; }

.site-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 16px 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}
.site-banner[hidden] { display: none !important; }
html.readonly-banner-dismissed #readonlyBanner { display: none !important; }
.site-banner-text { color: var(--text-2); flex: 1; min-width: 0; }
.site-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.site-banner-close {
  color: var(--muted);
}
.site-banner-close:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .site-banner-close:hover {
  background: rgba(255, 255, 255, 0.08);
}
.site-banner-readonly {
  background: var(--primary-soft);
  border-color: var(--primary-ring);
}
.site-banner-admin {
  background: var(--surface-2);
}
.btn-primary.sm,
.btn-ghost.sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  white-space: nowrap;
}

.cat-drag-handle { color: var(--muted); cursor: grab; display: inline-flex; }

/* ===== Content ===== */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.content-toolbar {
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 28px 10px;
  min-height: 0;
  max-height: 72px;
  overflow: visible;
  background: color-mix(in srgb, var(--surface) 58%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 52%, transparent);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--bg) 32%, transparent);
  transition: max-height 0.26s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.26s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.18s ease,
    transform 0.26s cubic-bezier(0.4, 0, 0.2, 1),
    background var(--ease),
    border-color var(--ease);
}
.content-toolbar-slot {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* History menu - hover to show */
.history-wrap {
  position: relative;
  outline: none;
  flex-shrink: 0;
}
.history-float-title {
  display: none;
}
.history-wrap::after {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: 100%;
  height: 14px;
  z-index: 59;
}
.history-wrap .history-menu {
  display: block;
  left: 0;
  right: auto;
  top: calc(100% + 2px);
  min-width: 260px;
  max-width: min(360px, calc(100vw - 48px));
  max-height: min(400px, 50vh);
  overflow-y: auto;
  padding: 8px 6px 8px 8px;
  animation: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  transition-delay: 0s;
}

.history-wrap:hover .history-menu,
.history-wrap:focus-within .history-menu,
.history-wrap.is-open .history-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0.02s;
}
.history-menu-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.history-menu-item {
  display: grid;
  grid-template-columns: 50px 18px 28px 1fr;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background var(--ease);
}
.history-menu-item:hover {
  background: var(--surface-2);
}
.history-menu-item-time {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-menu-item-timeline {
  position: relative;
  height: 100%;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-menu-item-timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  bottom: -8px;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
  border-radius: 1px;
  pointer-events: none;
}
.history-menu-item-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--card, var(--bg));
  box-shadow: 0 0 0 1px var(--border);
  z-index: 1;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.history-menu-item:hover .history-menu-item-dot {
  background: var(--primary);
  border-color: var(--surface-2);
  box-shadow: 0 0 0 1px var(--primary);
}
.history-menu-item .link-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  font-size: 12px;
}
.history-menu-item-main {
  min-width: 0;
  flex: 1;
}
.history-menu-item-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-menu-item-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.content-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}
.content-toolbar-right .search-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(calc(320px * 2 / 3), calc(36vw * 2 / 3));
  min-width: calc(160px * 2 / 3);
  z-index: 1;
}
.content-toolbar-right .search-input {
  background: var(--bg);
  border-color: var(--border);
  padding-right: 14px;
}
.content-toolbar-right .search-input:focus {
  background: var(--surface-2);
}
.content-body {
  position: relative;
  z-index: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0 28px 80px;
  min-height: 0;
}

/* ===== Feed sidebar (right) ===== */
.feed-sidebar-wrap {
  position: relative;
  flex-shrink: 0;
  width: var(--feed-sidebar-w);
  transition: width var(--ease);
}
.feed-sidebar-wrap:has(.feed-sidebar.collapsed) {
  width: 0;
}
.feed-sidebar {
  width: 100%;
  height: 100%;
  padding: 16px 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.feed-sidebar.collapsed {
  padding: 0;
  overflow: hidden;
}
.feed-sidebar-toggle {
  position: absolute;
  left: 0;
  top: 50%;
  bottom: auto;
  transform: translate(-100%, -50%);
  z-index: 45;
  width: 20px;
  height: 40px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  transition: color var(--ease), background var(--ease), border-color var(--ease), transform var(--ease);
}
.feed-sidebar-wrap .feed-sidebar-toggle,
.feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.feed-sidebar-toggle svg {
  transform: rotate(180deg);
}
.feed-sidebar-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.feed-sidebar-toggle:active {
  transform: translate(-100%, -50%) scale(0.96);
}
.feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle {
  transform: translate(-100%, -50%);
}
.feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle svg {
  transform: none;
}
.feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle:active {
  transform: translate(-100%, -50%) scale(0.96);
}
.feed-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px 6px;
  flex-shrink: 0;
}
.feed-sidebar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.feed-source-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 6px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  flex-shrink: 0;
  min-height: 0;
  overflow: hidden;
}
.feed-source-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  font-size: 13px;
}
.feed-source-icon--all .link-icon-letter {
  font-size: 15px;
  color: var(--text-2);
}
.feed-source-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.feed-source-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-source-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-source-open {
  flex-shrink: 0;
  color: var(--text-2);
}
.feed-source-open:hover {
  color: var(--primary);
  background: var(--primary-soft);
}
.feed-source-open[hidden] {
  display: none;
}
.feed-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  padding: 0 4px;
}
.feed-list--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}
.feed-placeholder,
.feed-status {
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  grid-column: 1 / -1;
}
.feed-status.is-error { color: var(--danger); }
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background var(--ease);
  min-width: 0;
}
.feed-item:hover {
  background: var(--surface-2);
}
.feed-item.is-hovered,
.feed-item.is-active {
  background: var(--primary-soft);
}
.feed-item.is-active {
  box-shadow: inset 0 0 0 1px var(--primary-ring);
}
.feed-item-thumb {
  flex-shrink: 0;
  width: 72px;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.feed-item-thumb.is-empty {
  background: linear-gradient(135deg, var(--surface-2), color-mix(in srgb, var(--border) 55%, var(--surface-2)));
}
.feed-item-thumb-fallback {
  display: block;
  width: 100%;
  height: 100%;
}
.feed-item-thumb-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
}
.feed-item-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.feed-item-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
}
.feed-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.feed-item-source {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-item-time {
  flex-shrink: 0;
}
.feed-item--card,
.feed-item--large,
.feed-item--grid {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.feed-item--card .feed-item-thumb,
.feed-item--large .feed-item-thumb,
.feed-item--grid .feed-item-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}
.feed-item--large .feed-item-thumb {
  aspect-ratio: 4 / 3;
}
.feed-item--large .feed-item-title {
  font-size: 14px;
  -webkit-line-clamp: 3;
}
.feed-item--compact {
  gap: 8px;
  padding: 7px 8px;
}
.feed-item--compact .feed-item-thumb {
  width: 48px;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
}
.feed-item--compact .feed-item-title {
  -webkit-line-clamp: 1;
  font-size: 12px;
}
.feed-item--compact .feed-item-meta {
  margin-top: 0;
}
.feed-item--grid {
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.feed-item--grid .feed-item-title {
  font-size: 12px;
  -webkit-line-clamp: 2;
}
.feed-item--grid .feed-item-meta {
  margin-top: 2px;
}
.feed-view-wrap { position: relative; outline: none; }
.feed-view-wrap::after {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: 100%;
  height: 14px;
  z-index: 59;
}
.feed-view-wrap .feed-view-menu {
  display: block;
  top: calc(100% + 2px);
  right: 0;
  left: auto;
  min-width: 220px;
  width: 220px;
  padding: 6px 0 10px;
  animation: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}
.feed-view-wrap.is-open .feed-view-menu,
.feed-view-wrap:focus-within .feed-view-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.feed-refresh-btn.is-spinning svg {
  animation: feedSpin 0.8s linear infinite;
}
@keyframes feedSpin {
  to { transform: rotate(360deg); }
}


.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(240px * var(--view-size) / 100), 1fr));
  gap: calc(14px * var(--view-size) / 100);
  align-content: start;
}
.links-grid.list-view {
  grid-template-columns: 1fr;
  gap: calc(8px * var(--view-size) / 100);
}

/* Category group (when viewing all) */
.group { margin-bottom: 28px; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.group-title { font-size: 14px; font-weight: 600; color: var(--text); }
.group-count { font-size: 12px; color: var(--muted); }
.group-line { flex: 1; height: 1px; background: var(--border); }

/* ===== Group board layout ===== */
.group-board {
  column-count: var(--group-cols, 4);
  column-gap: calc(28px * var(--view-size) / 100);
  width: 100%;
}
.group-column {
  position: relative;
  min-width: 0;
  width: 100%;
  padding: calc(8px * var(--view-size) / 100);
  border-radius: var(--radius);
  transition: background var(--ease);
  break-inside: avoid;
  margin-bottom: calc(22px * var(--view-size) / 100);
}
.group-board .group-column:has(.link-card:hover) {
  background: color-mix(in srgb, var(--surface-hover) 72%, transparent);
}
.group-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(6px * var(--view-size) / 100);
  margin-bottom: calc(10px * var(--view-size) / 100);
  min-width: 0;
  min-height: calc(30px * var(--view-size) / 100);
  padding: calc(5px * var(--view-size) / 100) calc(7px * var(--view-size) / 100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}
.group-column-head:hover,
.group-column-sub-head:hover {
  background: color-mix(in srgb, var(--primary-soft) 58%, transparent);
}
.group-column-head .group-column-title {
  margin-bottom: 0;
  min-width: 0;
  flex: 1;
}
.group-column-head-actions {
  display: flex;
  align-items: center;
  gap: calc(4px * var(--view-size) / 100);
  flex-shrink: 0;
  margin-left: auto;
  order: 2;
}
.group-column-batch-search {
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease), color var(--ease), background var(--ease);
}
.group-column-batch-search:hover {
  color: var(--primary);
  background: var(--primary-soft);
}
.group-column-head:hover .group-column-batch-search,
.group-column-sub-head:hover .group-column-batch-search {
  opacity: 1;
  pointer-events: auto;
}
.group-column-sub-head .group-column-head-actions {
  order: 3;
  margin-left: auto;
}
.group-column-add-link {
  flex-shrink: 0;
  color: var(--muted);
}
.group-column-add-link:hover {
  color: var(--primary);
  background: var(--primary-soft);
}
.group-column-sub-head .group-column-add-link {
  margin-left: 0;
}
.group-column-title {
  font-size: max(var(--view-text-min), calc(13px * var(--view-size) / 100));
  font-weight: 600;
  color: var(--primary);
  margin-bottom: calc(10px * var(--view-size) / 100);
  letter-spacing: 0.01em;
}
.group-column-parent .group-column-subs {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: calc(8px * var(--view-size) / 100);
  padding-left: 0;
  border-left: 2px solid var(--border);
  margin-left: 2px;
}
.group-column-sub {
  position: relative;
  padding-left: calc(6px * var(--view-size) / 100);
}
.group-column-sub::before {
  content: "";
  position: absolute;
  left: -4.5px;
  top: calc((30px * var(--view-size) / 100) / 2);
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
  transform: translateY(-50%);
}
.group-column-sub + .group-column-sub {
  margin-top: calc(18px * var(--view-size) / 100);
}
.group-column-sub.collapsed + .group-column-sub,
.group-column-sub + .group-column-sub.collapsed {
  margin-top: calc(9px * var(--view-size) / 100);
}
.group-column-sub-head {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: calc(8px * var(--view-size) / 100);
  min-height: calc(30px * var(--view-size) / 100);
  padding: calc(5px * var(--view-size) / 100) calc(7px * var(--view-size) / 100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--ease), color var(--ease);
}
.group-column-sub-toggle,
.group-column-parent-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: -2px 0;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  transition: color var(--ease), background var(--ease);
}
.group-column-sub-toggle {
  order: 4;
}
.group-column-parent-toggle {
  order: 4;
  margin-left: 0;
}
.group-column-sub-toggle:hover,
.group-column-parent-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}
.group-column-sub-toggle svg,
.group-column-parent-toggle svg {
  display: block;
  transition: transform var(--ease);
  transform: rotate(90deg);
}
.group-column-sub-toggle.collapsed svg,
.group-column-parent-toggle.collapsed svg {
  transform: rotate(0deg);
}
.group-column-sub-title {
  font-size: max(var(--view-text-min), calc(12px * var(--view-size) / 100));
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0;
  order: 1;
  flex: 0 1 auto;
  min-width: 0;
}
.group-column.collapsed > .group-column-visible,
.group-column.collapsed > .group-column-more,
.group-column-parent.collapsed .group-column-direct-wrap,
.group-column-parent.collapsed .group-column-subs {
  display: none;
}
.group-column.collapsed {
  margin-bottom: calc(8px * var(--view-size) / 100);
  padding-top: calc(4px * var(--view-size) / 100);
  padding-bottom: calc(4px * var(--view-size) / 100);
}
.group-column.collapsed .group-column-head,
.group-column-sub.collapsed .group-column-sub-head {
  margin-bottom: 0;
}
.group-column-sub.collapsed .group-column-visible,
.group-column-sub.collapsed .group-column-more {
  display: none;
}
.group-column-direct.links-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(8px * var(--view-size) / 100);
}
.group-column-direct-wrap {
  position: relative;
  margin-bottom: calc(12px * var(--view-size) / 100);
}
.group-column-direct-wrap .group-column-direct.links-grid {
  margin-bottom: 0;
}
.group-column-sub-overflow {
  margin: calc(6px * var(--view-size) / 100) 0 0;
  padding: calc(6px * var(--view-size) / 100) calc(4px * var(--view-size) / 100);
  font-size: max(var(--view-text-min), calc(11px * var(--view-size) / 100));
  color: var(--muted);
  line-height: 1.45;
}
.group-column-visible.links-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(8px * var(--view-size) / 100);
  width: 100%;
  min-width: 0;
  overflow: hidden;
}
.group-column-sub .group-column-visible.links-grid {
  padding-left: 20px;
}
.group-column-empty {
  min-height: 48px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}
.edit-mode .group-column-empty {
  min-height: 64px;
}
.edit-mode .group-column-empty::before {
  content: "拖拽链接到此处";
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  font-size: max(var(--view-text-min), calc(11px * var(--view-size) / 100));
  color: var(--muted);
  pointer-events: none;
}
.group-board[data-view="icon"] .group-column-visible.icon-view,
.group-board[data-view="icon"] .group-column-direct.icon-view {
  grid-template-columns: repeat(2, 1fr);
  gap: calc(8px * var(--view-size) / 100);
  align-items: start;
}
.group-board[data-view="icon"] .group-column-visible.icon-view .link-card,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card {
  justify-content: flex-start;
  min-height: 0;
  width: 100%;
  padding: calc(8px * var(--view-size) / 100) calc(4px * var(--view-size) / 100) calc(6px * var(--view-size) / 100);
  gap: calc(6px * var(--view-size) / 100);
}
.group-board[data-view="icon"] .group-column-visible.icon-view .link-card:not(:has(.link-main)),
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card:not(:has(.link-main)) {
  min-height: 0;
  padding: calc(8px * var(--view-size) / 100) calc(4px * var(--view-size) / 100);
}
.group-board[data-view="small-icon"] .group-column-visible.small-icon-view,
.group-board[data-view="small-icon"] .group-column-direct.small-icon-view {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: calc(4px * var(--view-size) / 100) calc(14px * var(--view-size) / 100);
  align-items: start;
}
.group-board[data-view="small-icon"] .group-column-popover-links.small-icon-view {
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: calc(8px * var(--view-size) / 100) calc(10px * var(--view-size) / 100);
  align-items: start;
}
.group-board[data-view="small-icon"] .group-column-visible.small-icon-view .link-card,
.group-board[data-view="small-icon"] .group-column-direct.small-icon-view .link-card,
.group-board[data-view="small-icon"] .group-column-popover-links.small-icon-view .link-card {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  padding: calc(3px * var(--view-size) / 100) calc(4px * var(--view-size) / 100);
  gap: calc(5px * var(--view-size) / 100);
  background: transparent;
  border-color: transparent;
  overflow: hidden;
}
.group-board[data-view="small-icon"] .group-column-visible.small-icon-view .link-card:hover,
.group-board[data-view="small-icon"] .group-column-direct.small-icon-view .link-card:hover,
.group-board[data-view="small-icon"] .group-column-popover-links.small-icon-view .link-card:hover {
  background: var(--surface-2);
}
.group-board[data-view="small-icon"] .group-column-visible.small-icon-view .link-card:not(:has(.link-main)),
.group-board[data-view="small-icon"] .group-column-direct.small-icon-view .link-card:not(:has(.link-main)),
.group-board[data-view="small-icon"] .group-column-popover-links.small-icon-view .link-card:not(:has(.link-main)) {
  min-height: 0;
  padding: calc(2px * var(--view-size) / 100) calc(2px * var(--view-size) / 100);
}
.group-board[data-view="small-icon"] .group-column .link-icon {
  width: calc(16px * var(--view-size) / 100);
  height: calc(16px * var(--view-size) / 100);
  border-radius: calc(3px * var(--view-size) / 100);
  flex-shrink: 0;
}
.group-board[data-view="small-icon"] .group-column .link-icon-letter {
  font-size: max(var(--view-text-min), calc(9px * var(--view-size) / 100));
}
.group-board[data-view="small-icon"] .group-column .link-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.group-board[data-view="small-icon"] .group-column .link-title {
  display: block;
  font-weight: 400;
  font-size: max(var(--view-text-min), calc(12px * var(--view-size) / 100));
  line-height: 1.35;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-board[data-view="small-icon"] .group-column .link-card--rss .link-main,
.group-board[data-view="small-icon"] .group-column .link-card--site-search .link-main {
  padding-right: calc(24px * var(--view-size) / 100);
}
.group-board[data-view="small-icon"] .group-column .link-card-tools {
  top: 50%;
  right: calc(2px * var(--view-size) / 100);
  transform: translateY(-50%);
}
.group-column .link-card {
  max-width: 100%;
  min-width: 0;
  padding: calc(10px * var(--view-size) / 100) calc(11px * var(--view-size) / 100);
  gap: calc(10px * var(--view-size) / 100);
}
.group-board[data-view="small-icon"] .group-column .link-card {
  padding: calc(3px * var(--view-size) / 100) calc(4px * var(--view-size) / 100);
  gap: calc(5px * var(--view-size) / 100);
}
.group-board[data-view="list"] .group-column .link-icon {
  width: calc(24px * var(--view-size) / 100);
  height: calc(24px * var(--view-size) / 100);
  border-radius: calc(6px * var(--view-size) / 100);
}
.group-board[data-view="list"] .group-column .link-icon-letter {
  font-size: max(var(--view-text-min), calc(11px * var(--view-size) / 100));
}
.group-column-more {
  position: relative;
  margin-top: calc(6px * var(--view-size) / 100);
}
.group-column-more-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: calc(4px * var(--view-size) / 100) 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--ease), background var(--ease);
}
.group-column-more-hint:hover,
.group-column-more-hint:focus-visible {
  color: var(--primary);
  background: var(--surface-2);
  outline: none;
}
.group-more-icon {
  display: block;
  flex-shrink: 0;
}
.group-column-popover {
  display: none;
  flex-direction: column;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 2px);
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: calc(6px * var(--view-size) / 100);
  max-height: calc(260px * var(--view-size) / 100);
  overflow: hidden;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.group-column-popover-head {
  flex-shrink: 0;
  padding: 0 calc(2px * var(--view-size) / 100) calc(5px * var(--view-size) / 100);
  font-size: max(var(--view-text-min), calc(10px * var(--view-size) / 100));
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: calc(5px * var(--view-size) / 100);
}
.group-column-popover-links.links-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(3px * var(--view-size) / 100);
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  flex: 1;
}
.group-board[data-view="icon"] .group-column-popover-links.icon-view {
  grid-template-columns: repeat(2, 1fr);
  gap: calc(4px * var(--view-size) / 100);
  align-items: start;
}
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-card {
  justify-content: flex-start;
  min-height: 0;
  width: 100%;
}
.group-column-popover::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 12px;
}
.group-column-more-hint:hover + .group-column-popover,
.group-column-popover:hover {
  display: flex;
}

/* ===== Link card ===== */
.link-card {
  position: relative;
  display: flex; align-items: center;
  gap: calc(12px * var(--view-size) / 100);
  padding: calc(14px * var(--view-size) / 100);
  background: var(--card);
  border-radius: calc(var(--radius) * var(--view-size) / 100);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background var(--ease);
}
.link-card:hover {
  background: var(--surface-2);
}
.link-card--no-bg {
  background: transparent;
  border-color: transparent;
}
.link-card--no-bg:hover {
  background: var(--surface-2);
}
.link-card--no-icon {
  gap: 0;
}
.link-card.is-detail-focus {
  background: var(--primary-soft);
}
.link-card.is-detail-focus:hover {
  background: var(--primary-soft);
}
.link-card:not(:has(.link-main)) {
  justify-content: center;
}

.link-icon {
  width: calc(40px * var(--view-size) / 100);
  height: calc(40px * var(--view-size) / 100);
  flex-shrink: 0;
  border-radius: calc(10px * var(--view-size) / 100);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
  font-weight: 600;
  font-size: max(var(--view-text-min), min(var(--view-text-max), calc(16px * var(--view-size) / 100)));
  color: #fff;
  transition: opacity var(--ease), transform var(--ease);
}
.link-icon-letter {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: max(var(--view-text-min), min(var(--view-text-max), calc(16px * var(--view-size) / 100)));
  color: #fff;
  transition: opacity var(--ease);
}
.link-icon-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain;
  background: var(--surface-2);
  opacity: 0;
  transition: opacity var(--ease);
}
.link-icon-img.loaded { opacity: 1; }
.link-icon:has(.link-icon-img.loaded) .link-icon-letter { opacity: 0; }
.link-icon.icon-fallback .link-icon-letter { opacity: 1; }

.url-field-row {
  display: flex; align-items: center; gap: 10px;
}
.url-icon-preview {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.url-icon-preview .link-icon-letter { font-size: 15px; }
.url-icon-preview .link-icon-img { background: var(--surface); }
.url-field-row .field-input { flex: 1; }

.link-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding-right: calc(6px * var(--view-size) / 100);
}
.link-title {
  position: relative;
  display: flex; align-items: center; justify-content: flex-start;
  font-size: max(var(--view-text-min), min(var(--view-text-max), calc(12px * var(--view-size) / 100)));
  font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.link-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pin-badge {
  position: absolute;
  left: calc(100% + 2px);
  top: 50%;
  width: 1em;
  height: 1em;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  pointer-events: none;
}
.pin-badge svg {
  width: 1em;
  height: 1em;
  display: block;
}

/* ===== Pinned links bar ===== */
.pinned-links-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  flex-wrap: wrap;
  width: min(calc(560px * 2 / 3), 100%);
  margin-left: 28px;
  max-height: 30px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.24s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.18s ease,
    transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}
.pinned-links-bar[hidden] { display: none; }
.pinned-link-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--ease), transform var(--ease);
}
.pinned-link-item:hover {
  opacity: 1;
  transform: scale(1.25);
}
.pinned-link-item .link-icon {
  width: 18px;
  height: 18px;
  font-size: 10px;
  transition: width var(--ease), height var(--ease);
}
.pinned-link-item:hover .link-icon {
  width: 80%;
  height: 80%;
}
.pinned-link-item-title {
  display: none;
}
.pinned-links-label {
  margin-left: auto;
  padding-right: 9px;
  font-size: 12px;
  color: var(--primary);
  white-space: nowrap;
  user-select: none;
  opacity: 0.8;
}
.pinned-links-label-name {
  display: none;
  margin-right: 5px;
  color: var(--text);
}
.pinned-links-bar:hover .pinned-links-label-name {
  display: inline;
}
.pinned-links-label-search {
  color: var(--primary);
}
@keyframes pinShrink {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}
@keyframes pinPopIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes cardPopOut {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.pinned-link-item.pin-shrink {
  animation: pinShrink 0.25s ease forwards;
}
.pinned-link-item.pin-pop-in {
  animation: pinPopIn 0.3s ease forwards;
}
.link-card.card-pop-out {
  animation: cardPopOut 0.3s ease forwards;
}
.link-desc {
  display: block;
  min-width: 0;
  max-width: 100%;
  font-size: max(var(--view-text-min), calc(12.5px * var(--view-size) / 100));
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: calc(4px * var(--view-size) / 100);
}

.link-actions {
  position: absolute; top: 8px; right: 8px;
  display: none; gap: 2px;
  opacity: 0;
  transition: opacity var(--ease);
}
.edit-mode .link-card:hover .link-actions {
  display: flex;
  opacity: 1;
}
.link-actions .icon-btn {
  width: 28px; height: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.link-actions .icon-btn:hover { background: var(--surface-2); }
.link-actions .icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.link-card.is-feed-pinned {
  background: var(--primary-soft);
}
.link-card.is-feed-pinned:hover {
  background: var(--primary-soft);
}

.link-card-tools {
  position: absolute;
  right: calc(10px * var(--view-size) / 100);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: calc(4px * var(--view-size) / 100);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
  z-index: 2;
}
.edit-mode .link-card-tools {
  display: none !important;
}
.edit-mode .link-card--rss .link-main,
.edit-mode .link-card--site-search .link-main,
.edit-mode .link-card--rss.link-card--site-search .link-main,
.edit-mode .link-card--rss.link-card--site-search:hover .link-main {
  padding-right: calc(6px * var(--view-size) / 100);
}
.link-rss,
.link-site-search {
  position: static;
  flex-shrink: 0;
  width: calc(30px * var(--view-size) / 100);
  height: calc(30px * var(--view-size) / 100);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: calc(8px * var(--view-size) / 100);
  background: transparent;
  color: var(--text-2);
  box-shadow: none;
  cursor: pointer;
  opacity: 1;
  pointer-events: auto;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.link-rss:hover,
.link-site-search:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-ring);
}
.link-rss.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-ring);
}
.link-card--rss .link-card-tools {
  opacity: 1;
  pointer-events: auto;
}
.link-card--site-search:not(.link-card--rss):hover .link-card-tools,
.link-card.is-feed-pinned .link-card-tools {
  opacity: 1;
  pointer-events: auto;
}
.link-card--rss.link-card--site-search:not(:hover) .link-site-search {
  display: none;
}
.link-card--rss .link-main,
.link-card--rss.link-card--site-search .link-main {
  padding-right: calc(38px * var(--view-size) / 100);
}
.link-card--rss.link-card--site-search:hover .link-main {
  padding-right: calc(72px * var(--view-size) / 100);
}
.edit-mode .link-card--rss .link-card-tools,
.edit-mode .link-card--site-search:not(.link-card--rss):hover .link-card-tools {
  right: calc(96px * var(--view-size) / 100);
}
.icon-view .link-card-tools {
  top: calc(8px * var(--view-size) / 100);
  right: calc(8px * var(--view-size) / 100);
  transform: none;
}
.icon-view .link-rss,
.icon-view .link-site-search {
  width: calc(26px * var(--view-size) / 100);
  height: calc(26px * var(--view-size) / 100);
}
.edit-mode .icon-view .link-card--rss .link-card-tools,
.edit-mode .icon-view .link-card--site-search:not(.link-card--rss):hover .link-card-tools {
  top: calc(36px * var(--view-size) / 100);
  right: calc(8px * var(--view-size) / 100);
}
.small-icon-view .link-card-tools {
  top: calc(5px * var(--view-size) / 100);
  right: calc(5px * var(--view-size) / 100);
  transform: none;
}
.small-icon-view .link-rss,
.small-icon-view .link-site-search {
  width: calc(22px * var(--view-size) / 100);
  height: calc(22px * var(--view-size) / 100);
}
.edit-mode .small-icon-view .link-card--rss .link-card-tools,
.edit-mode .small-icon-view .link-card--site-search:not(.link-card--rss):hover .link-card-tools {
  top: calc(30px * var(--view-size) / 100);
  right: calc(5px * var(--view-size) / 100);
}

/* List view */
.list-view .link-card { padding: calc(6px * var(--view-size) / 100) calc(9px * var(--view-size) / 100); }
.list-view .link-icon {
  width: calc(28px * var(--view-size) / 100);
  height: calc(28px * var(--view-size) / 100);
  border-radius: calc(4px * var(--view-size) / 100);
  font-size: max(var(--view-text-min), calc(13px * var(--view-size) / 100));
}
.list-view .link-icon-letter { font-size: max(var(--view-text-min), calc(13px * var(--view-size) / 100)); }

/* Compact view - 紧凑单列 */
.compact-view {
  grid-template-columns: 1fr;
  gap: calc(4px * var(--view-size) / 100);
}
.compact-view .link-card {
  padding: calc(6px * var(--view-size) / 100) calc(10px * var(--view-size) / 100);
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.compact-view .link-icon {
  width: calc(22px * var(--view-size) / 100);
  height: calc(22px * var(--view-size) / 100);
  border-radius: calc(6px * var(--view-size) / 100);
}
.compact-view .link-icon-letter { font-size: max(var(--view-text-min), calc(11px * var(--view-size) / 100)); }
.compact-view .link-title { font-size: max(var(--view-text-min), calc(13px * var(--view-size) / 100)); }
.compact-view .link-desc {
  font-size: max(var(--view-text-min), calc(11px * var(--view-size) / 100));
  margin-top: 1px;
}
.compact-view .link-actions { top: 4px; right: 4px; }
.compact-view .link-actions .icon-btn { width: 24px; height: 24px; }

/* Large view - 大卡片 */
.large-view {
  grid-template-columns: repeat(auto-fill, minmax(calc(300px * var(--view-size) / 100), 1fr));
  gap: calc(18px * var(--view-size) / 100);
}
.large-view .link-card {
  flex-direction: column;
  align-items: flex-start;
  padding: calc(18px * var(--view-size) / 100);
  gap: calc(14px * var(--view-size) / 100);
  min-height: calc(148px * var(--view-size) / 100);
}
.large-view .link-icon {
  width: calc(56px * var(--view-size) / 100);
  height: calc(56px * var(--view-size) / 100);
  border-radius: calc(14px * var(--view-size) / 100);
}
.large-view .link-icon-letter { font-size: max(var(--view-text-min), min(var(--view-text-max), calc(22px * var(--view-size) / 100))); }
.large-view .link-main { width: 100%; }
.large-view .link-title { font-size: max(var(--view-text-min), min(var(--view-text-max), calc(16px * var(--view-size) / 100))); white-space: normal; }
.large-view .link-desc {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
}
.large-view .link-actions { top: 12px; right: 12px; }

/* Card view - 悬停加载网站缩略图 */
.card-view {
  grid-template-columns: repeat(auto-fill, minmax(calc(240px * var(--view-size) / 100), 1fr));
  gap: calc(16px * var(--view-size) / 100);
}
.card-view .link-card--card-view {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  gap: 0;
}
.card-view .link-card--card-view.link-card--no-bg {
  background: var(--card);
  border-color: var(--border);
}
.card-view .link-card-preview {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.card-view .link-card-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.card-view .link-card-preview-img[hidden] {
  display: none;
}
.card-view .link-card-preview-empty,
.card-view .link-card-preview-loading,
.card-view .link-card-preview-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: max(var(--view-text-min), calc(11px * var(--view-size) / 100));
  color: var(--muted);
}
.card-view .link-card-preview-loading,
.card-view .link-card-preview-error {
  display: none;
}
.card-view .link-card-preview.is-loading .link-card-preview-empty { display: none; }
.card-view .link-card-preview.is-loading .link-card-preview-loading { display: flex; }
.card-view .link-card-preview.is-error .link-card-preview-empty { display: none; }
.card-view .link-card-preview.is-error .link-card-preview-error { display: flex; }
.card-view .link-card-preview.has-preview .link-card-preview-empty { display: none; }
.card-view .link-card-body {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--view-size) / 100);
  padding: calc(12px * var(--view-size) / 100) calc(14px * var(--view-size) / 100);
  min-width: 0;
}
.card-view .link-card-body .link-main {
  min-width: 0;
}
.card-view .link-card-body .link-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-view .link-card-body .link-desc {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: calc(2px * var(--view-size) / 100);
}
.card-view .link-card--card-view .link-actions {
  top: calc(8px * var(--view-size) / 100);
  right: calc(8px * var(--view-size) / 100);
}
.card-view .link-card--card-view .link-card-tools {
  top: auto;
  bottom: calc(8px * var(--view-size) / 100);
  right: calc(8px * var(--view-size) / 100);
  transform: none;
}
.edit-mode .card-view .link-card--card-view.link-card--rss .link-card-tools,
.edit-mode .card-view .link-card--card-view.link-card--site-search:not(.link-card--rss):hover .link-card-tools {
  bottom: calc(36px * var(--view-size) / 100);
}
.group-board[data-view="card"] .group-column .link-card--card-view {
  padding: 0;
}
.group-board[data-view="card"] .group-column .link-card-body {
  padding: calc(8px * var(--view-size) / 100) calc(9px * var(--view-size) / 100);
  gap: calc(8px * var(--view-size) / 100);
}
.group-board[data-view="card"] .group-column .link-icon {
  width: calc(24px * var(--view-size) / 100);
  height: calc(24px * var(--view-size) / 100);
  border-radius: calc(6px * var(--view-size) / 100);
}

/* Icon view - 图标网格 */
.icon-view {
  grid-template-columns: repeat(auto-fill, minmax(calc(96px * var(--view-size) / 100), 1fr));
  gap: calc(10px * var(--view-size) / 100);
}
.icon-view .link-card {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(14px * var(--view-size) / 100) calc(8px * var(--view-size) / 100) calc(12px * var(--view-size) / 100);
  gap: calc(10px * var(--view-size) / 100);
  min-height: calc(108px * var(--view-size) / 100);
}
.icon-view .link-icon {
  width: clamp(32px, calc(32px * var(--view-size) / 100), 48px);
  height: clamp(32px, calc(32px * var(--view-size) / 100), 48px);
  border-radius: calc(10px * var(--view-size) / 100);
}
.icon-view .link-icon-letter { font-size: max(var(--view-text-min), min(var(--view-text-max), calc(18px * var(--view-size) / 100))); }
.icon-view .link-main { width: 100%; }
.icon-view .link-title {
  font-size: max(var(--view-text-min), calc(12px * var(--view-size) / 100));
  font-weight: 500;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  justify-content: center;
  text-align: center;
}
.icon-view .link-title-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-view .link-desc {
  font-size: max(var(--view-text-min), calc(10px * var(--view-size) / 100));
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}
.icon-view .link-card:not(:has(.link-main)) {
  min-height: calc(72px * var(--view-size) / 100);
  padding: calc(12px * var(--view-size) / 100);
}
.edit-mode .icon-view .link-actions {
  display: flex;
  opacity: 0;
}
.edit-mode .icon-view .link-card:hover .link-actions { opacity: 1; }

/* Small icon view - icon left + label right, adaptive grid */
.small-icon-view {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: calc(4px * var(--view-size) / 100) calc(6px * var(--view-size) / 100);
  align-items: start;
}
.small-icon-view .link-card {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  padding: calc(4px * var(--view-size) / 100);
  gap: calc(6px * var(--view-size) / 100);
  min-height: 0;
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-sm);
  background: transparent;
  border-color: transparent;
  overflow: hidden;
}
.small-icon-view .link-card:hover {
  background: var(--surface-2);
}
.small-icon-view .link-card--no-bg {
  background: transparent;
  border-color: transparent;
}
.small-icon-view .link-icon {
  width: calc(16px * var(--view-size) / 100);
  height: calc(16px * var(--view-size) / 100);
  border-radius: calc(3px * var(--view-size) / 100);
  flex-shrink: 0;
}
.small-icon-view .link-icon-letter {
  font-size: max(var(--view-text-min), calc(9px * var(--view-size) / 100));
}
.small-icon-view .link-main {
  flex: 1;
  min-width: 0;
  width: auto;
  overflow: hidden;
}
.small-icon-view .link-title {
  display: block;
  justify-content: flex-start;
  font-size: max(var(--view-text-min), calc(12px * var(--view-size) / 100));
  font-weight: 400;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.small-icon-view .link-title-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.small-icon-view .link-card--rss .link-main,
.small-icon-view .link-card--site-search .link-main {
  padding-right: calc(24px * var(--view-size) / 100);
}
.small-icon-view .link-card--rss.link-card--site-search .link-main {
  padding-right: calc(48px * var(--view-size) / 100);
}
.small-icon-view .link-desc { display: none; }
.small-icon-view .link-card:not(:has(.link-main)) {
  min-height: 0;
  padding: calc(3px * var(--view-size) / 100);
}
.edit-mode .small-icon-view .link-actions {
  display: flex;
  opacity: 0;
  top: 0;
  right: 0;
}
.edit-mode .small-icon-view .link-card:hover .link-actions { opacity: 1; }
.small-icon-view .link-actions .icon-btn {
  width: 20px;
  height: 20px;
}

/* Keep icon layouts visually even; floating action icons should not reserve text space. */
.group-board[data-view="icon"] .group-column-visible.icon-view .link-card,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-card,
.icon-view .link-card {
  height: calc(94px * var(--view-size) / 100);
  min-height: calc(94px * var(--view-size) / 100);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(8px * var(--view-size) / 100) calc(8px * var(--view-size) / 100);
}

.group-board[data-view="icon"] .group-column-visible.icon-view .link-card:has(.link-desc),
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card:has(.link-desc),
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-card:has(.link-desc),
.icon-view .link-card:has(.link-desc) {
  height: calc(142px * var(--view-size) / 100);
  min-height: calc(142px * var(--view-size) / 100);
  padding: calc(13px * var(--view-size) / 100) calc(9px * var(--view-size) / 100) calc(11px * var(--view-size) / 100);
  gap: calc(7px * var(--view-size) / 100);
}

.group-board[data-view="icon"] .group-column-visible.icon-view .link-main,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-main,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-main,
.icon-view .link-main {
  flex: 0 1 auto;
  width: 100%;
  min-width: 0;
  padding-right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.group-board[data-view="icon"] .group-column-visible.icon-view .link-card:has(.link-desc) .link-main,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card:has(.link-desc) .link-main,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-card:has(.link-desc) .link-main,
.icon-view .link-card:has(.link-desc) .link-main {
  gap: calc(4px * var(--view-size) / 100);
}

.group-board[data-view="icon"] .group-column-visible.icon-view .link-title,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-title,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-title,
.icon-view .link-title {
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  overflow: visible;
  text-align: center;
}

.group-board[data-view="icon"] .group-column-visible.icon-view .link-desc,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-desc,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-desc,
.icon-view .link-desc {
  width: 100%;
  text-align: center;
  margin-top: 0;
  line-height: 1.35;
}

.group-board[data-view="icon"] .group-column-visible.icon-view .link-card--rss .link-main,
.group-board[data-view="icon"] .group-column-visible.icon-view .link-card--site-search .link-main,
.group-board[data-view="icon"] .group-column-visible.icon-view .link-card--rss.link-card--site-search:hover .link-main,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card--rss .link-main,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card--site-search .link-main,
.group-board[data-view="icon"] .group-column-direct.icon-view .link-card--rss.link-card--site-search:hover .link-main,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-card--rss .link-main,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-card--site-search .link-main,
.group-board[data-view="icon"] .group-column-popover-links.icon-view .link-card--rss.link-card--site-search:hover .link-main,
.icon-view .link-card--rss .link-main,
.icon-view .link-card--site-search .link-main,
.icon-view .link-card--rss.link-card--site-search:hover .link-main,
.small-icon-view .link-card--rss .link-main,
.small-icon-view .link-card--site-search .link-main,
.small-icon-view .link-card--rss.link-card--site-search .link-main,
.small-icon-view .link-card--rss.link-card--site-search:hover .link-main,
.group-board[data-view="small-icon"] .group-column .link-card--rss .link-main,
.group-board[data-view="small-icon"] .group-column .link-card--site-search .link-main,
.group-board[data-view="small-icon"] .group-column .link-card--rss.link-card--site-search .link-main,
.group-board[data-view="small-icon"] .group-column .link-card--rss.link-card--site-search:hover .link-main {
  padding-right: 0;
}

/* ===== Empty state ===== */
.empty-state[hidden] {
  display: none !important;
}
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 80px 20px; color: var(--muted);
}
.content-empty-hint {
  text-align: center;
  padding: 48px 20px;
  font-size: 14px;
  color: var(--muted);
}
.empty-illustration {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--surface-2);
  margin-bottom: 16px;
  position: relative;
}
.empty-illustration::after {
  content: ""; position: absolute; inset: 22px;
  border: 2px dashed var(--border-strong); border-radius: 10px;
}
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-desc { font-size: 13px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 18, 23, 0.4);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: overlayIn 0.16s ease;
}
.modal-overlay[hidden] {
  display: none !important;
}
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.6); }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-sm { max-width: 380px; }
.modal-link { max-width: 720px; }
.duplicate-modal { max-width: 680px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px 20px 20px; }

.field { display: block; margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}
.field-label em { color: var(--danger); font-style: normal; }
.field-hint {
  font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 4px;
}
.field-input.is-fetching {
  background-image: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-hover) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: fieldShimmer 1.2s ease-in-out infinite;
}
@keyframes fieldShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.field-input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
select.field-input { cursor: pointer; }
.field-input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
.field-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-2); cursor: pointer;
  margin-bottom: 4px; user-select: none;
}
.field-check input {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: transparent;
  position: relative;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.field-check input:hover:not(:disabled) {
  border-color: var(--primary);
}
.field-check input:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.field-check input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.field-check input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.field-check input:disabled {
  opacity: 0.45;
  cursor: default;
}
.field-check input:disabled:checked {
  background: var(--muted);
  border-color: var(--muted);
}

.link-modal-body { padding-top: 16px; }
.link-modal-layout {
  display: flex;
  gap: 20px;
  align-items: stretch;
}
.link-modal-preview-col {
  width: 248px;
  flex-shrink: 0;
}
.link-modal-preview {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
}
.link-modal-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.link-modal-preview-img[hidden] { display: none !important; }
.link-modal-preview-empty,
.link-modal-preview-loading,
.link-modal-preview-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.link-modal-preview-loading,
.link-modal-preview-error { display: none; }
.link-modal-preview.is-loading .link-modal-preview-empty { display: none; }
.link-modal-preview.is-loading .link-modal-preview-loading { display: flex; }
.link-modal-preview.is-error .link-modal-preview-empty { display: none; }
.link-modal-preview.is-error .link-modal-preview-error {
  display: flex;
  color: var(--danger);
}
.link-modal-preview.has-preview .link-modal-preview-empty { display: none; }
.link-modal-fields {
  flex: 1;
  min-width: 0;
}
.link-modal-fields .field:last-of-type { margin-bottom: 0; }

@media (max-width: 640px) {
  .link-modal-layout {
    flex-direction: column;
  }
  .link-modal-preview-col {
    width: 100%;
  }
}

.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.category-last-hint {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.confirm-text { color: var(--text-2); margin-bottom: 4px; }
.import-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-top: 14px;
}
.import-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.18s ease;
}
.import-progress-value {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.duplicate-list {
  max-height: min(52vh, 420px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-top: 12px;
}
.duplicate-list:empty {
  display: none;
}
.duplicate-group {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.duplicate-group:last-child {
  border-bottom: none;
}
.duplicate-url {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 8px;
}
.duplicate-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.duplicate-item + .duplicate-item {
  margin-top: 6px;
}
.duplicate-badge {
  justify-self: start;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-soft);
}
.duplicate-item.is-remove .duplicate-badge {
  color: var(--danger);
  background: var(--danger-soft);
}
.duplicate-name {
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.duplicate-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}

/* ===== Toast ===== */
.toast[hidden] {
  display: none !important;
}
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--ease), transform var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Context menu ===== */
.ctx-menu[hidden] { display: none !important; }
.ctx-menu {
  position: fixed;
  z-index: 160;
  min-width: 168px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.ctx-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}
.ctx-item:hover:not(:disabled) { background: var(--surface-2); }
.ctx-item:disabled { color: var(--muted); cursor: default; }
.ctx-item.is-danger { color: var(--danger); }
.ctx-item.is-danger:hover:not(:disabled) { background: var(--danger-soft); }
.ctx-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

/* ===== Article reader ===== */
.article-reader[hidden] { display: none !important; }
.article-reader {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(16, 18, 23, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 24px;
  animation: overlayIn 0.16s ease;
}
.article-reader-shell {
  width: min(860px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.article-reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.article-reader-nav,
.article-reader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.article-reader-counter {
  min-width: 56px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.article-reader-hint {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.btn-ghost.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.article-reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 40px;
  min-height: 0;
}
.article-reader-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 10px;
}
.article-reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.article-reader-content {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-2);
  word-break: break-word;
}
.article-reader-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 12px 0;
}
.article-reader-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article-reader-content p { margin: 0 0 1em; }
.article-reader-content h1,
.article-reader-content h2,
.article-reader-content h3 {
  color: var(--text);
  margin: 1.4em 0 0.6em;
  line-height: 1.35;
}
.article-reader-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 720px) {
  .article-reader { padding: 0; }
  .article-reader-shell {
    width: 100%;
    border-radius: 0;
    border: none;
  }
  .article-reader-hint { display: none; }
  .article-reader-body { padding: 20px 18px 32px; }
  .article-reader-title { font-size: 20px; }
}

/* ===== Sortable / DnD states ===== */
.sortable-ghost { opacity: 0.35; }
.sortable-chosen { box-shadow: var(--shadow-md); }
.sortable-drag { transform: scale(0.98); opacity: 0.92; }
.category-list.drop-active,
.links-grid.drop-active { outline: 2px dashed var(--primary-ring); outline-offset: 4px; border-radius: var(--radius); }

.edit-mode .link-card {
  cursor: grab;
  user-select: none;
}
.category-drag-enabled .category-item:not([data-cat="all"]) {
  cursor: grab;
  user-select: none;
}
.category-drag-enabled .sortable-chosen,
.category-drag-enabled .sortable-drag,
.edit-mode .sortable-chosen,
.edit-mode .sortable-drag {
  cursor: grabbing !important;
}
body.dnd-active,
body.dnd-active * {
  cursor: grabbing !important;
}
body.dnd-active .sortable-drag,
body.dnd-active .sortable-ghost {
  pointer-events: none;
}
body.category-dragging,
body.category-dragging * {
  cursor: grabbing !important;
}
body.dnd-copy-mode,
body.dnd-copy-mode * {
  cursor: copy !important;
}
.category-item.dnd-drop-target {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
  box-shadow: inset 0 0 0 2px var(--primary);
}
.category-drag-enabled .category-list.dnd-sidebar-active,
.edit-mode .category-list.dnd-sidebar-active {
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  outline: 1px dashed var(--primary-ring);
  outline-offset: 2px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ===== Responsive ===== */

/* --- Tablet (max 1024px) --- */
@media (max-width: 1024px) {
  .group-board {
    column-count: 3 !important;
  }
}

@media (min-width: 721px) {
  .topbar {
    overflow: visible;
  }
  .history-wrap.is-open,
  .history-wrap:hover,
  .history-wrap:focus-within {
    z-index: 70;
  }
  .history-wrap.is-open .history-float-title,
  .history-wrap:hover .history-float-title,
  .history-wrap:focus-within .history-float-title {
    position: absolute;
    left: 42px;
    width: 212px;
    top: -6px;
    z-index: 71;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    pointer-events: none;
    font-size: 13px;
    font-weight: 650;
    color: var(--muted);
  }
  .history-wrap.is-open #historyBtn,
  .history-wrap:hover #historyBtn,
  .history-wrap:focus-within #historyBtn {
    position: relative;
    z-index: 71;
    color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 24%, transparent);
  }
  .history-wrap .history-menu {
    left: -6px;
    top: -6px;
    min-width: 260px;
    padding-top: 52px;
    transform-origin: top left;
  }
  .view-wrap.is-open,
  .view-wrap:focus-within {
    z-index: 180;
  }
  .content:has(.view-wrap.is-open) .content-toolbar,
  .content:has(.view-wrap:focus-within) .content-toolbar {
    z-index: 190;
  }
  .view-wrap.is-open .view-float-title,
  .view-wrap:focus-within .view-float-title {
    position: absolute;
    left: -224px;
    top: -6px;
    transform: none;
    z-index: 181;
    width: 176px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    pointer-events: none;
    font-size: 13px;
    font-weight: 650;
    color: var(--muted);
  }
  .view-wrap.is-open .view-float-title .view-display-current,
  .view-wrap:focus-within .view-float-title .view-display-current {
    color: var(--primary);
  }
  .view-wrap.is-open #viewBtn,
  .view-wrap:focus-within #viewBtn {
    position: relative;
    z-index: 181;
    color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 24%, transparent);
  }
  .view-wrap .view-menu {
    top: -6px;
    right: -6px;
    padding-top: 52px;
    transform-origin: top right;
    z-index: 180;
  }
  .view-wrap .view-menu .view-menu-section-head {
    display: none;
  }
  html.desktop-header-compact .topbar {
    height: 56px;
  }
  html.desktop-header-compact .topbar-inner {
    padding-top: 0;
    padding-bottom: 0;
  }
  html.desktop-header-compact .topbar-center {
    gap: 0;
  }
  html.desktop-header-compact .pinned-links-bar {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
  }
  html.desktop-header-compact .content-toolbar {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px);
    overflow: hidden;
  }
}

/* --- Mobile (max 720px) --- */
@media (max-width: 720px) {
  :root {
    --topbar-h: 112px;
    --mobile-toolbar-h: 41px;
    --mobile-toggle-area-top: var(--topbar-h);
    --sidebar-w: clamp(180px, 58vw, 228px);
    --feed-sidebar-w: min(90vw, 360px);
  }
  html.mobile-chrome-hidden {
    --mobile-toggle-area-top: 0px;
  }
  html {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  html.mobile-panel-open,
  html.mobile-panel-open body {
    overflow: hidden;
    overscroll-behavior: none;
  }
  html.mobile-panel-open body {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
  }
  body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  .app {
    height: auto;
    min-height: 100dvh;
    padding-top: var(--topbar-h);
    transition: padding-top 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  html.mobile-chrome-hidden .app {
    padding-top: var(--topbar-h);
  }
  .topbar-resizer { display: none; }
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(16, 18, 23, 0.06);
    transform: translateY(0);
    transition: height 0.26s cubic-bezier(0.4, 0, 0.2, 1),
      transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
      box-shadow var(--ease), border-color var(--ease);
    overflow: hidden;
    will-change: transform;
  }
  html.mobile-chrome-hidden .topbar {
    transform: translateY(-100%);
    pointer-events: none;
  }
  html.mobile-header-compact .topbar {
    height: 62px;
  }
  [data-theme="dark"] .topbar {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  }
  .topbar-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 44px 48px;
    gap: 3px 8px;
    padding: 8px 12px 9px;
    align-items: center;
    transition: grid-template-rows 0.26s cubic-bezier(0.4, 0, 0.2, 1),
      padding 0.26s cubic-bezier(0.4, 0, 0.2, 1),
      gap 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .topbar-left {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    transition: opacity 0.18s ease, transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .topbar-right {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
    justify-content: flex-end;
    gap: 4px;
    transition: opacity 0.18s ease, transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .topbar-right #editModeToggle,
  .topbar-right > .menu-wrap {
    display: none;
  }
  .topbar-center {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    gap: 6px;
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .topbar-center .web-search-wrap {
    width: 100%;
    margin-left: 0;
  }
  .web-pinned-search-menu {
    position: fixed;
    top: calc(var(--topbar-h) - 10px);
    left: 10px;
    right: 10px;
    transform: none;
    width: auto;
    max-height: min(42dvh, 300px);
  }
  html.mobile-header-compact .web-pinned-search-menu {
    top: 58px;
  }
  html.mobile-header-compact .topbar-inner {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 0 46px;
    gap: 0 8px;
    padding: 8px 10px;
  }
  html.mobile-header-compact .topbar-left,
  html.mobile-header-compact .topbar-right {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-18px) scale(0.96);
  }
  html.mobile-header-compact .pinned-links-bar {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
  }
  html.mobile-header-compact .topbar-center {
    grid-column: 1 / -1;
    grid-row: 2;
    transform: translateY(-2px);
  }
  .topbar .search-input {
    height: 40px;
    font-size: 15px;
    border-radius: 14px;
  }
  .web-search-wrap .topbar-hover-icon.link-icon {
    left: 6px;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
  }
  .web-search-wrap .web-search-input {
    padding-left: 46px;
    padding-right: 78px;
  }
  .web-search-mode-btn {
    width: 36px;
    height: 36px;
    right: 4px;
  }
  .web-search-tool-btn {
    width: 34px;
    height: 34px;
    right: 40px;
  }
  .search-wrap {
    width: min(200px, 42vw);
    min-width: 120px;
  }
  .content-toolbar-right .search-wrap {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    flex: 1;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  .sidebar-wrap {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    width: var(--sidebar-w) !important;
    max-width: calc(100vw - 28px);
    height: 100dvh;
    pointer-events: none;
  }
  .sidebar-wrap .sidebar {
    width: 100%;
    height: 100%;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    will-change: transform;
  }
  .sidebar-wrap:has(.sidebar:not(.collapsed)) .sidebar {
    transform: translateX(0);
  }
  .sidebar-wrap:has(.sidebar.collapsed) .sidebar {
    pointer-events: none;
  }
  .sidebar-wrap .sidebar-toggle {
    position: fixed;
    left: 0;
    top: calc(var(--topbar-h) + var(--mobile-toolbar-h) + ((100dvh - var(--topbar-h) - var(--mobile-toolbar-h)) / 2));
    bottom: auto;
    transform: translateY(-50%);
    z-index: 101;
    width: 16px;
    height: 56px;
    padding-bottom: 0;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: auto;
    opacity: 1;
    transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.4, 0, 0.2, 1),
      color var(--ease), background var(--ease), border-color var(--ease);
  }
  .sidebar-wrap .sidebar-toggle svg,
  .feed-sidebar-wrap .feed-sidebar-toggle svg {
    width: 14px;
    height: 14px;
  }
  .sidebar-wrap .sidebar-toggle svg {
    transform: translateX(-2px);
  }
  .feed-sidebar-wrap .feed-sidebar-toggle svg {
    transform: rotate(180deg) translateX(-2px);
  }
  .sidebar-wrap .sidebar-toggle:hover,
  .feed-sidebar-wrap .feed-sidebar-toggle:hover,
  .sidebar-wrap .sidebar-toggle:active,
  .feed-sidebar-wrap .feed-sidebar-toggle:active {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }
  .sidebar-wrap .sidebar-toggle:active {
    transform: translateY(-50%) scale(0.96);
  }
  .sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle,
  .sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle:active {
    transform: translateY(-50%);
  }
  .sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle:active {
    transform: translateY(-50%) scale(0.96);
  }
  .sidebar-wrap:has(.sidebar:not(.collapsed)) .sidebar-toggle {
    display: none;
  }
  .col-resizer,
  .panel-resizer-h { display: none; }
  .link-detail-collapse-btn { display: flex; }
  .sidebar .link-detail,
  .sidebar .link-detail-controls {
    display: none;
  }
  .body:has(.sidebar:not(.collapsed)) .feed-sidebar-toggle,
  .body:has(.feed-sidebar:not(.collapsed)) .sidebar-toggle {
    display: none;
  }
  .body:has(.view-wrap.is-open) .sidebar-toggle,
  .body:has(.view-wrap.is-open) .feed-sidebar-toggle,
  .body:has(.history-wrap:focus-within) .sidebar-toggle,
  .body:has(.history-wrap:focus-within) .feed-sidebar-toggle,
  .body:has(.feed-view-wrap.is-open) .sidebar-toggle,
  .body:has(.feed-view-wrap.is-open) .feed-sidebar-toggle {
    display: none;
  }
  .search-kbd { display: none; }
  .brand-name {
    display: inline;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .btn-primary span { display: none; }
  .body {
    min-height: 0;
    height: auto;
    min-height: calc(100dvh - var(--topbar-h));
    margin-top: 0;
    transition: margin-top 0.28s cubic-bezier(0.4, 0, 0.2, 1),
      min-height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  html.mobile-chrome-hidden .body {
    min-height: calc(100dvh - var(--topbar-h));
    margin-top: 0;
  }
  .content {
    position: relative;
    overflow: visible;
  }
  .content-body {
    padding: 50px 16px max(72px, calc(48px + env(safe-area-inset-bottom)));
    scroll-padding-top: 72px;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: auto;
    transition: padding-top 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  html.mobile-chrome-hidden .content-body {
    padding-top: 50px;
    scroll-padding-top: 72px;
  }
  .content-toolbar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    z-index: 45;
    padding: 0 12px;
    gap: 8px;
    background: color-mix(in srgb, var(--surface) 54%, transparent);
    -webkit-backdrop-filter: saturate(190%) blur(22px);
    backdrop-filter: saturate(190%) blur(22px);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 58%, transparent);
    box-shadow: 0 12px 28px color-mix(in srgb, var(--bg) 42%, transparent);
    transform: translateY(0);
    transition: top 0.26s cubic-bezier(0.4, 0, 0.2, 1),
      transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.2s ease, background var(--ease), border-color var(--ease);
    will-change: transform;
  }
  html.mobile-header-compact:not(.mobile-chrome-hidden) .content-toolbar {
    top: 62px;
  }
  .body:has(.view-wrap.is-open) .content-toolbar {
    transform: none;
  }
  html.mobile-chrome-hidden .content-toolbar {
    transform: translateY(calc(-1 * var(--topbar-h) - 100% - 8px));
    pointer-events: none;
  }
  html.mobile-chrome-hidden .body:has(.view-wrap.is-open) .content-toolbar {
    transform: none;
    pointer-events: auto;
  }
  .content-toolbar-slot {
    flex: 0 0 auto;
    min-height: 40px;
  }
  .content-toolbar-right {
    flex: 1;
    min-width: 0;
  }
  .content-toolbar-right .view-wrap {
    display: block;
    flex: 0 0 auto;
  }
  .content-toolbar-right .search-input {
    height: 40px;
    border-radius: 12px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }
  .content-toolbar-right .search-wrap,
  .content-toolbar-right #searchInput {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }
  .content-toolbar-right #searchInput {
    -webkit-appearance: none;
    appearance: none;
  }
  .content-toolbar-right .search-input:focus {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }
  .content-toolbar-right #searchInput:focus {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }
  .history-wrap .history-menu,
  .view-wrap .view-menu,
  .feed-view-wrap .feed-view-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(var(--topbar-h) + var(--mobile-toolbar-h) + 8px);
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: min(calc(100dvh - var(--topbar-h) - var(--mobile-toolbar-h) - 20px), 520px);
    overflow: auto;
    z-index: 120;
  }
  .history-wrap .history-menu {
    position: absolute;
    left: 0;
    right: auto;
    top: calc(100% + 8px);
    width: min(320px, calc(100vw - 24px));
    max-height: min(56dvh, 430px);
  }
  .content-toolbar-right .view-wrap:focus-within:not(.is-open) .view-menu,
  .history-wrap:hover:not(.is-open) .history-menu,
  .history-wrap:focus-within:not(.is-open) .history-menu,
  .feed-view-wrap:focus-within .feed-view-menu {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .history-wrap.is-open .history-menu,
  .content-toolbar-right .view-wrap.is-open .view-menu,
  .feed-view-wrap.is-open .feed-view-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .view-wrap.is-open .view-menu,
  .feed-view-wrap.is-open .feed-view-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .content-toolbar-right .view-wrap .view-menu {
    position: absolute;
    left: auto;
    right: 0;
    top: calc(100% + 8px);
    bottom: auto;
    transform: none;
    animation: none;
    width: min(168px, calc(100vw - 24px));
    max-height: none;
    overflow: visible;
    padding: 6px 0 8px;
  }
  .content-toolbar-right .view-wrap .view-menu::-webkit-scrollbar {
    display: none;
  }
  @keyframes mobileSheetIn {
    from { opacity: 0; transform: translateX(-50%) translateY(calc(-100% - var(--topbar-h) - 64px - max(4px, env(safe-area-inset-bottom)))); }
    to { opacity: 1; transform: translateX(-50%) translateY(calc(-100% - var(--topbar-h) - 76px - max(12px, env(safe-area-inset-bottom)))); }
  }
  .content-toolbar-right .view-options-grid {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 2px 10px 8px;
  }
  .content-toolbar-right .view-type-option {
    min-height: 48px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 10px;
  }
  .content-toolbar-right .view-type-icon {
    width: 28px;
    flex: 0 0 28px;
  }
  .content-toolbar-right .view-type-label {
    text-align: left;
    font-size: 13px;
  }
  .content-toolbar-right .view-menu-section {
    padding: 7px 12px 4px;
  }
  .content-toolbar-right .view-display-options {
    grid-template-columns: 1fr;
    padding: 2px 8px 6px;
  }
  .content-toolbar-right .view-check {
    padding: 6px 8px;
    font-size: 12.5px;
  }
  .content-toolbar-right .view-size-block {
    display: none;
  }
  .content-toolbar-right .view-size-tip {
    display: none;
  }
  .feed-sidebar-wrap {
    position: fixed;
    right: 0;
    top: 0;
    z-index: 100;
    width: var(--feed-sidebar-w) !important;
    max-width: calc(100vw - 28px);
    height: 100dvh;
    pointer-events: none;
  }
  .feed-sidebar-wrap .feed-sidebar {
    width: 100%;
    height: 100%;
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    will-change: transform;
  }
  html.mobile-sidebar-dragging .sidebar-wrap .sidebar,
  html.mobile-sidebar-dragging .feed-sidebar-wrap .feed-sidebar {
    transition: none;
  }
  .feed-sidebar-wrap:has(.feed-sidebar:not(.collapsed)) .feed-sidebar {
    transform: translateX(0);
  }
  .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar {
    pointer-events: none;
  }
  .feed-sidebar-wrap .feed-sidebar-toggle {
    position: fixed;
    right: 0;
    left: auto;
    top: calc(var(--topbar-h) + var(--mobile-toolbar-h) + ((100dvh - var(--topbar-h) - var(--mobile-toolbar-h)) / 2));
    bottom: auto;
    transform: translateY(-50%);
    z-index: 101;
    width: 16px;
    height: 56px;
    padding-bottom: 0;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: auto;
    opacity: 1;
    transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.4, 0, 0.2, 1),
      color var(--ease), background var(--ease), border-color var(--ease);
  }
  .feed-sidebar-wrap .feed-sidebar-toggle:active {
    transform: translateY(-50%) scale(0.96);
  }
  .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle,
  .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle:active {
    transform: translateY(-50%);
  }
  .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle:active {
    transform: translateY(-50%) scale(0.96);
  }
  html.mobile-side-toggles-hidden .sidebar-wrap .sidebar-toggle,
  html.mobile-side-toggles-hidden .feed-sidebar-wrap .feed-sidebar-toggle,
  html.mobile-gesture-hide-toggles .sidebar-wrap .sidebar-toggle,
  html.mobile-gesture-hide-toggles .feed-sidebar-wrap .feed-sidebar-toggle {
    pointer-events: none;
  }
  html.mobile-side-toggles-hidden .sidebar-wrap .sidebar-toggle,
  html.mobile-gesture-hide-toggles .sidebar-wrap .sidebar-toggle {
    transform: translateY(-50%) translateX(calc(-100% - 4px));
  }
  html.mobile-side-toggles-hidden .feed-sidebar-wrap .feed-sidebar-toggle,
  html.mobile-gesture-hide-toggles .feed-sidebar-wrap .feed-sidebar-toggle {
    transform: translateY(-50%) translateX(calc(100% + 4px));
  }
  html.mobile-side-toggles-hidden .sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle,
  html.mobile-side-toggles-hidden .sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle:active,
  html.mobile-gesture-hide-toggles .sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle,
  html.mobile-gesture-hide-toggles .sidebar-wrap:has(.sidebar.collapsed) .sidebar-toggle:active {
    transform: translateY(-50%) translateX(calc(-100% - 4px));
  }
  html.mobile-side-toggles-hidden .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle,
  html.mobile-side-toggles-hidden .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle:active,
  html.mobile-gesture-hide-toggles .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle,
  html.mobile-gesture-hide-toggles .feed-sidebar-wrap:has(.feed-sidebar.collapsed) .feed-sidebar-toggle:active {
    transform: translateY(-50%) translateX(calc(100% + 4px));
  }
  .feed-sidebar-wrap:has(.feed-sidebar:not(.collapsed)) .feed-sidebar-toggle {
    display: none;
  }
  .group-board {
    column-count: 2 !important;
    column-gap: 12px;
  }
  .pinned-links-bar {
    gap: 4px;
    transition: opacity 0.18s ease, max-height 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .pinned-links-label { display: none; }
  .group-column {
    padding: 8px 0;
    margin-bottom: 14px;
  }
  .group-column-title {
    font-size: max(var(--view-text-min), calc(16px * var(--view-size) / 100));
  }
  .group-column-sub-title {
    font-size: max(var(--view-text-min), calc(13px * var(--view-size) / 100));
  }
  .group-column-sub + .group-column-sub {
    margin-top: 22px;
  }
  .group-column-sub.collapsed + .group-column-sub,
  .group-column-sub + .group-column-sub.collapsed {
    margin-top: 10px;
  }
  .group-column-sub-head {
    margin-bottom: 10px;
  }
  .group-column.collapsed .group-column-head,
  .group-column-sub.collapsed .group-column-sub-head {
    margin-bottom: 0;
  }
  .group-column-head .group-column-batch-search,
  .group-column-sub-head .group-column-batch-search {
    display: none;
  }
  .group-column-sub .group-column-visible.links-grid {
    padding-left: 10px;
  }
  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 156px), 1fr));
    gap: 10px;
  }
  .links-grid.large-view {
    grid-template-columns: 1fr;
  }
  .links-grid.card-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .list-view,
  .compact-view {
    gap: 6px;
  }
  .link-card {
    min-height: 58px;
    border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    box-shadow: 0 1px 2px rgba(16, 18, 23, 0.04);
  }
  .link-card:active {
    transform: scale(0.985);
    background: var(--surface-2);
  }
  .link-card-tools,
  .link-card--site-search:not(.link-card--rss):hover .link-card-tools {
    opacity: 1;
    pointer-events: auto;
  }
  .link-rss,
  .link-site-search {
    width: 34px;
    height: 34px;
  }
  .link-card--rss .link-main,
  .link-card--rss.link-card--site-search .link-main,
  .link-card--rss.link-card--site-search:hover .link-main {
    padding-right: 74px;
  }
  .category-item {
    min-height: 44px;
    border-radius: 12px;
  }
  .sidebar,
  .feed-sidebar {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .content-body,
  .link-card,
  .category-list,
  .category-item,
  .sidebar,
  .feed-sidebar,
  .pinned-links-bar {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  input,
  textarea,
  [contenteditable="true"] {
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    user-select: text;
  }
  /* Mobile overlay backdrop */
  .mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  .mobile-sidebar-backdrop.is-visible {
    display: block;
    opacity: 1;
  }
  .mobile-menu-backdrop {
    display: none;
    position: fixed;
    inset: var(--topbar-h) 0 0;
    background: rgba(16, 18, 23, 0.28);
    -webkit-backdrop-filter: saturate(160%) blur(7px);
    backdrop-filter: saturate(160%) blur(7px);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }
  .mobile-menu-backdrop.is-visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

/* --- Small phone (max 480px) --- */
@media (max-width: 480px) {
  :root {
    --topbar-h: 108px;
  }
  html.mobile-header-compact .topbar {
    height: 62px;
  }
  .topbar-inner { gap: 2px 6px; padding: 8px 10px 8px; }
  .topbar-center { transform: translateY(-2px); }
  .topbar-right { gap: 2px; }
  .brand-name { max-width: 34vw; }
  .group-board {
    column-count: 1 !important;
  }
  .content-body { padding: 48px 16px max(68px, calc(44px + env(safe-area-inset-bottom))); }
  html.mobile-chrome-hidden .content-body { padding-top: 48px; }
  .content-toolbar { padding: 0 10px; }
  .pinned-links-bar { display: none; }
  .web-search-tool-btn { display: inline-flex; }
  .web-search-wrap .web-search-input { padding-right: 82px; }
  .links-grid {
    grid-template-columns: 1fr;
  }
  .links-grid.card-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .icon-view {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .small-icon-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .icon-view .link-card,
  .small-icon-view .link-card {
    min-height: 56px;
  }
  .modal-overlay {
    align-items: flex-end;
    padding: 12px 10px max(10px, env(safe-area-inset-bottom));
  }
  .modal {
    max-height: min(88dvh, 680px);
    overflow: auto;
    border-radius: 16px 16px 12px 12px;
  }
  .field-row {
    flex-direction: column;
    gap: 0;
  }
}

/* --- Touch device: no hover effects --- */
@media (hover: none) {
  .pinned-link-item:hover {
    opacity: 0.5;
    transform: none;
  }
  .pinned-link-item:hover .link-icon {
    width: 18px;
    height: 18px;
  }
  .link-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
  .group-board .group-column:has(.link-card:hover) {
    background: transparent;
  }
  /* Larger touch targets */
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .menu-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .category-item {
    min-height: 40px;
  }
}

