:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --card-hover: #f0f4ff;
  --text: #1a1a2e;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --border: #e2e8f0;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #0ea5e9;
  --info-light: #e0f2fe;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --card-hover: #334155;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --primary: #60a5fa;
  --primary-light: #1e3a5f;
  --primary-dark: #3b82f6;
  --border: #334155;
  --success: #22c55e;
  --success-light: #14532d;
  --warning: #fbbf24;
  --warning-light: #451a03;
  --danger: #ef4444;
  --danger-light: #450a0a;
  --info: #38bdf8;
  --info-light: #0c4a6e;
  --purple: #a78bfa;
  --purple-light: #3b0764;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  padding-top: var(--nav-height);
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); text-decoration: underline; }
img, svg { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, h5, h6 { line-height: 1.3; color: var(--text); }
p { margin-bottom: 1rem; color: var(--text-secondary); }
input, select, button { font-family: var(--font); font-size: 1rem; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
section { padding: 16px 0; }
.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-align: center;
}
.section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
  transition: background var(--transition), border-color var(--transition);
}
[data-theme="dark"] .navbar { background: rgba(15,23,42,0.88); }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
}
.nav-logo {
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-logo:hover { text-decoration: none; color: var(--primary); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0 auto;
}
.nav-links a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  text-decoration: none;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  background: var(--primary-light);
  text-decoration: none;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.theme-toggle {
  background: none;
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition);
  color: var(--text);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--primary); background: var(--primary-light); }
.nav-hamburger {
  display: none;
  background: none;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  transition: all var(--transition);
  flex-shrink: 0;
}
.nav-hamburger:hover { border-color: var(--primary); background: var(--primary-light); }
.nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all var(--transition);
}
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}
.drawer-overlay.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background: var(--card);
  z-index: 1001;
  transition: right var(--transition);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
}
.drawer.open { right: 0; }
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.drawer-header .drawer-logo { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.drawer-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: var(--text-secondary); padding: 4px 8px; border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.drawer-close:hover { color: var(--text); background: var(--card-hover); }
.drawer-nav { list-style: none; padding: 0; margin: 0; flex: 1; }
.drawer-nav li { border-bottom: 1px solid var(--border); }
.drawer-nav li:last-child { border-bottom: none; }
.drawer-nav a {
  display: block;
  padding: 14px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.drawer-nav a:hover,
.drawer-nav a.active { color: var(--primary); background: var(--primary-light); text-decoration: none; }
body.no-scroll { overflow: hidden; }
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
}
@media (min-width: 769px) {
  .drawer, .drawer-overlay { display: none; }
}

.content-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: background var(--transition), box-shadow var(--transition);
}
.content-section h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  color: var(--text);
}
.content-section h3 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.8rem;
  color: var(--text);
}

.footer {
  background: #1e293b;
  color: #cbd5e1;
  padding: 50px 0 0;
  margin-top: 40px;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
.footer h3 { color: #fff; font-size: 1.1rem; margin-bottom: 16px; }
.footer p { color: #94a3b8; font-size: 0.9rem; }
.footer ul { list-style: none; }
.footer ul li { margin-bottom: 8px; }
.footer ul a { color: #94a3b8; font-size: 0.9rem; transition: color var(--transition); }
.footer ul a:hover { color: #fff; text-decoration: none; }
.footer-bottom {
  border-top: 1px solid #334155;
  padding: 20px;
  margin-top: 40px;
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
.footer-bottom a { color: #94a3b8; }
.footer-bottom a:hover { color: #fff; }

.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all var(--transition);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--primary-dark); transform: translateY(-3px); }

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  pointer-events: auto;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(20px); } }

.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  padding: 22px 0 48px;
  color: #fff;
  text-align: center;
}
.hero h1 { font-size: 2rem; font-weight: 800; color: #fff; margin-bottom: 0.3rem; }
.hero p { color: rgba(255,255,255,0.9); font-size: 0.97rem; max-width: 600px; margin: 0 auto; }

@media print {
  .navbar, .back-to-top, .result-actions, .toast-container { display: none !important; }
  body { padding-top: 0; }
}

@media (max-width: 900px) {
  .hero h1 { font-size: 1.8rem; }
}
@media (max-width: 500px) {
  .hero h1 { font-size: 1.4rem; }
  .hero p { font-size: 0.95rem; }
  .section-title { font-size: 1.4rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .content-section { padding: 24px; }
}
