:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #accefe;
  --text: #111827;
  --muted: #667085;
  --line: #d9deea;
  --brand: #111827;
  --brand-2: #374151;
  --accent: #091d44;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.10);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #070b12;
  --surface: #101827;
  --surface-2: #172033;
  --text: #eef2ff;
  --muted: #a6b0c3;
  --line: #2c3448;
  --brand: #f8fafc;
  --brand-2: #dbe4f0;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 34rem),
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.10), transparent 32rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img, canvas { max-width: 100%; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.skip-link { position: absolute; left: -999px; top: 12px; background: var(--text); color: var(--bg); padding: 10px 12px; border-radius: 10px; z-index: 10; }
.skip-link:focus { left: 12px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 35%);
  background: color-mix(in srgb, var(--bg), transparent 12%);
  backdrop-filter: blur(14px);
}
.nav { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; position: relative; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}
.brand strong { display: block; letter-spacing: -0.03em; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-actions a, .theme-toggle { padding: 10px 12px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.nav-actions a:hover, .theme-toggle:hover { background: var(--surface); color: var(--text); border-color: var(--line); }
.menu-toggle { display: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 12px; padding: 8px 11px; }

.hero { display: grid; grid-template-columns: 1.35fr 0.65fr; gap: 28px; align-items: center; padding: 72px 0 44px; }
.eyebrow { color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; margin: 0 0 10px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.04em; }
h1 { font-size: clamp(42px, 8vw, 82px); line-height: 0.92; max-width: 820px; }
h2 { font-size: clamp(28px, 4vw, 44px); }
h3 { font-size: 24px; }
.hero-text { color: var(--muted); font-size: 18px; line-height: 1.7; max-width: 720px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 12px 16px; border-radius: 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; }
.btn.primary { background: var(--brand); color: var(--bg); border-color: var(--brand); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 38px; padding: 8px 12px; border-radius: 11px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.hero-panel { display: grid; gap: 14px; padding: 20px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface), transparent 8%); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.hero-panel div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 22px; padding: 24px; }
.hero-panel strong { display: block; font-size: 34px; letter-spacing: -0.05em; }
.hero-panel span { color: var(--muted); }

.utility-shell { padding: 28px 0 56px; }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.search-box { width: min(420px, 100%); display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.search-box input, .field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
.search-box input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 18px; scrollbar-width: thin; }
.category-tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 10px 13px; white-space: nowrap; font-weight: 800; }
.category-tabs button.active { background: var(--brand); color: var(--bg); border-color: var(--brand); }
.app-layout { display: grid; grid-template-columns: 380px 1fr; gap: 18px; align-items: start; }
.tool-list-panel, .tool-stage { background: color-mix(in srgb, var(--surface), transparent 4%); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.tool-list-panel { padding: 14px; max-height: 780px; overflow: auto; position: sticky; top: 90px; }
.tool-grid { display: grid; gap: 10px; }
.tool-card { text-align: left; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 17px; padding: 14px; width: 100%; display: grid; gap: 6px; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.tool-card:hover { transform: translateY(-1px); border-color: var(--accent); }
.tool-card.active { border-color: var(--accent); background: var(--accent-soft); }
.tool-card strong { font-size: 15px; }
.tool-card span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.tool-card small { color: var(--accent); font-weight: 900; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.tool-stage { min-height: 700px; padding: 20px; }
.empty-stage { display: grid; min-height: 620px; place-items: center; text-align: center; color: var(--muted); }
.empty-stage h3 { color: var(--text); margin-bottom: 8px; }
.tool-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 18px; }
.tool-header p { color: var(--muted); line-height: 1.6; max-width: 720px; margin: 8px 0 0; }
.tool-form { display: grid; gap: 14px; }
.field { display: grid; gap: 8px; }
.field label, .field .label { color: var(--muted); font-weight: 800; font-size: 13px; }
.field textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.result-box { border: 1px solid var(--line); background: var(--surface-2); border-radius: 18px; padding: 16px; min-height: 78px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.result-box:empty::before { content: "Result will appear here."; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat strong { display: block; font-size: 26px; letter-spacing: -0.04em; }
.stat span { color: var(--muted); font-size: 13px; }
.preview-area { display: grid; gap: 14px; margin-top: 4px; }
.preview-canvas-wrap { border: 1px dashed var(--line); background: var(--surface-2); border-radius: 18px; padding: 14px; min-height: 220px; display: grid; place-items: center; overflow: auto; }
.timer-display { font-size: clamp(42px, 9vw, 86px); letter-spacing: -0.06em; font-weight: 900; text-align: center; padding: 24px; border-radius: 22px; background: var(--surface-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 10px 0 70px; }
.info-card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-xl); padding: 28px; box-shadow: var(--shadow); }
.info-card p { color: var(--muted); line-height: 1.7; }
.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); border-radius: 999px; padding: 12px 16px; z-index: 40; box-shadow: var(--shadow); transition: .2s ease; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hidden { display: none !important; }
.note { color: var(--muted); font-size: 13px; line-height: 1.5; }
.error { color: var(--danger); }
.success { color: var(--success); }
.code-like { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding-top: 48px; }
  .hero-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-layout { grid-template-columns: 1fr; }
  .tool-list-panel { position: static; max-height: 420px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .container { width: min(100% - 22px, 1180px); }
  .menu-toggle { display: block; }
  .nav-actions { display: none; position: absolute; top: 68px; left: 11px; right: 11px; flex-direction: column; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 10px; box-shadow: var(--shadow); }
  .nav-actions.open { display: flex; }
  .nav-actions a, .theme-toggle { text-align: left; border-radius: 12px; }
  .hero-panel { grid-template-columns: 1fr; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .tool-header { flex-direction: column; }
  .tool-stage { padding: 14px; }
}


/* Header dropdown and individual tool page additions */
.nav-menu-item { position: static; }
.nav-menu-button { padding: 10px 12px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 800; }
.nav-menu-button:hover, .nav-menu-item:focus-within .nav-menu-button { background: var(--surface); color: var(--text); border-color: var(--line); }
.mega-menu { position: absolute; top: calc(100% + 10px); left: 50%; right: auto; transform: translateX(-50%); width: min(920px, calc(100vw - 32px)); max-height: 76vh; overflow: auto; display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); z-index: 70; }
.nav-menu-item:hover .mega-menu, .nav-menu-item:focus-within .mega-menu { display: grid; }
.mega-group { border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: var(--surface-2); }
.mega-group > strong { display: block; margin-bottom: 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.mega-group a { display: block; padding: 7px 0; color: var(--muted); font-size: 14px; line-height: 1.3; }
.mega-group a:hover { color: var(--text); }
.tool-page { padding: 44px 0 72px; }
.tool-page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.tool-page .tool-stage { min-height: auto; }
.breadcrumbs { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.breadcrumbs a { color: var(--accent); font-weight: 800; }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 18px; box-shadow: var(--shadow); position: sticky; top: 92px; }
.side-card h2 { font-size: 22px; margin-bottom: 10px; }
.mini-link { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.mini-link:hover { color: var(--text); }
.seo-article { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow); overflow: hidden; }
.seo-article summary { cursor: pointer; padding: 18px 20px; font-weight: 900; font-size: 18px; }
.seo-article-content { padding: 0 20px 22px; color: var(--muted); line-height: 1.75; }
.seo-article-content h2, .seo-article-content h3 { color: var(--text); margin: 18px 0 8px; }
.seo-article-content ul { padding-left: 20px; }
.footer-inner p:last-child { font-weight: 900; color: var(--text); }
@media (max-width: 980px) {
  .mega-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); left: 50%; right: auto; transform: translateX(-50%); }
  .tool-page-grid { grid-template-columns: 1fr; }
  .side-card { position: static; }
}
@media (max-width: 720px) {
  .nav-menu-button { width: 100%; text-align: left; border-radius: 12px; }
  .nav-menu-item { position: relative; }
  .mega-menu { position: static; width: 100%; max-height: 360px; grid-template-columns: 1fr; box-shadow: none; margin-top: 6px; transform: none; }
  .nav-menu-item:hover .mega-menu { display: none; }
  .nav-menu-item:focus-within .mega-menu { display: grid; }
}

/* Mobile-safe Tools dropdown fix */
.nav-menu-item.open .mega-menu { display: grid; }
.nav-menu-button { touch-action: manipulation; }
@media (max-width: 720px) {
  .nav-menu-item.open .mega-menu { display: grid !important; }
  .nav-menu-item:not(.open) .mega-menu { display: none !important; }
  .mega-menu { max-height: 58vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
}
