:root {
  color-scheme: light;
  --background: #f7f6f3;
  --surface: #ffffff;
  --surface-soft: #f9f9f8;
  --line: #e7e4de;
  --line-soft: rgba(17, 17, 17, 0.07);
  --ink: #111111;
  --muted: #787774;
  --black-hover: #333333;
  --focus: rgba(31, 108, 159, 0.16);

  --blue-bg: #e1f3fe;
  --blue-text: #1f6c9f;
  --green-bg: #edf3ec;
  --green-text: #346538;
  --red-bg: #fdebec;
  --red-text: #9f2f2d;
  --yellow-bg: #fbf3db;
  --yellow-text: #956400;

  --sans: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Times New Roman", "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --mono: "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  --radius-large: 12px;
  --radius-small: 6px;
  --radius-input: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--blue-bg);
  color: var(--blue-text);
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px 24px 56px;
}

/* Header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.host:focus-visible,
.open-link:focus-visible,
.close-button:focus-visible,
.tag-filter button:focus-visible {
  outline: 2px solid var(--blue-text);
  outline-offset: 2px;
}

.button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--black-hover);
  border-color: var(--black-hover);
}

.button.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.button.ghost:hover {
  border-color: #d4d0c8;
  background: var(--surface-soft);
}

.button:active {
  transform: scale(0.99);
}

/* Editorial hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: end;
  padding: clamp(42px, 7vw, 84px) 0 clamp(36px, 5vw, 64px);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-title {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: clamp(46px, 8vw, 96px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.hero-description {
  width: min(680px, 100%);
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.7;
}

.hero-stats {
  display: grid;
  gap: 1px;
  margin: 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
}

.hero-stats div {
  background: var(--surface);
  padding: 18px 20px;
}

.hero-stats dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.hero-stats dd {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 650;
}

.hero-stats .status {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 9999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.hero-stats .status.loading {
  background: var(--yellow-bg);
  color: var(--yellow-text);
}

.hero-stats .status.ready {
  background: var(--green-bg);
  color: var(--green-text);
}

.hero-stats .status.error {
  background: var(--red-bg);
  color: var(--red-text);
}

/* Toolbar */

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.search-box,
.filter-box {
  min-width: 0;
}

.search-box {
  display: grid;
  gap: 8px;
  align-content: center;
}

.search-box span,
.filter-heading {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.filter-box {
  display: grid;
  gap: 12px;
  align-content: center;
}

.filter-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

input,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: #a5a29b;
}

input:focus,
textarea:focus {
  border-color: #b8dcef;
  box-shadow: 0 0 0 3px var(--focus);
}

textarea {
  min-height: 112px;
  resize: vertical;
}

.tag-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: #d9d5cd transparent;
}

.tag-filter::-webkit-scrollbar {
  height: 5px;
}

.tag-filter::-webkit-scrollbar-thumb {
  background: #d9d5cd;
  border-radius: 999px;
}

.chip {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  min-height: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.chip .tag-name,
.chip .remove-global {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chip .tag-name {
  padding: 0 12px;
  cursor: pointer;
}

.chip .remove-global {
  padding: 0 10px 0 8px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}

.chip .remove-global:hover {
  background: var(--red-bg);
  color: var(--red-text);
}

.chip:hover {
  border-color: #d4d0c8;
  background: var(--surface-soft);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.chip.active .remove-global {
  border-left-color: rgba(255, 255, 255, 0.24);
  color: rgba(255, 255, 255, 0.78);
}

.chip.active .remove-global:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr));
  gap: 20px;
  padding-top: 28px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.cover-link {
  position: relative;
  display: block;
  color: inherit;
  text-decoration: none;
}

.cover-link::after {
  content: "打开链接";
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 1;
  padding: 7px 10px;
  border-radius: var(--radius-small);
  background: rgba(17, 17, 17, 0.88);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.cover-link:hover::after,
.cover-link:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.cover-link:hover .cover img {
  opacity: 0.94;
}

.cover-link:focus-visible {
  outline: 2px solid var(--blue-text);
  outline-offset: -2px;
}

.cover {
  height: 176px;
  margin-top: 16px;
  overflow: hidden;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-soft);
}

.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.host {
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  color: var(--blue-text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.note.empty-note {
  color: #a5a29b;
  font-weight: 450;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 6px 0 11px;
  border-radius: 9999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.tag-tone-0 {
  background: var(--blue-bg);
  color: var(--blue-text);
}

.tag-tone-1 {
  background: var(--green-bg);
  color: var(--green-text);
}

.tag-tone-2 {
  background: var(--yellow-bg);
  color: var(--yellow-text);
}

.tag-tone-3 {
  background: var(--red-bg);
  color: var(--red-text);
}

.tag button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: inherit;
  font-family: var(--mono);
  font-size: 10px;
}

.tag button:hover {
  background: rgba(17, 17, 17, 0.08);
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.open-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-small);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.open-link:hover {
  background: var(--ink);
  color: #ffffff;
}

.card-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
}

.icon-button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.icon-button.danger:hover {
  background: var(--red-bg);
  color: var(--red-text);
}

/* Loading and empty */

.loading-card {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.empty {
  margin-top: 28px;
  padding: clamp(56px, 10vw, 96px) 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
  text-align: center;
}

.empty-badge {
  display: inline-block;
  margin: 0;
  padding: 5px 10px;
  border-radius: 9999px;
  background: var(--yellow-bg);
  color: var(--yellow-text);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.empty h2 {
  margin: 18px 0 8px;
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.empty p:last-child {
  width: min(480px, 100%);
  margin: 0 auto;
  color: var(--muted);
}

/* Footer */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Dialog */

.dialog {
  width: min(580px, calc(100vw - 32px));
  max-height: min(88vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
  color: var(--ink);
}

.dialog::backdrop {
  background: rgba(17, 17, 17, 0.34);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.close-button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.close-button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.dialog-body {
  display: grid;
  gap: 18px;
  padding: 24px;
  overflow: auto;
}

.dialog label {
  display: grid;
  gap: 7px;
}

.dialog label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-small);
  background: var(--red-bg);
  color: var(--red-text);
  font-size: 14px;
}

/* Toast */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  padding: 12px 16px;
  border-radius: var(--radius-small);
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* Responsive */

@media (max-width: 900px) {
  .page {
    padding: 16px 16px 44px;
  }

  .hero {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 22px;
    padding-top: 32px;
  }

  .toolbar {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .cards {
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .button {
    flex: 1;
  }

  .hero-title {
    font-size: clamp(42px, 13vw, 64px);
  }

  .cover {
    height: 150px;
  }

  .card-content {
    padding: 18px;
  }

  .note {
    font-size: 19px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

