:root {
  --bg: #090d16;
  --bg-deep: #0f172a;
  --surface: #111827;
  --surface-raised: #1e293b;
  --surface-soft: #162033;
  --accent: #38bdf8;
  --accent-strong: #8b5cf6;
  --accent-warm: #f59e0b;
  --danger: #ef4444;
  --danger-soft: #fca5a5;
  --success: #22c55e;
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --border: rgba(148, 163, 184, 0.18);
  --shadow: rgba(15, 23, 42, 0.55);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --content-max: 1100px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

.page-shell {
  margin: 0;
  min-height: 100vh;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at top, rgba(56, 191, 248, 0.175), transparent 40%),
    radial-gradient(
      circle at bottom right,
      rgba(138, 92, 246, 0.175),
      transparent 40%
    ),
    var(--bg);
  color: var(--text);
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select,
input {
  font: inherit;
}

.page-shell {
  width: min(var(--content-max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.site-header {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.site-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px -24px var(--shadow);
  backdrop-filter: blur(8px);
}

.brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-strong);
}

.brand a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.2s ease;
}

.brand a:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
}

.nav-link {
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.5);
  color: var(--muted-strong);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--text);
  transform: translateY(-1px);
}

.nav-link.active {
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.18),
    rgba(139, 92, 246, 0.12)
  );
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18);
}

.page-heading {
  text-align: center;
  padding: 0.5rem 0;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.05em;
  font-weight: 800;
  color: var(--text);
}

.page-heading .page-subtitle {
  margin: 0.8rem auto 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.page-card {
  background: linear-gradient(
    180deg,
    rgba(17, 24, 39, 0.92),
    rgba(15, 23, 42, 0.92)
  );
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 60px -30px rgba(15, 23, 42, 0.8);
}

.section-label {
  display: block;
  margin-bottom: 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.surface-panel,
.controls,
.diagram-container,
.result-box,
.modal-content,
.toggle-row,
.custom-select-trigger,
.custom-options,
.subtitle-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
}

.custom-select-wrapper {
  position: relative;
  margin-bottom: 0.9rem;
}

.custom-select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-select-trigger:hover,
.custom-select-trigger:focus-visible {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(17, 24, 39, 0.9);
  outline: none;
}

.arrow {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.25s ease;
  margin-left: 10px;
}

.custom-select-wrapper.open .arrow {
  transform: rotate(-135deg);
}

.custom-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 15px 35px rgba(2, 6, 23, 0.55);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 10;
  max-height: 280px;
  overflow-y: auto;
}

.custom-select-wrapper.open .custom-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-option {
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted-strong);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.custom-option:last-child {
  border-bottom: none;
}

.custom-option:hover,
.custom-option:focus-visible {
  background: rgba(15, 23, 42, 0.9);
  color: var(--accent);
  outline: none;
}

.custom-option.selected {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 1rem 3rem 1rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.75);
  color: var(--muted-strong);
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.5;
  outline: none;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

select:hover {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(17, 24, 39, 0.9);
}

select:focus {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
  background: rgba(17, 24, 39, 0.95);
}

select option {
  background: rgba(15, 23, 42, 0.98);
  color: var(--text);
}
