@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;600&family=Noto+Serif+SC:wght@600;700&display=swap');

:root {
  color-scheme: light dark;
  --bg: #f4f4f2;
  --fg: #101010;
  --muted: #5f5f5f;
  --panel: #ffffff;
  --border: #dddddd;
  --shadow: rgba(0, 0, 0, 0.08);
  --accent: #111111;
}

[data-theme="dark"] {
  --bg: #0c0c0c;
  --fg: #f1f1f1;
  --muted: #a2a2a2;
  --panel: #141414;
  --border: #2a2a2a;
  --shadow: rgba(0, 0, 0, 0.4);
  --accent: #f1f1f1;
}

html {
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  transition: background 0.4s ease, color 0.4s ease;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

[data-theme="dark"] body {
  background: var(--bg);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top)) 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

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

.calendar-badge {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: grid;
  grid-template-rows: 1fr 2fr;
  align-items: center;
  justify-items: center;
  overflow: hidden;
  box-shadow: 0 8px 16px var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.calendar-month {
  width: 100%;
  text-align: center;
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #ffffff;
  background: #111111;
  padding: 2px 0 1px;
}

[data-theme="dark"] .calendar-month {
  background: #f1f1f1;
  color: #101010;
}

.calendar-day {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
}

.title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 24px;
}

h1 {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  margin: 0;
  letter-spacing: 0.04em;
}

.subtitle {
  font-size: 1rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.1;
}

.header-countdown {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.toggle {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.toggle:hover {
  transform: translateY(-2px);
}

.toggle:active {
  transform: translateY(-3px) scale(1.01);
}

.toggle.is-pressed {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.toggle .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.pager {
  display: none;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin-top: -10px;
  position: relative;
  z-index: 3;
}

.pager button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.pager button:hover {
  transform: translateY(-2px);
}

.pager button.is-pressed {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.18);
}


.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 40px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24px;
  border: 1px solid transparent;
  pointer-events: none;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  line-height: 1.1;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-title .range {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.lead {
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-family: "Noto Serif SC", serif;
}

.lead-number {
  font-size: clamp(2.6rem, 5vw, 3.8rem);
  font-weight: 700;
}

.lead-label {
  font-size: 1rem;
  color: var(--muted);
}

/* ... existing basic styles for page/header ... */

/* New Navigation Grid Styles */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.nav-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  background: var(--panel);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  min-height: 120px;
  cursor: pointer;

  /* Initial animation state */
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.6s ease forwards;
}

/* Hover effects */
.nav-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--item-color);
}

[data-theme="dark"] .nav-item:hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.nav-item.is-pressed {
  transform: scale(0.96);
}

.nav-content h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-url {
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 6px;
  font-weight: 500;
}

.nav-tag-self {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.nav-tag-official {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.nav-icon {
  align-self: flex-end;
  font-size: 1.2rem;
  color: var(--item-color);
  opacity: 0.2;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-item:hover .nav-icon {
  opacity: 1;
  transform: translateX(4px) translateY(-4px);
}

/* Remove old subject styles but keep animation */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Media Queries updates */
@media (max-width: 640px) {

  html,
  body {
    min-height: auto;
  }

  .hero {
    display: block;
    position: relative;
  }

  .pager {
    display: flex;
  }

  .panel {
    display: none;
    width: 100%;
    flex-direction: column;
    padding: 20px;
    border-radius: 20px;
  }

  .panel.is-visible {
    display: flex;
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    animation: panelFadeIn 0.35s ease-out;
  }

  .panel.is-hidden {
    display: none;
    pointer-events: none;
  }

  @keyframes panelFadeIn {
    from {
      opacity: 0;
      transform: translateY(12px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

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

  .nav-item {
    min-height: 100px;
    padding: 14px;
  }

  .nav-content h3 {
    font-size: 1rem;
  }
}

/* Ensure generic text colors update */
a {
  color: inherit;
  text-decoration: none;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 6px 0 0;
}

.footer .github,
.footer .vercel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.footer .github:hover,
.footer .vercel:hover {
  color: var(--fg);
  transform: translateY(-1px);
}

.footer-sep {
  color: var(--muted);
}

/* Admin Panel Styles */
.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-overlay.is-open {
  display: flex;
}

.admin-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

.admin-modal-sm {
  max-width: 400px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.admin-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.admin-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s ease;
}

.admin-close:hover {
  color: var(--fg);
}

.admin-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.admin-login {
  text-align: center;
}

.admin-login p {
  margin: 0 0 16px;
  color: var(--muted);
}

.admin-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s ease;
}

.admin-input:focus {
  border-color: var(--accent);
}

.admin-input-color {
  width: 60px;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

.admin-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 12px;
}

.admin-label:first-child {
  margin-top: 0;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 6px;
}

.admin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.admin-btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.admin-btn-danger {
  color: #EF4444;
  border-color: #EF4444;
}

.admin-btn-danger:hover {
  background: #EF4444;
  color: white;
}

.admin-btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.admin-error {
  color: #EF4444;
  font-size: 0.85rem;
  margin-top: 8px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.admin-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.admin-category {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--bg);
}

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

.admin-category-header h3 {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
}

.admin-category-header span {
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-category-actions {
  display: flex;
  gap: 8px;
}

.admin-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.admin-link-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.admin-link-info {
  flex: 1;
  min-width: 0;
}

.admin-link-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.admin-link-url {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-link-actions {
  display: flex;
  gap: 6px;
}

@media (max-width: 640px) {
  .admin-modal {
    max-height: 90vh;
    border-radius: 16px;
  }

  .admin-content {
    padding: 16px;
  }

  .admin-actions {
    flex-direction: column;
  }

  .admin-btn {
    width: 100%;
  }
}

/* Sort buttons */
.admin-sort-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: 8px;
}

.admin-btn-icon {
  padding: 4px 8px;
  font-size: 0.75rem;
  line-height: 1;
  min-width: auto;
  border-radius: 6px;
}

.admin-btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
}

/* Connectivity status dots */
.status-dot {
  position: absolute;
  bottom: 16px;
  left: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 10;
}

.status-checking {
  background: #9ca3af;
  animation: pulse 1.5s infinite;
}

.status-online {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.status-offline {
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

/* Floating Scroll Buttons */
.scroll-buttons {
  position: fixed;
  right: 16px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.scroll-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

[data-theme="dark"] .scroll-btn {
  background: rgba(30, 30, 30, 0.7);
}

.scroll-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.scroll-btn:active {
  transform: scale(0.95);
}