/* All layout and theme styles live here. No webfonts or external stylesheets. */
:root {
  color-scheme: light;
  --background: #f8f9f7;
  --surface: #ffffff;
  --text: #282e2b;
  --muted: #737973;
  --border: #e4e8e2;
  --accent: #426958;
  --accent-soft: #eaf0e9;
  --hover-border: #bdcbbf;
  --icon-background: #f3f5f1;
  --shadow: 0 4px 16px rgb(35 47 36 / 4%);
  --warning: #94502e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #202422;
  --surface: #292e2b;
  --text: #e5eae4;
  --muted: #a1aba2;
  --border: #373e39;
  --accent: #b2cbb6;
  --accent-soft: #323f35;
  --hover-border: #637a69;
  --icon-background: #353d37;
  --shadow: 0 4px 16px rgb(0 0 0 / 10%);
  --warning: #e5b197;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
svg { display: block; width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.page-shell { max-width: 1440px; min-height: 100vh; margin: 0 auto; padding: 0 56px; display: flex; flex-direction: column; }
.site-header { min-height: 100px; display: flex; justify-content: space-between; align-items: center; gap: 24px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; font-size: 16px; font-weight: 650; letter-spacing: -.4px; }
#site-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: var(--accent); background: var(--accent-soft); }
.brand-mark svg { width: 23px; height: 23px; stroke-width: 1.45; }
.header-actions { display: flex; align-items: center; gap: 24px; flex-shrink: 0; }
.header-link, .theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; font-size: 12px; color: var(--muted); white-space: nowrap; transition: color 150ms ease; }
.header-link svg { width: 13px; height: 13px; }
.header-link:hover, .theme-toggle:hover { color: var(--text); }
.edit-link { border: 0; background: transparent; padding: 0; color: var(--accent); }
.action-divider { height: 18px; width: 1px; background: var(--border); }
.theme-toggle { border: 0; background: transparent; padding: 0; min-width: 77px; justify-content: flex-start; }
.theme-toggle svg { width: 16px; height: 16px; }
main { flex: 1; }
.welcome { padding: 57px 0 32px; }
.eyebrow { margin: 0 0 15px; display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 10px; font-weight: 650; letter-spacing: 1.9px; line-height: 1.5; }
.status-dot { width: 6px; height: 6px; flex-shrink: 0; background: var(--accent); border-radius: 50%; }
h1 { font-size: clamp(28px, 3vw, 38px); font-weight: 560; letter-spacing: -1.4px; line-height: 1.25; margin: 0; overflow-wrap: anywhere; }
.welcome-description { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 12px 0 27px; overflow-wrap: anywhere; }
.search { display: flex; align-items: center; gap: 13px; height: 56px; max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 17px; box-shadow: 0 2px 4px rgb(20 40 20 / 2%); transition: border-color 150ms ease, box-shadow 150ms ease; }
.search:focus-within { border-color: var(--hover-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { color: var(--muted); flex-shrink: 0; }
.search input { width: 100%; min-width: 0; background: transparent; border: 0; color: var(--text); outline: none; font-size: 13px; line-height: 1.5; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
kbd { display: inline-grid; place-items: center; min-width: 21px; height: 23px; padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); background: var(--background); font: 11px ui-monospace, monospace; }
.clear-search { border: 0; padding: 6px; margin-right: -6px; background: transparent; color: var(--muted); }
.collection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 23px; margin-bottom: 27px; border-bottom: 1px solid var(--border); }
.category-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-button { border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 6px; padding: 8px 12px; min-height: 36px; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; transition: background 150ms ease, color 150ms ease; }
.filter-button:hover { color: var(--text); background: var(--accent-soft); }
.filter-button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.result-count { margin: 0; color: var(--muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.collections { display: grid; gap: 29px; padding-bottom: 46px; }
.collection { min-width: 0; animation: appear 240ms ease both; }
.collection-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.collection-icon { color: var(--accent); display: grid; place-items: center; }
.collection-icon svg { width: 16px; height: 16px; }
.collection h2 { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.5; letter-spacing: .1px; overflow-wrap: anywhere; }
.collection-count { color: var(--muted); font-size: 10px; min-width: 19px; height: 19px; display: grid; place-items: center; background: var(--accent-soft); border-radius: 5px; font-variant-numeric: tabular-nums; }
.card-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.card-grid li { min-width: 0; }
.website-card { position: relative; min-width: 0; height: 86px; padding: 17px 14px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease; }
.website-card:hover { transform: translateY(-2px); border-color: var(--hover-border); box-shadow: var(--shadow); }
.favicon { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; position: relative; border-radius: 9px; background: var(--icon-background); color: var(--accent); overflow: hidden; }
.favicon-letter { font-size: 17px; font-weight: 600; }
.favicon img { position: absolute; inset: 0; margin: auto; width: 23px; height: 23px; object-fit: contain; }
.favicon.has-image { background: #f5f6f3; }
.favicon.has-image .favicon-letter { visibility: hidden; }
.card-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; line-height: 1.35; }
.card-description { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; line-height: 1.4; }
.card-arrow { position: absolute; top: 7px; right: 7px; color: var(--muted); opacity: 0; transition: opacity 150ms ease; }
.card-arrow svg { width: 11px; height: 11px; }
.website-card:hover .card-arrow, .website-card:focus-visible .card-arrow { opacity: 1; }
.empty-state { text-align: center; padding: 56px 16px 80px; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 18px; background: var(--accent-soft); color: var(--accent); border-radius: 13px; }
.empty-state h2 { font-weight: 550; font-size: 20px; margin: 0 0 10px; }
.empty-state p { color: var(--muted); font-size: 13px; line-height: 1.7; }
.reset-filters { display: inline-flex; align-items: center; gap: 12px; margin-top: 14px; border: 1px solid var(--border); border-radius: 7px; padding: 10px 15px; background: var(--surface); font-size: 12px; }
.site-footer { border-top: 1px solid var(--border); padding: 23px 0 28px; display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.site-footer p { margin: 0; }
.keyboard-hint { display: flex; align-items: center; gap: 7px; }
.keyboard-hint kbd { min-width: 17px; height: 19px; font-size: 10px; padding: 0 4px; }
.keyboard-hint span { margin: 0 5px; }
.noscript-message { padding: 32px 0; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 10; top: 8px; left: 8px; padding: 12px 16px; border-radius: 6px; background: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
@keyframes appear { from { opacity: .6; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

/* 可视化编辑器，与导航页共用主题。原生 dialog 提供模态焦点与 Esc 关闭。 */
body:has(dialog[open]) { overflow: hidden; }
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 0; margin: auto; max-width: calc(100% - 32px); max-height: calc(100dvh - 40px); box-shadow: 0 22px 90px rgb(0 0 0 / 18%); }
dialog::backdrop { background: rgb(18 29 23 / 38%); }
.editor-dialog { width: 840px; }
.entry-dialog { width: 490px; }
.confirm-dialog { width: 430px; }
.copy-dialog { width: 680px; }
.copy-content { display: block; width: 100%; min-width: 0; height: clamp(160px, 40vh, 360px); padding: 13px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--background); font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; resize: vertical; tab-size: 2; }
.copy-content:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.editor-panel { padding: 27px; }
.editor-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.editor-header .eyebrow { font-size: 9px; letter-spacing: 1.7px; margin-bottom: 9px; }
dialog h2 { font-size: 23px; line-height: 1.4; font-weight: 600; margin: 0; }
.editor-intro { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 13px 0 22px; }
.editor-toolbar, .editor-actions, .editor-feedback, .entry-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.editor-toolbar, .editor-feedback { justify-content: space-between; }
.editor-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); font-size: 12px; line-height: 1.5; }
.editor-button:hover { background: var(--accent-soft); border-color: var(--hover-border); }
.editor-button.primary { color: var(--surface); background: var(--accent); border-color: var(--accent); }
.editor-button.primary:hover { filter: brightness(.94); }
.text-button { border: 0; background: transparent; color: var(--accent); min-height: 36px; font-size: 12px; padding: 5px 0; }
button:disabled { opacity: .35; cursor: default; }
.editor-filter { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.editor-filter select { max-width: 170px; height: 36px; padding: 0 25px 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.editor-feedback { margin: 13px 0; gap: 4px 12px; }
.editor-feedback p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.editor-warning { background: var(--background); border-left: 2px solid var(--warning); border-radius: 3px; padding: 10px 12px; font-size: 12px; line-height: 1.7; color: var(--warning); overflow-wrap: anywhere; }
.editor-list { max-height: 46vh; min-height: 80px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; padding: 0 5px 0 0; margin-top: 12px; overscroll-behavior: contain; }
.editor-category { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; margin-bottom: 15px; }
.editor-category:last-child { margin-bottom: 0; }
.editor-category-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; background: var(--background); }
.editor-category-title { display: flex; align-items: center; gap: 9px; min-width: 0; margin: 0; font-size: 13px; font-weight: 600; }
.editor-category-title svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--accent); }
.editor-category-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-category-title small { font-size: 10px; color: var(--muted); font-weight: 400; }
.row-actions { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.icon-button { display: inline-grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border: 0; border-radius: 5px; background: transparent; font-size: 18px; color: var(--muted); padding: 0; }
.icon-button svg { width: 15px; height: 15px; }
.icon-button:hover:not(:disabled) { background: var(--accent-soft); color: var(--text); }
.editor-website { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 11px 9px 15px; border-top: 1px solid var(--border); }
.editor-website-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.editor-website-copy strong { font-size: 12px; font-weight: 550; }
.editor-website-copy span { font-size: 10px; color: var(--muted); }
.editor-website-copy > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-to-category { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--border); background: transparent; padding: 11px 15px; color: var(--accent); font-size: 11px; }
.add-to-category:hover { background: var(--accent-soft); }
.editor-no-data { text-align: center; padding: 20px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.editor-footer { border-top: 1px solid var(--border); padding-top: 17px; margin-top: 20px; }
.editor-footer p { font-size: 11px; color: var(--muted); line-height: 1.8; margin: 12px 0 0; }
.editor-footer a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.editor-fields { padding: 0; margin: 0; border: 0; min-width: 0; }
.editor-field { display: block; font-size: 12px; font-weight: 500; margin-top: 19px; }
.editor-field input, .editor-field select { display: block; width: 100%; min-width: 0; color: var(--text); background: var(--background); border: 1px solid var(--border); border-radius: 7px; padding: 11px 12px; margin-top: 8px; outline: none; font-size: 14px; }
.editor-field input:focus, .editor-field select:focus, .editor-filter select:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 1px; }
.editor-field small, .optional { font-weight: 400; color: var(--muted); font-size: 11px; }
.editor-field small { display: block; line-height: 1.6; margin-top: 7px; }
.optional { padding-left: 5px; }
.entry-footer { justify-content: flex-end; margin-top: 24px; }
.entry-footer .editor-button { min-width: 72px; }
.confirm-dialog p { color: var(--muted); font-size: 13px; line-height: 1.9; overflow-wrap: anywhere; }

@media (max-width: 560px) {
  dialog { max-width: calc(100% - 20px); max-height: calc(100dvh - 24px); border-radius: 12px; }
  .editor-panel { padding: 19px 16px; }
  dialog h2 { font-size: 21px; }
  .editor-toolbar { align-items: stretch; gap: 14px; }
  .editor-filter { width: 100%; justify-content: space-between; }
  .editor-filter select { max-width: 210px; width: 65%; }
  .editor-list { max-height: 41vh; padding-right: 0; }
  .editor-category-heading { padding: 8px; gap: 5px; }
  .editor-category-title { gap: 5px; font-size: 12px; }
  .row-actions { gap: 0; }
  .editor-website { flex-wrap: wrap; gap: 4px; padding: 10px; }
  .editor-website-copy { flex: 1 1 120px; }
  .icon-button { width: 32px; height: 36px; }
  .editor-intro { font-size: 12px; }
  .editor-field input, .editor-field select, .editor-filter select { font-size: 16px; }
  .copy-content { font-size: 16px; }
  .editor-footer .editor-actions { gap: 8px; }
}

@media (min-width: 1680px) {
  .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .welcome { padding-top: 64px; }
}
@media (max-width: 1100px) {
  .page-shell { padding: 0 36px; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .result-count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (max-width: 760px) {
  .page-shell { padding: 0 24px; }
  .site-header { min-height: 83px; gap: 12px; }
  .header-actions { gap: 15px; }
  .brand { font-size: 14px; gap: 8px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  #github-link, .action-divider { display: none; }
  .welcome { padding: 38px 0 25px; }
  h1 { letter-spacing: -.9px; }
  .collection-toolbar { padding-bottom: 20px; margin-bottom: 25px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .collections { gap: 26px; padding-bottom: 35px; }
  .keyboard-hint { display: none; }
  .site-footer { justify-content: center; }
}
@media (max-width: 480px) {
  .page-shell { padding: 0 18px; }
  .site-header { flex-wrap: wrap; padding: 17px 0 13px; gap: 8px; }
  .header-actions { gap: 12px; }
  .edit-link { gap: 5px; }
  .header-link, .theme-toggle { font-size: 11px; min-height: 36px; }
  .theme-toggle { min-width: 66px; gap: 5px; }
  .welcome { padding-top: 32px; }
  .eyebrow { font-size: 9px; letter-spacing: 1.5px; }
  h1 { max-width: 310px; font-size: 29px; }
  .welcome-description { font-size: 12px; margin-bottom: 22px; }
  .search { padding: 0 13px; gap: 9px; height: 52px; }
  .search input { font-size: 16px; }
  .search input::placeholder { font-size: 12px; }
  #search-shortcut { display: none; }
  .category-filters { gap: 4px; }
  .filter-button { padding: 8px 10px; font-size: 11px; }
  .website-card { height: 105px; padding: 13px 11px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 9px; }
  .favicon { width: 27px; height: 27px; flex-basis: 27px; border-radius: 6px; }
  .favicon img { width: 20px; height: 20px; }
  .favicon-letter { font-size: 15px; }
  .card-copy { width: 100%; gap: 4px; }
  .card-name { font-size: 12px; }
  .card-description { font-size: 10px; }
}
@media (max-width: 340px) {
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .website-card { height: 80px; flex-direction: row; align-items: center; gap: 12px; }
  .card-copy { width: auto; }
  .site-header { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .website-card:hover { transform: none; }
}
