:root {
  color-scheme: dark;
  --theme-bg: #0b0f19;
  --theme-bg-glow: #18213a;
  --theme-panel: #111827;
  --theme-panel-soft: #172033;
  --theme-input: #1f2937;
  --theme-border: rgba(255, 255, 255, .12);
  --theme-border-strong: rgba(196, 181, 253, .75);
  --theme-text: #f9fafb;
  --theme-muted: #cbd5e1;
  --theme-subtle: #94a3b8;
  --theme-link: #c4b5fd;
  --theme-link-hover: #fbbf24;
  --theme-accent: #7c3aed;
  --theme-accent-hover: #6d28d9;
  --theme-warning: #fde68a;
  --theme-danger: #f87171;
  --theme-focus: #c4b5fd;
  --theme-shadow: rgba(0, 0, 0, .4);
}

html[data-theme="light"] {
  color-scheme: light;
  --theme-bg: #f8fafc;
  --theme-bg-glow: #e0e7ff;
  --theme-panel: #ffffff;
  --theme-panel-soft: #eef2ff;
  --theme-input: #f1f5f9;
  --theme-border: rgba(15, 23, 42, .16);
  --theme-border-strong: #6d28d9;
  --theme-text: #111827;
  --theme-muted: #334155;
  --theme-subtle: #475569;
  --theme-link: #6d28d9;
  --theme-link-hover: #92400e;
  --theme-accent: #7c3aed;
  --theme-accent-hover: #6d28d9;
  --theme-warning: #92400e;
  --theme-danger: #b91c1c;
  --theme-focus: #6d28d9;
  --theme-shadow: rgba(15, 23, 42, .18);
}

.skip-link {
  position: absolute;
  top: 8px;
  left: -9999px;
  z-index: 1000;
  padding: 8px 12px;
  border: 1px solid var(--theme-border-strong);
  border-radius: 6px;
  background: var(--theme-panel);
  color: var(--theme-text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { left: 8px; outline: 3px solid var(--theme-focus); outline-offset: 2px; }

.theme-toggle {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--theme-border-strong);
  border-radius: 999px;
  background: var(--theme-panel);
  color: var(--theme-text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.theme-toggle[hidden] { display: none; }

.theme-toggle:hover { border-color: var(--theme-link-hover); }
.theme-toggle:focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 2px; }
.theme-toggle-icon { font-size: 16px; line-height: 1; }
.locale-switch {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--theme-border);
  border-radius: 999px;
  color: var(--theme-text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.locale-switch a { display: inline-flex; min-height: 44px; align-items: center; padding: 0 13px; color: inherit; text-decoration: none; }
.locale-switch:hover { border-color: var(--theme-link-hover); background: var(--theme-panel-soft); }
.locale-switch a:focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 2px; }

.resource-nav {
  display: grid;
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(180px, .9fr));
  gap: 0;
  width: 100%;
  max-width: 1280px;
  margin: 28px auto 12px;
  padding: 5px;
  border: 1px solid var(--theme-border);
  border-radius: 18px;
  background: var(--theme-panel);
  box-shadow: 0 12px 30px var(--theme-shadow);
}

.tool-type-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 1280px;
  margin: 12px auto 18px;
}
.tool-type-link {
  display: flex;
  min-width: 0;
  min-height: 76px;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  border: 1px solid var(--theme-border);
  border-radius: 16px;
  background: var(--theme-panel);
  color: var(--theme-text);
  text-decoration: none;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}
.tool-type-link:hover { transform: translateY(-1px); border-color: var(--theme-border-strong); background: var(--theme-panel-soft); }
.tool-type-link:focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 2px; }
.tool-type-link.is-active { border-color: var(--theme-accent); background: var(--theme-accent); color: #fff; }
.tool-type-icon { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; border: 1px solid var(--theme-border); border-radius: 13px; background: var(--theme-panel-soft); color: var(--theme-link); }
.tool-type-icon svg { width: 22px; height: 22px; }
.tool-type-link.is-active .tool-type-icon { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.14); color: #fff; }
.tool-type-copy { display: grid; min-width: 0; gap: 3px; }
.tool-type-copy strong { font-size: 14px; line-height: 1.25; }
.tool-type-copy small { color: var(--theme-subtle); font-size: 12px; line-height: 1.3; }
.tool-type-link.is-active .tool-type-copy small { color: rgba(255,255,255,.82); }
.resource-group { min-width: 0; padding: 14px 16px; }
.resource-group + .resource-group { border-left: 1px solid var(--theme-border); }
.resource-group h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  color: var(--theme-text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.3;
  text-transform: uppercase;
}
.resource-count {
  color: var(--theme-subtle);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: none;
}
.resource-links { display: grid; gap: 4px; }
.resource-tools .resource-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.resource-links a {
  display: flex;
  box-sizing: border-box;
  min-height: 40px;
  align-items: center;
  border-radius: 10px;
  padding: 7px 10px;
  color: var(--theme-link);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
}
.resource-links a:hover, .resource-links a:focus-visible { background: var(--theme-panel-soft); color: var(--theme-link-hover); text-decoration: none; }
.resource-links a[aria-current="page"] { background: var(--theme-accent); color: #fff; font-weight: 700; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .tool-type-link { transition: none; }
  .tool-type-link:hover { transform: none; }
}

@media (max-width: 760px) {
  .tool-type-nav { gap: 8px; margin: 10px auto 14px; }
  .tool-type-link { min-height: 62px; justify-content: center; gap: 7px; padding: 8px 6px; text-align: center; }
  .tool-type-icon { flex-basis: 30px; width: 30px; height: 30px; border-radius: 10px; }
  .tool-type-icon svg { width: 17px; height: 17px; }
  .tool-type-copy { justify-items: center; }
  .tool-type-copy strong { font-size: 12px; }
  .tool-type-copy small { display: none; }
  .resource-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 6px; }
  .resource-group { padding: 7px 8px; }
  .resource-tools { grid-column: 1 / -1; border-bottom: 1px solid var(--theme-border); }
  .resource-group + .resource-group { border-left: 0; }
  .resource-group:last-child { border-left: 1px solid var(--theme-border); }
  .resource-tools .resource-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .resource-group:not(.resource-tools) .resource-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resource-links a { min-height: 44px; padding: 6px 7px; font-size: 12px; }
}

@media (max-width: 520px) {
  .guide-header { flex-wrap: wrap; }
  .guide-header .brand, .guide-header .header-cta { white-space: nowrap; }
  .guide-header .theme-toggle { order: 3; flex-basis: 100%; width: 100%; }
}

@media (max-width: 360px) {
  .resource-nav { grid-template-columns: 1fr; }
  .resource-group + .resource-group { border-top: 1px solid var(--theme-border); }
  .resource-group:last-child { border-left: 0; }
  .resource-group:not(.resource-tools) .resource-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resource-links a { padding: 4px 5px; font-size: 11px; line-height: 1.25; }
}

@media (max-width: 420px) {
  .tool-type-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .tool-type-link { min-height: 54px; justify-content: center; padding: 7px 4px; text-align: center; }
  .tool-type-icon { display: none; }
  .tool-type-copy { justify-items: center; }
  .tool-type-copy strong { font-size: 11px; }
}

@media print {
  .theme-toggle, .tool-type-nav, .resource-nav { display: none !important; }
}
