:root {
  --bg: #08111c;
  --surface: rgba(16, 25, 40, 0.9);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --text: #f5f7ff;
  --muted: #94a3b8;
  --accent: #7dd3fc;
  --accent-strong: #38bdf8;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 22%),
    radial-gradient(circle at 90% 12%, rgba(99, 102, 241, 0.16), transparent 18%),
    radial-gradient(circle at 50% 70%, rgba(59, 130, 246, 0.12), transparent 24%),
    linear-gradient(180deg, #06101e 0%, #0f1f33 55%, #08101c 100%);
  background-attachment: fixed;
  color: var(--text);
}

body {
  padding: 28px 24px 40px;
}

.page-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 14px;
}

@media (max-width: 600px) {
  body {
    padding: 18px 14px 24px;
  }
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
  padding: 0 16px;
}

.nav-brand {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  gap: 16px;
}

.nav-link {
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: all 180ms ease;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: var(--accent-strong);
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

@media (max-width: 600px) {
  .top-nav {
    margin-bottom: 20px;
    padding: 0 8px;
  }

  .nav-brand {
    font-size: 1.1rem;
  }

  .nav-links {
    gap: 8px;
  }

  .nav-link {
    padding: 8px 12px;
    font-size: 0.95rem;
  }
}

.page-shell {
  max-width: 1120px;
  margin: 0 auto;
}

.hero-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 0.88rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-card h1 {
  margin: 0;
  font-size: clamp(2.5rem, 4vw, 4rem);
  line-height: 1.02;
}

.hero-card p {
  max-width: 640px;
  color: var(--muted);
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.6);
  outline-offset: 3px;
}

button#sampleBtn,
button#quizBtn,
.special-btn,
button.tool-btn,
#calculateBtn,
#runToolBtn {
  padding: 14px 20px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.9), rgba(59, 130, 246, 0.95));
  color: #0f172a;
  font-weight: 700;
}

button.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.11);
}

button.hidden {
  display: none;
}

.grid-layout {
  display: grid;
  gap: 24px;
  margin-top: 24px;
  grid-template-columns: 1.4fr 1fr;
}

.card {
  padding: 28px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 14px;
}

.input-label {
  display: block;
  margin: 24px 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

input[type='text'], textarea.expression-input {
  width: 100%;
  padding: 18px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

textarea.expression-input {
  min-height: 110px;
  resize: vertical;
}

.helper-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.quick-tools,
.tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.tool-btn,
.special-btn {
  flex: 1 1 160px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 14px 18px;
  text-align: center;
}

.tool-btn:hover,
.special-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.result-box {
  padding: 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.result-box span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.explanation-panel {
  margin-top: 24px;
}

.explanation-panel h3 {
  margin-top: 0;
}

.explanation-text {
  min-height: 190px;
  padding: 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  line-height: 1.7;
  white-space: pre-line;
}

.tools-card p {
  color: var(--muted);
}

.tool-panel {
  margin-top: 20px;
}

.tool-inputs {
  display: grid;
  gap: 14px;
}

.tool-inputs label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.tool-inputs input {
  width: 100%;
}

.history-panel {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.history-panel h4 {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.95rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 150ms ease;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.history-result {
  font-weight: 600;
  color: var(--accent);
}


@media (max-width: 900px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }

  .hero-card {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
}
