/* ── Atlas · modern personal launcher ── */

:root {
  /* 参考 hao.studygolang.com 的配色体系 */
  --bg: #f1f4f9;
  --bg-elevated: #ffffff;
  --bg-muted: #f5f7fa;
  --text: #3c3c3c;
  --text-secondary: #5c6570;
  --text-tertiary: #8f8f8f;
  --border: rgba(15, 20, 25, 0.08);
  --border-strong: rgba(15, 20, 25, 0.12);
  --accent: #4e81e4;
  --accent-hover: #1856cf;
  --accent-soft: rgba(78, 129, 228, 0.1);
  --accent-text: #1856cf;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #b45309;
  --shadow-sm: 0 1px 2px rgba(15, 20, 25, 0.04);
  --shadow: 0 1px 3px rgba(15, 20, 25, 0.04), 0 8px 24px rgba(15, 20, 25, 0.06);
  --shadow-lg: 0 4px 6px rgba(15, 20, 25, 0.03), 0 16px 40px rgba(15, 20, 25, 0.08);
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-full: 999px;
  --font: Tahoma, Verdana, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "SF Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --header-h: 64px;
  --max: 1080px;
  /* 前台参考风格：纯蓝顶栏 + 深蓝搜索按钮 */
  --header-blue: #4e81e4;
  --header-btn: #1856cf;
  --header-menu-text: #d9efff;
  --footer-text: #dff2ff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --bg-elevated: #14181f;
    --bg-muted: #1a1f28;
    --text: #f1f3f5;
    --text-secondary: #9aa3af;
    --text-tertiary: #6b7380;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.15);
    --accent-text: #93c5fd;
    --success: #34d399;
    --success-bg: rgba(5, 150, 105, 0.15);
    --success-border: rgba(52, 211, 153, 0.3);
    --danger: #f87171;
    --danger-bg: rgba(220, 38, 38, 0.15);
    --danger-border: rgba(248, 113, 113, 0.3);
    --warn-bg: rgba(180, 83, 9, 0.15);
    --warn-border: rgba(251, 191, 36, 0.3);
    --warn-text: #fbbf24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Shell ── */

.shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

/* ── Top bar ── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 -1.25rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  color: inherit;
}

.brand:hover {
  color: inherit;
}

.brand-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  display: block;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

.brand-logo-lg {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  margin: 0 auto 1.25rem;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.05rem;
}

.brand-title {
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 34px;
  padding: 0 0.85rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s, color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

a.btn-chip {
  color: var(--text-secondary);
}

.btn-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-muted);
  box-shadow: var(--shadow-sm);
}

/* ── 前台 · 纯蓝顶栏（参考 hao.studygolang.com） ── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--header-blue);
  box-shadow: 0 2px 12px rgba(32, 76, 160, 0.18);
}

.site-header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  color: #fff;
}

.site-brand:hover {
  color: #fff;
}

.site-brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: block;
}

.site-brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.site-brand-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
}

.site-brand-sub {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--header-menu-text);
  white-space: nowrap;
}

/* 搜索区 */
.site-search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 520px;
  margin: 0 auto;
}

.search-engines {
  display: flex;
  gap: 0.15rem;
  margin-bottom: 0.3rem;
}

.search-engine {
  height: auto;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--header-menu-text);
  background: transparent;
  border: none;
  border-radius: 3px 3px 0 0;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.search-engine:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.search-engine.is-active {
  color: var(--header-btn);
  background: #fff;
}

.search-form {
  display: flex;
  height: 36px;
  border-radius: 3px;
  overflow: hidden;
  background: #fff;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-btn {
  height: 100%;
  padding: 0 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--header-btn);
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.search-btn:hover {
  background: #1248b0;
}

.site-header-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-link {
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--header-menu-text);
  white-space: nowrap;
}

.header-link:hover {
  color: #fff;
}

/* ── 横向分类导航（蓝色区域内） ── */

.primary-menus {
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.primary-menus-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.primary-menus-inner::-webkit-scrollbar {
  display: none;
}

.menu-link {
  display: block;
  padding: 0.55rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--header-menu-text);
  white-space: nowrap;
  border-radius: 3px 3px 0 0;
  transition: background 0.15s, color 0.15s;
}

.menu-link:hover {
  color: #fff;
}

.menu-link.is-active {
  color: var(--text);
  background: var(--bg);
}

/* ── 主体内容区 ── */

.page-body {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

/* ── Category sections ── */

.sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.section {
  background: #fff;
  border: none;
  border-radius: 10px;
  box-shadow: none;
  padding: 1.1rem 1.4rem 1.3rem;
  scroll-margin-top: 118px;
  animation: fade-up 0.45s var(--ease) both;
}

.section:nth-child(1) { animation-delay: 0.04s; }
.section:nth-child(2) { animation-delay: 0.1s; }
.section:nth-child(3) { animation-delay: 0.16s; }
.section:nth-child(4) { animation-delay: 0.22s; }
.section:nth-child(5) { animation-delay: 0.28s; }

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section-head {
  margin-bottom: 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.section-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #333;
}

/* Link grid — 参考站：26px 圆图标 + 粗体名称 + 灰色描述 */
.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.15rem 0.75rem;
}

.tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  min-height: 48px;
  padding: 0.45rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  box-shadow: none;
  transition: background 0.15s;
  text-align: left;
}

.tile:hover {
  color: var(--text);
  background: var(--bg);
}

.tile-icon {
  --tile-hue: 210;
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  background: hsl(var(--tile-hue) 58% 46%);
}

.tile-favicon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
  background: #fff;
  border-radius: inherit;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.15s;
}

.tile-icon.is-loaded .tile-favicon {
  opacity: 1;
}

.tile-icon.is-fallback .tile-favicon,
.tile-favicon.is-broken {
  display: none;
}

.tile-letter {
  position: relative;
  z-index: 0;
  line-height: 1;
  user-select: none;
}

.tile-icon.is-loaded .tile-favicon:not(.is-broken) ~ .tile-letter {
  opacity: 0;
}

.tile-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.tile-label {
  display: block;
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-description {
  display: block;
  overflow: hidden;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-tertiary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty */
.empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty p {
  margin: 0 0 0.5rem;
  color: var(--text-secondary);
}

.empty p:last-child {
  margin-bottom: 0;
}

.empty strong {
  color: var(--text);
  font-weight: 600;
}

.empty a {
  font-weight: 600;
}

/* ── 页脚 ── */

.site-footer {
  margin-top: 1.5rem;
}

.footer-bar {
  padding: 0.85rem 1.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--footer-text);
  background: var(--header-blue);
}

/* ── 返回顶部 ── */

.back-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  z-index: 70;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.05rem;
  color: #fff;
  background: var(--header-blue);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(37, 60, 130, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, background 0.15s, transform 0.1s;
}

.back-top.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.back-top:hover {
  background: var(--header-btn);
}

/* ── 前台布局覆盖：匹配参考站的顶栏、左栏、内容区结构 ── */
.frontend-page {
  --bg: #f1f4f9;
  --bg-elevated: #ffffff;
  --text: #263445;
  --text-secondary: #526173;
  --text-tertiary: #69788a;
  --accent: #4e81e4;
  --accent-text: #245bc1;
  --max: 1440px;
  --sidebar-width: 142px;
  --header-height: 106px;
  background: var(--bg);
  color: var(--text);
}

.frontend-page .site-header-inner {
  max-width: var(--max);
  min-height: 72px;
}

.frontend-page .site-header {
  position: sticky;
  top: 0;
  z-index: 60;
}

.frontend-page .primary-menus {
  align-self: stretch;
  width: var(--sidebar-width);
  height: 100%;
  overflow-y: auto;
  border: 1px solid #e1e8f2;
  border-radius: 12px;
  background: #fff;
  box-shadow: 1px 0 10px rgba(30, 55, 90, 0.08);
}

.frontend-page .primary-menus-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  min-height: 100%;
  padding: 1rem 0.75rem;
}

.frontend-page .menu-link {
  padding: 0.7rem 0.8rem;
  color: #526173;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
}

.frontend-page .menu-link:hover {
  color: #245bc1;
  background: #f2f6ff;
}

.frontend-page .menu-link.is-active {
  color: #245bc1;
  background: #e8f0ff;
}

.frontend-page .page-body {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 2.75rem;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: stretch;
  gap: 1.5rem;
}

.frontend-page .sections {
  min-width: 0;
  gap: 1.5rem;
}

.frontend-page .section {
  padding: 1.25rem 1.5rem 1.4rem;
  border: 0;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(30, 55, 90, 0.045);
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.frontend-page .section-title {
  font-size: 1.125rem;
  color: #263445;
}

.frontend-page .tiles {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem 1rem;
}

.frontend-page .tile {
  min-height: 58px;
  padding: 0.6rem 0.65rem;
}

.frontend-page .tile:hover {
  background: #f5f8fd;
}

.frontend-page .tile-icon {
  width: 30px;
  height: 30px;
}

.frontend-page .tile-label {
  font-size: 1rem;
  font-weight: 600;
}

.frontend-page .tile-description {
  color: #526173;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}

.frontend-page .site-footer {
  margin-left: 0;
}

@media (min-width: 1200px) {
  .frontend-page .tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1600px) {
  .frontend-page .tiles {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .frontend-page {
    --header-height: auto;
  }

  .frontend-page .page-body {
    grid-template-columns: 1fr;
  }

  .frontend-page .primary-menus {
    position: static;
    width: auto;
    height: 52px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: var(--accent);
    box-shadow: none;
  }

  .frontend-page .primary-menus-inner {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 0 1rem;
  }

  .frontend-page .menu-link {
    color: var(--header-menu-text);
    border-radius: 3px 3px 0 0;
  }

  .frontend-page .menu-link.is-active {
    color: var(--text);
    background: var(--bg);
  }

  .frontend-page .page-body {
    padding: 1rem 1rem 2rem;
  }

  .frontend-page .site-footer {
    margin-left: 0;
  }

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

@media (max-width: 520px) {
  .frontend-page .site-header-inner {
    flex-wrap: wrap;
    gap: 0.6rem 0.8rem;
    padding: 0.65rem 0.85rem;
  }

  .frontend-page .site-brand {
    flex: 1 1 auto;
  }

  .frontend-page .site-search {
    order: 3;
    flex-basis: 100%;
  }

  .frontend-page .page-body {
    padding: 0.85rem 0.75rem 2rem;
  }

  .frontend-page .tiles {
    grid-template-columns: 1fr;
  }

  .frontend-page .section {
    padding: 0.85rem;
  }
}

@media (prefers-color-scheme: dark) {
  .frontend-page {
    --bg: #f1f4f9;
    --bg-elevated: #ffffff;
    --text: #263445;
    --text-secondary: #526173;
    --text-tertiary: #69788a;
    --accent: #4e81e4;
    --accent-text: #245bc1;
  }

  .frontend-page .section,
  .frontend-page .primary-menus {
    background: #fff;
  }

  .frontend-page .section-title,
  .frontend-page .tile-label {
    color: #263445;
  }

  .frontend-page .tile-description {
    color: #526173;
  }
}

/* ── Admin ── */

.admin-hero {
  padding: 1.75rem 0 1.25rem;
}

.admin-hero h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.admin-hero p {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.admin-tabs button {
  height: 40px;
  color: var(--text-secondary);
  background: transparent;
  box-shadow: none;
}

.admin-tabs button:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.admin-tabs button.is-active {
  color: var(--text);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.admin-panel[hidden] {
  display: none;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.card-head h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 1.15rem 1.2rem 1.25rem;
}

.flash {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
  font-size: 0.875rem;
  font-weight: 550;
}

.flash::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.err {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 550;
}

.banner {
  margin: 0 0 1rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.8125rem;
  font-weight: 550;
}

.hint {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 0.875rem;
}

/* Forms */
.field {
  margin: 0 0 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-secondary);
}

.field-help {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.file-input {
  padding: 7px 0.75rem !important;
}

.grid-form {
  display: grid;
  gap: 0.85rem 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-form.cols-2 {
    grid-template-columns: 1fr 1fr;
  }

  .grid-form.cols-3 {
    grid-template-columns: 1.2fr 1fr auto;
  }

  .grid-form.cols-4 {
    grid-template-columns: 1fr 1.4fr 0.8fr 0.55fr;
  }

  .grid-form .span-full {
    grid-column: 1 / -1;
  }
}

/* Unified control — same look as login password field */
.field input:not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
.field select,
.ui-input {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 42px;
  margin: 0;
  padding: 0 0.85rem;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.field input::placeholder,
.ui-input::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

.field input:hover:not(:disabled):not(:focus),
.field select:hover:not(:disabled):not(:focus),
.ui-input:hover:not(:disabled):not(:focus) {
  border-color: color-mix(in srgb, var(--text-tertiary) 55%, var(--border-strong));
}

.field input:focus,
.field select:focus,
.ui-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background-color: var(--bg-elevated);
}

.field input:disabled,
.field select:disabled,
.ui-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.field select,
select.ui-input {
  cursor: pointer;
  line-height: normal;
  padding-right: 2.25rem;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 12px;
}

.field select:focus,
select.ui-input:focus {
  background-color: var(--bg-elevated);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 12px;
}

/* Kill browser autofill yellow/blue so fields stay on-brand */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px var(--bg) inset;
  transition: background-color 99999s ease-out;
}

.form-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.form-foot.end {
  align-self: end;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 42px;
  padding: 0 1.1rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

button:hover,
.btn:hover {
  background: var(--accent-hover);
  color: #fff;
}

button:active,
.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  color: var(--text);
  background: var(--bg-muted);
  box-shadow: none;
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg);
  color: var(--text);
}

a.btn-secondary {
  color: var(--text);
  line-height: 42px;
}

.btn-ghost {
  height: 34px;
  padding: 0 0.7rem;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--accent-text);
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.btn-danger {
  height: 34px;
  padding: 0 0.65rem;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--danger);
  background: transparent;
  box-shadow: none;
}

.btn-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.inline-form {
  display: inline;
}

/* Data list */
.list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: background 0.12s;
}

.list li:last-child {
  border-bottom: none;
}

.list li:hover {
  background: var(--bg-muted);
}

.list-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.5rem;
}

.list-title {
  font-weight: 550;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

a.list-title:hover {
  color: var(--accent-text);
}

.list-meta {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 22px;
  padding: 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 550;
  color: var(--text-secondary);
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  vertical-align: middle;
}

.list-description,
.list-url {
  flex: 1 0 100%;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-url {
  font-family: var(--font-mono);
}

.list-actions {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
  align-self: center;
}

.move-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.2rem;
}

.move-actions form,
.list-actions form {
  display: inline-flex;
}

.btn-move {
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text-secondary);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-move:hover:not(:disabled) {
  color: var(--accent-text);
  background: var(--accent-soft);
}

.btn-move:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.link-groups {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.link-group-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0 0.15rem;
}

.link-group-head h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 650;
}

.link-group-head span {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.link-group .list {
  margin-top: 0.55rem;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, color-mix(in srgb, var(--accent) 18%, transparent), transparent),
    var(--bg);
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem 1.5rem;
  animation: fade-up 0.4s var(--ease) both;
}

.login-box h1 {
  margin: 0;
  text-align: center;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.login-box .login-desc {
  margin: 0.4rem 0 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.login-box button[type="submit"] {
  width: 100%;
  height: 44px;
  margin-top: 0.5rem;
}

.login-back {
  display: block;
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

.login-back:hover {
  color: var(--accent-text);
}

/* Responsive */
@media (max-width: 900px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 720px) {
  /* 顶栏折行：品牌一行，搜索一行 */
  .site-header-inner {
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
    padding: 0.6rem 1rem 0.75rem;
  }

  .site-brand-logo {
    width: 32px;
    height: 32px;
  }

  .site-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    margin: 0;
  }

}

@media (max-width: 520px) {
  .admin-tabs {
    gap: 0.25rem;
  }

  .admin-tabs button {
    padding: 0 0.4rem;
    font-size: 0.8125rem;
  }

  .sortable-list li {
    flex-wrap: nowrap;
  }

  .btn-move {
    width: 29px;
  }

  .tiles {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .tile {
    min-height: 58px;
    padding: 0.5rem 0.6rem;
  }

  .tile-icon {
    width: 36px;
    height: 36px;
  }

  .site-brand-sub {
    display: none;
  }

  .page-body {
    padding: 0.85rem 0.85rem 2rem;
  }

  .section {
    padding: 0.85rem 0.85rem 0.95rem;
  }

  .list-url {
    display: none;
  }

  .list-actions {
    margin-left: auto;
  }

  .back-top {
    right: 0.85rem;
    bottom: 1rem;
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .tile:hover {
    transform: none;
  }
}
