:root {
  --panel-rgb: 61 56 108;
  --panel-strong-rgb: 78 67 132;
  --panel-opacity: 0.64;
  --panel-strong-opacity: 0.76;
  --panel: rgb(var(--panel-rgb) / var(--panel-opacity));
  --panel-strong: rgb(var(--panel-strong-rgb) / var(--panel-strong-opacity));
  --panel-soft: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.13);
  --line-bright: rgba(255, 255, 255, 0.25);
  --text: #eef3ff;
  --muted: rgba(238, 243, 255, 0.66);
  --faint: rgba(238, 243, 255, 0.42);
  --accent: #8bdcff;
  --accent-2: #a78bfa;
  --warn: #ff9898;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
  --stage-width: 1840px;
  --ui-scale: 0.78;
  --wallpaper-opacity: 1;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

body[data-theme="light"] {
  --panel-rgb: 255 255 255;
  --panel-strong-rgb: 245 248 255;
  --panel-soft: rgba(12, 22, 45, 0.06);
  --line: rgba(20, 35, 70, 0.14);
  --line-bright: rgba(20, 35, 70, 0.24);
  --text: #172033;
  --muted: rgba(23, 32, 51, 0.68);
  --faint: rgba(23, 32, 51, 0.42);
  --accent: #0f7498;
  --accent-2: #6366f1;
  --warn: #ba2f2f;
  --shadow: 0 20px 60px rgba(44, 55, 88, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: #0b1227;
  overflow-x: hidden;
}

body[data-theme="light"] {
  background: #edf3fb;
}

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

button {
  cursor: pointer;
}

.background-scene {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 22% 18%, rgba(72, 106, 190, 0.34), transparent 30%),
    radial-gradient(circle at 64% 16%, rgba(118, 76, 174, 0.34), transparent 28%),
    radial-gradient(circle at 62% 72%, rgba(187, 88, 137, 0.18), transparent 34%),
    linear-gradient(150deg, #071327 0%, #141d45 45%, #2b2156 70%, #101a36 100%);
  background-position: center;
  background-size: cover;
  opacity: var(--wallpaper-opacity);
}

.background-scene.has-image {
  background-image:
    linear-gradient(rgba(8, 13, 30, 0.44), rgba(8, 13, 30, 0.56)),
    var(--wallpaper-url);
}

.background-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.027) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 50px 50px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.76), transparent 86%);
}

.scale-stage {
  width: min(var(--stage-width), calc((100vw - 40px) / var(--ui-scale)));
  margin: 0 auto;
  zoom: var(--ui-scale);
}

.page-shell {
  padding: 34px 0 58px;
}

.hero-bar {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) auto minmax(420px, 2.1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 5px;
  background: linear-gradient(135deg, #d4f0ff, #7184df);
  color: #17203d;
  font-size: 1.05rem;
  font-weight: 900;
}

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

h1 {
  overflow: hidden;
  color: var(--text);
  font-size: 1.06rem;
  letter-spacing: 0;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand p {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-badge {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(139, 220, 255, 0.28);
  border-radius: 6px;
  background: rgba(22, 128, 161, 0.16);
  color: #d2f5ff;
  font-size: 0.72rem;
  font-weight: 760;
  white-space: nowrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-bright);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.search-box span {
  color: var(--muted);
  font-size: 1rem;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-box input::placeholder {
  color: var(--faint);
}

.clock {
  color: var(--text);
  font-size: 1.17rem;
  font-weight: 720;
  white-space: nowrap;
}

.summary-line {
  min-height: 20px;
  margin: 16px 2px 15px;
  color: var(--muted);
  font-size: 0.76rem;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px 8px;
}

.link-section {
  min-width: 0;
}

.link-section h2 {
  margin-bottom: 9px;
  color: rgba(238, 243, 255, 0.86);
  font-size: 0.92rem;
  letter-spacing: 0;
}

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

.link-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 5px;
  background: rgb(var(--panel-strong-rgb) / var(--panel-strong-opacity));
  color: inherit;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.link-card:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 220, 255, 0.35);
  background: var(--panel-strong);
}

.link-icon {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 880;
}

.link-icon img {
  width: 19px;
  height: 19px;
  object-fit: contain;
}

.link-icon span {
  display: none;
}

.link-icon.fallback img {
  display: none;
}

.link-icon.fallback span {
  display: block;
}

.link-content {
  min-width: 0;
}

.link-title {
  overflow: hidden;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-description {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  padding: 56px 16px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--text);
  font-size: 1rem;
}

.floating-wallpaper,
.floating-edit {
  position: fixed;
  z-index: 6;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(139, 220, 255, 0.5);
  border-radius: 8px;
  background: rgba(19, 37, 77, 0.78);
  color: #bdefff;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.floating-wallpaper {
  left: 22px;
  bottom: 22px;
}

.floating-edit {
  right: 22px;
  bottom: 22px;
}

.editor-dialog,
.wallpaper-dialog {
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: rgb(var(--panel-rgb) / 0.96);
  box-shadow: var(--shadow);
}

.editor-dialog {
  width: min(1120px, calc(100% - 28px));
  max-height: min(800px, calc(100vh - 28px));
}

.wallpaper-dialog {
  width: min(520px, calc(100% - 28px));
}

.editor-dialog::backdrop,
.wallpaper-dialog::backdrop {
  background: rgba(5, 8, 18, 0.66);
  backdrop-filter: blur(8px);
}

.editor-shell {
  max-height: inherit;
  overflow: auto;
}

.editor-header,
.wallpaper-panel header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgb(var(--panel-rgb) / 0.92);
  backdrop-filter: blur(16px);
}

.editor-header p,
.wallpaper-panel header p {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.editor-header h2,
.wallpaper-panel h2 {
  font-size: 1rem;
}

.editor-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 18px;
}

.edit-form,
.category-manager,
.data-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.editor-panel {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  min-width: 0;
}

.panel-title h3 {
  color: var(--text);
  font-size: 0.95rem;
}

.panel-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

.edit-form label,
.wallpaper-url,
.wallpaper-upload,
.range-setting {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.appearance-controls {
  display: grid;
  gap: 14px;
  margin: 0 18px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.theme-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
}

.theme-toggle button {
  min-height: 28px;
  border: 0;
  border-radius: 5px;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  font-weight: 780;
}

.theme-toggle button.active {
  color: var(--text);
  background: rgb(var(--panel-strong-rgb) / 0.72);
}

.range-setting span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.range-setting output {
  color: var(--text);
  font-weight: 800;
}

.range-setting input {
  width: 100%;
  accent-color: var(--accent);
}

.wallpaper-upload {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin: 0 18px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
}

.wallpaper-upload p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.45;
}

.edit-form input,
.edit-form textarea,
.edit-form select,
.category-add input,
.category-row input,
.wallpaper-url input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: 0;
}

.edit-form select option {
  color: #111827;
}

.edit-form input:focus,
.edit-form textarea:focus,
.edit-form select:focus,
.category-add input:focus,
.category-row input:focus,
.wallpaper-url input:focus {
  border-color: rgba(139, 220, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 220, 255, 0.12);
}

.category-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.category-list,
.card-list {
  display: grid;
  gap: 8px;
}

.category-row,
.edit-row {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
}

.category-row {
  grid-template-columns: 1fr auto;
}

.edit-row {
  grid-template-columns: 1fr auto;
}

.edit-row-info {
  min-width: 0;
}

.edit-row-title {
  font-weight: 830;
  font-size: 0.82rem;
}

.edit-row-meta {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-row-actions,
.category-actions,
.data-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.mini-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 760;
}

.primary-button {
  border-color: rgba(139, 220, 255, 0.4);
  background: rgba(44, 151, 198, 0.45);
}

.danger-button,
.mini-button.danger {
  color: #ffd0d0;
  border-color: rgba(255, 152, 152, 0.38);
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 1.08rem;
}

.mini-button {
  min-width: 32px;
  padding: 0 9px;
}

.notice {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.6;
}

.sync-notice {
  display: grid;
  gap: 4px;
}

.sync-notice span {
  color: var(--text);
  font-weight: 820;
}

.sync-notice small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.notice code {
  color: #c9f4ff;
  font-weight: 800;
}

.wallpaper-panel {
  margin: 0;
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 18px 10px;
}

.wallpaper-choice {
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--preview);
  background-size: cover;
  background-position: center;
}

.wallpaper-choice.active {
  outline: 2px solid rgba(139, 220, 255, 0.9);
  outline-offset: 2px;
}

.wallpaper-url {
  padding: 0 18px 14px;
}

.wallpaper-panel .form-actions {
  padding: 0 18px 18px;
}

@media (max-width: 1180px) {
  .scale-stage {
    width: min(var(--stage-width), calc((100vw - 28px) / var(--ui-scale)));
  }

  .hero-bar {
    grid-template-columns: 1fr auto;
  }

  .search-box {
    grid-column: 1 / -1;
  }

  .section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-layout,
  .editor-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .scale-stage {
    width: min(100% - 22px, var(--stage-width));
    zoom: 1;
  }

  .page-shell {
    padding-top: 22px;
  }

  .hero-bar {
    grid-template-columns: 1fr;
  }

  .clock {
    justify-self: start;
  }

  .section-grid,
  .wallpaper-grid {
    grid-template-columns: 1fr;
  }

  .wallpaper-upload {
    grid-template-columns: 1fr;
  }

  .editor-layout,
  .editor-header,
  .wallpaper-panel header {
    padding: 16px;
  }

  .category-add,
  .category-row,
  .edit-row {
    grid-template-columns: 1fr;
  }
}
