/* ==========================================================================
   Constellation — 站点样式（移动端优先，无构建，单文件）
   颜色、字号、间距全部用 CSS 变量，方便后续扩展。
   ========================================================================== */

:root {
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --radius-sm: 4px;
  --radius-md: 8px;

  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */

  --font-body: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, 'Noto Sans', sans-serif;

  /* Light theme (default) */
  --bg: #fafafa;
  --fg: #111827;
  --muted: #6b7280;
  --muted-bg: #f3f4f6;
  --border: #e5e7eb;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --button-bg: #2563eb;
  --button-fg: #ffffff;
  --button-hover: #1d4ed8;
  --error-bg: #fef2f2;
  --error-fg: #b91c1c;
  --error-border: #fecaca;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c10;
    --fg: #f3f4f6;
    --muted: #9ca3af;
    --muted-bg: #1f2937;
    --border: #374151;
    --link: #60a5fa;
    --link-hover: #93c5fd;
    --card-bg: #111827;
    --card-border: #374151;
    --button-bg: #3b82f6;
    --button-fg: #0b0c10;
    --button-hover: #60a5fa;
    --error-bg: #450a0a;
    --error-fg: #fca5a5;
    --error-border: #7f1d1d;
  }
}

/* Reset + base */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); font-size: var(--text-base); line-height: 1.6;
       color: var(--fg); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column;
       overflow-wrap: anywhere; word-wrap: break-word; }

.skip-link { position: absolute; top: -100%; left: var(--space-md); padding: var(--space-sm) var(--space-md);
             background: var(--button-bg); color: var(--button-fg); border-radius: var(--radius-sm);
             z-index: 100; }
.skip-link:focus { top: var(--space-md); }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); margin-top: var(--space-lg); }
h3 { font-size: var(--text-lg); margin-top: var(--space-md); }
h4 { font-size: var(--text-base); margin-top: var(--space-sm); }

p { margin-top: var(--space-sm); overflow-wrap: anywhere; }
.lede { font-size: var(--text-lg); color: var(--muted); margin-top: var(--space-md); }
.small { font-size: var(--text-sm); color: var(--muted); }
.muted { color: var(--muted); }
.big { font-size: var(--text-xl); }

.wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 var(--space-md); }

/* Header */
.site-header { background: var(--card-bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: var(--text-lg); color: var(--fg); text-decoration: none; flex-shrink: 0; }
.main-nav { display: flex; gap: var(--space-sm); flex-wrap: wrap; justify-content: flex-end; }
.main-nav a { padding: var(--space-xs) var(--space-sm); font-size: var(--text-sm); color: var(--fg); white-space: nowrap; }
.main-nav a:hover { color: var(--link); text-decoration: none; background: var(--muted-bg); border-radius: var(--radius-sm); }

/* Breadcrumbs */
.breadcrumbs { padding: var(--space-sm) 0; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: var(--space-xs); list-style: none; font-size: var(--text-sm); }
.breadcrumbs li::after { content: '/'; margin-left: var(--space-xs); color: var(--muted); }
.breadcrumbs li:last-child::after { content: ''; }
.breadcrumbs a { color: var(--muted); white-space: nowrap; }
.breadcrumbs a:hover { color: var(--link); }
.breadcrumbs span[aria-current='page'] { color: var(--fg); font-weight: 500; }

/* Main */
main { flex: 1; padding: var(--space-lg) 0; }

/* Panels & cards */
.panel { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: var(--space-md); margin-top: var(--space-md); }
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); overflow: hidden; }

/* Sign grid */
.sign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-sm); list-style: none; margin-top: var(--space-md); padding: 0; }
.sign-grid.compact { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.sign-card { display: flex; flex-direction: column; align-items: center; padding: var(--space-sm); text-align: center; text-decoration: none; color: inherit; }
.sign-card:hover { text-decoration: none; background: var(--muted-bg); }
.sign-name { font-weight: 600; }
.sign-dates { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }
.sign-meta { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }

/* Link lists */
.link-list { list-style: none; padding: 0; margin-top: var(--space-md); }
.link-list li { margin-bottom: var(--space-sm); }
.link-list li p { margin-top: var(--space-xs); }

/* Facts */
.facts { list-style: none; padding: 0; margin-top: var(--space-sm); }
.facts li { padding: var(--space-xs) 0; border-bottom: 1px solid var(--border); }
.facts li:last-child { border-bottom: none; }

/* Buttons */
.button, button[type='submit'] { display: inline-block; padding: var(--space-sm) var(--space-md); background: var(--button-bg); color: var(--button-fg); border: none; border-radius: var(--radius-sm); font-size: var(--text-base); font-weight: 600; cursor: pointer; text-decoration: none; }
.button:hover, button[type='submit']:hover { background: var(--button-hover); color: var(--button-fg); text-decoration: none; }

/* Forms */
.tool-form { margin-top: var(--space-md); }
.field { margin-bottom: var(--space-md); }
.field label { display: block; margin-bottom: var(--space-xs); font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; max-width: 100%; padding: var(--space-sm); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); color: var(--fg); font-size: var(--text-base); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 2px rgba(37,99,235,0.2); }
.field .small { display: block; margin-top: var(--space-xs); }
.field .error { color: var(--error-fg); background: var(--error-bg); border: 1px solid var(--error-border); padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-sm); margin-top: var(--space-xs); font-size: var(--text-sm); }

/* Result panels */
.result { border-color: var(--link); }
.result .big { word-break: keep-all; }

/* Reading body */
.reading-body { margin-top: var(--space-md); line-height: 1.7; }
.entry-body { margin-top: var(--space-md); line-height: 1.7; }
.entry-body h2, .entry-body h3 { margin-top: var(--space-lg); }
.entry-body p { margin-top: var(--space-sm); }
.entry-body ul, .entry-body ol { margin-top: var(--space-sm); padding-left: var(--space-lg); }
.entry-body li { margin-top: var(--space-xs); }
.entry-body a { text-decoration: underline; }

/* Footer */
.site-footer { background: var(--card-bg); border-top: 1px solid var(--border); margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-lg); padding: var(--space-xl) 0; }
.site-footer h2 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: var(--space-sm); }
.site-footer ul.plain { list-style: none; padding: 0; }
.site-footer ul.plain li { margin-bottom: var(--space-xs); }
.site-footer ul.plain a { color: var(--fg); font-size: var(--text-sm); }
.site-footer ul.plain a:hover { color: var(--link); }
.footer-note { padding: var(--space-md) 0; border-top: 1px solid var(--border); text-align: center; font-size: var(--text-sm); color: var(--muted); }

/* Window links */
.window-links { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-md); padding: 0; list-style: none; }
.window-links a { padding: var(--space-xs) var(--space-sm); background: var(--muted-bg); border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--fg); white-space: nowrap; }
.window-links a:hover { background: var(--border); color: var(--link); text-decoration: none; }

/* Ads placeholder */
.adsense { margin: var(--space-lg) 0; text-align: center; min-height: 90px; }

/* ==========================================================================
   Responsive breakpoints
   ========================================================================== */

/* Tablet and small desktop */
@media (max-width: 768px) {
  .wrap { padding: 0 var(--space-md); }
  .sign-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .sign-grid.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .main-nav { justify-content: center; width: 100%; margin-top: var(--space-sm); }
  .header-inner { justify-content: center; }
  .brand { margin-bottom: var(--space-xs); }
  .breadcrumbs ol { justify-content: center; }
  .window-links { justify-content: center; }
  .window-links a { white-space: normal; }
  .window-links a::after { content: none; }
  .main-nav a { font-size: var(--text-sm); padding: var(--space-xs) var(--space-sm); }
}

/* Mobile (390px and below) */
@media (max-width: 390px) {
  .wrap { padding: 0 var(--space-sm); }
  .sign-grid { grid-template-columns: repeat(2, 1fr); }
  .sign-grid.compact { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1fr; }
  .main-nav { justify-content: center; width: 100%; margin-top: var(--space-sm); }
  .header-inner { justify-content: center; }
  .brand { margin-bottom: var(--space-xs); }
  .breadcrumbs ol { justify-content: center; }
  .window-links { justify-content: center; }
  .window-links a { white-space: normal; padding: var(--space-xs) var(--space-sm); font-size: var(--text-xs); }
  .main-nav { gap: var(--space-xs); }
  .main-nav a { padding: var(--space-xs) var(--space-sm); font-size: var(--text-xs); }
  .sign-card { padding: var(--space-xs); }
  .sign-name { font-size: var(--text-sm); }
  .sign-dates { font-size: var(--text-xs); }
  .sign-meta { display: none; }
  .panel { padding: var(--space-sm); }
  .facts li { padding: var(--space-xs) 0; font-size: var(--text-sm); }
  .window-links a { padding: var(--space-xs) var(--space-sm); }
  .button, button[type='submit'] { width: 100%; padding: var(--space-md); font-size: var(--text-base); }
  .field input, .field select, .field textarea { padding: var(--space-md); font-size: var(--text-base); }
  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }
  h3 { font-size: var(--text-base); }
  .lede { font-size: var(--text-base); }
  .small, .muted { font-size: var(--text-xs); }
  .site-footer h2 { font-size: var(--text-xs); }
  .site-footer ul.plain a { font-size: var(--text-sm); }
  .footer-grid { gap: var(--space-md); padding: var(--space-lg) 0; }
  .site-footer ul.plain li { margin-bottom: var(--space-xs); }
}

/* Extra small mobile (320px and below) */
@media (max-width: 320px) {
  .sign-grid { grid-template-columns: repeat(2, 1fr); }
  .sign-grid.compact { grid-template-columns: repeat(2, 1fr); }
  .sign-name { font-size: var(--text-xs); }
  .sign-dates { font-size: 0.7rem; }
  .window-links a { padding: var(--space-xs) var(--space-xs); font-size: 0.7rem; }
  .main-nav a { padding: var(--space-xs) var(--space-xs); font-size: 0.7rem; }
  .brand { font-size: var(--text-base); }
  h1 { font-size: var(--text-lg); }
  h2 { font-size: var(--text-base); }
  .panel { padding: var(--space-xs); }
}

/* Landscape mobile */
@media (max-height: 480px) and (orientation: landscape) {
  .site-header { height: 48px; }
  .header-inner { height: 48px; }
  main { padding: var(--space-md) 0; }
  .panel { padding: var(--space-sm); margin-top: var(--space-sm); }
  .footer-grid { padding: var(--space-md) 0; }
}