:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #647084;
  --line: #dfe6ef;
  --accent: #1e293b;
  --accent-hover: #0f172a;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 38px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p {
  margin-top: 6px;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dark-button,
.ghost-button,
.light-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}

.dark-button {
  position: relative;
  min-height: 38px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.dark-button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.ghost-button,
.light-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  font-weight: 700;
}

.ghost-button:hover,
.light-button:hover {
  border-color: #c6d0df;
  background: #f8fafc;
}

.danger-button {
  min-height: 34px;
  padding: 0 10px;
  background: #fee2e2;
  color: var(--danger);
  font-weight: 700;
}

.icon-button {
  width: 34px;
  height: 34px;
  background: #eef2f7;
  color: #475569;
  font-size: 20px;
  line-height: 1;
}

.full-button {
  width: 100%;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin: 14px 0 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-box span,
.form-stack label span,
.admin-field span {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-filter,
.tag-chip {
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag-filter {
  cursor: pointer;
}

.tag-filter.is-active {
  background: var(--accent);
  color: #fff;
}

.count-pill,
.browser-hint {
  border-radius: 999px;
  padding: 8px 12px;
  background: #eef2f7;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.browser-hint {
  margin-bottom: 14px;
  border: 1px solid #fde68a;
  background: #fef9c3;
  color: #854d0e;
  white-space: normal;
}

.section-stack {
  display: grid;
  gap: 16px;
}

.nav-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  font-size: 20px;
  letter-spacing: 0;
}

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
}

.section-count {
  color: #475569;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 12px;
  padding: 14px;
}

.nav-card {
  display: flex;
  flex-direction: column;
  min-height: 196px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.nav-card h3 {
  padding-right: 8px;
  font-size: 19px;
  line-height: 1.25;
  word-break: break-word;
}

.domain {
  margin-top: 6px;
  color: #64748b;
  font-size: 13px;
  word-break: break-all;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.note {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-footer {
  margin-top: auto;
  padding-top: 14px;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
}

.empty-state {
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.page-footer {
  padding: 20px 6px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.notice-dot {
  display: none;
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #ef4444;
}

.notice-dot.is-visible {
  display: block;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
}

.modal.is-open {
  display: flex;
}

.modal-panel {
  width: min(680px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.small-panel {
  width: min(460px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 18px;
}

.modal-body {
  padding: 16px 18px;
  overflow: auto;
}

.notice-list {
  display: grid;
  gap: 12px;
}

.notice-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.notice-card h3 {
  font-size: 16px;
}

.notice-date {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.notice-content {
  margin-top: 10px;
  color: #334155;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.form-stack label,
.admin-field {
  display: grid;
  gap: 6px;
}

.form-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.form-status.ok {
  color: var(--ok);
}

.form-status.error {
  color: var(--danger);
}

.admin-page {
  background: #eef2f7;
}

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #fff;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-logo .brand-mark {
  width: 42px;
  height: 42px;
  background: #fff;
  color: #111827;
}

.admin-logo h1 {
  font-size: 18px;
}

.admin-logo p {
  margin-top: 2px;
  color: #cbd5e1;
  font-size: 12px;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.admin-nav button {
  border: 0;
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.admin-nav button.is-active,
.admin-nav button:hover {
  background: #1f2937;
  color: #fff;
}

.sidebar-actions {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
}

.admin-main {
  padding: 18px;
  min-width: 0;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-top h2 {
  font-size: 24px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(310px, 420px) 1fr;
  gap: 14px;
  align-items: start;
}

.admin-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.admin-panel-head h3 {
  font-size: 16px;
}

.admin-panel-body {
  padding: 14px;
}

.admin-form {
  display: grid;
  gap: 10px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.check-row input {
  width: auto;
}

.list-stack {
  display: grid;
  gap: 8px;
}

.sort-card {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.sort-card[draggable="true"] {
  cursor: grab;
}

.sort-card.is-dragging {
  opacity: 0.45;
}

.drag-handle {
  color: #94a3b8;
  text-align: center;
  font-weight: 900;
}

.card-title {
  font-weight: 800;
  word-break: break-word;
}

.card-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.list-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.mini-button:hover {
  background: #f8fafc;
}

.mini-button.danger {
  color: var(--danger);
  background: #fff5f5;
}

.color-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 24px;
}

.login-card p {
  margin: 8px 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.import-box {
  min-height: 240px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

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

  .top-actions {
    justify-content: flex-start;
  }

  .control-strip,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .sidebar-actions {
    position: static;
    margin-top: 14px;
  }

  .admin-nav {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell,
  .admin-main {
    width: min(100% - 18px, 1160px);
    padding-left: 0;
    padding-right: 0;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    font-size: 13px;
  }

  .brand h1 {
    font-size: 24px;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .admin-row,
  .color-row {
    grid-template-columns: 1fr;
  }

  .sort-card {
    grid-template-columns: 20px 1fr;
  }

  .sort-card .list-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}
