/*
  MathCell Helper Design System
  ------------------------------------------------------------
  The easiest style entry point is here: edit the tokens below.
  Dark theme is derived from the Wellenritt / Map UI mood:
  deep near-black backgrounds, green glass accents, soft radial glows,
  rounded panels, blur and compact pill controls.
*/

:root {
  color-scheme: light dark;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;
  --shadow-soft: 0 24px 70px rgba(0, 0, 0, 0.18);
  --shadow-panel: 0 28px 82px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.07);

  --accent-rgb: 127, 177, 151;
  --accent: #5e987a;
  --accent-strong: #7fb197;
  --danger: #b43b50;
  --ok: #247a4e;

  --bg: #f4f6f4;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: #ffffff;
  --text: #17201b;
  --muted: rgba(23, 32, 27, 0.66);
  --border: rgba(23, 32, 27, 0.14);
  --input: rgba(255, 255, 255, 0.96);
  --soft: rgba(23, 32, 27, 0.045);
  --code-bg: rgba(23, 32, 27, 0.07);
  --hero-bg:
    radial-gradient(circle at 18% 18%, rgba(var(--accent-rgb), 0.15), transparent 34%),
    radial-gradient(circle at 86% 18%, rgba(210, 220, 135, 0.13), transparent 32%),
    linear-gradient(180deg, #f8faf8 0%, #eef3ef 100%);
}

html[data-theme="dark"] {
  --accent: #7fb197;
  --accent-strong: #9ad3b4;
  --danger: #ff7b92;
  --ok: #a4e5bc;
  --bg: #050607;
  --bg-2: #07100d;
  --panel: linear-gradient(135deg, rgba(255, 255, 255, 0.078), rgba(255, 255, 255, 0.028)), rgba(5, 8, 7, 0.72);
  --panel-strong: rgba(8, 15, 20, 0.92);
  --text: #f2f6f3;
  --muted: rgba(242, 246, 243, 0.68);
  --border: rgba(255, 255, 255, 0.14);
  --input: rgba(0, 0, 0, 0.24);
  --soft: rgba(255, 255, 255, 0.055);
  --code-bg: rgba(255, 255, 255, 0.09);
  --hero-bg:
    radial-gradient(circle at 35% 28%, rgba(70, 140, 115, 0.16), transparent 34%),
    radial-gradient(circle at 70% 44%, rgba(150, 190, 95, 0.08), transparent 30%),
    linear-gradient(180deg, #020404 0%, #050807 48%, #020303 100%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  background: var(--hero-bg);
  color: var(--text);
  line-height: 1.45;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.18) 78%);
  opacity: 0.55;
}

.app-shell {
  position: relative;
  z-index: 1;
}

.hero,
main,
footer {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 34px 0 18px;
}

.eyebrow,
.kicker {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  letter-spacing: -0.03em;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 0.96;
}

h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2.3vw, 1.55rem);
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.hero-copy {
  max-width: 880px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.12rem);
}

.top-controls,
.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.top-controls {
  justify-content: flex-end;
  align-items: flex-end;
  min-width: max-content;
}

.info-toggle {
  width: 100%;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0.18rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(12px);
}

html[data-theme="light"] .segmented-control {
  background: rgba(255, 255, 255, 0.7);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) minmax(330px, 0.92fr);
  gap: 18px;
  padding: 0 0 42px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-panel);
  padding: clamp(1rem, 2vw, 1.25rem);
  backdrop-filter: blur(14px);
}

html[data-theme="light"] .card {
  box-shadow: var(--shadow-soft);
}

.wide-card {
  grid-column: 1 / -1;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

label {
  display: block;
  font-weight: 720;
  margin: 14px 0 6px;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.78rem 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input);
  color: var(--text);
  font: inherit;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: rgba(var(--accent-rgb), 0.82);
  opacity: 1;
  font-weight: 650;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
  color: rgba(49, 108, 78, 0.68);
}

.preview.is-example-only {
  color: var(--muted);
  border-color: rgba(var(--accent-rgb), 0.32);
  background: rgba(var(--accent-rgb), 0.075);
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(var(--accent-rgb), 0.72);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}

textarea {
  min-height: 112px;
  resize: vertical;
  font-family: var(--font-mono);
}

#generatedFormula {
  min-height: 84px;
  background: var(--soft);
}

.row {
  display: grid;
  gap: 12px;
}

.row.two {
  grid-template-columns: 1fr 1fr;
}

.row.three {
  grid-template-columns: 1.1fr 0.65fr 0.9fr;
}

button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--soft);
  color: var(--text);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: transform 130ms ease, background 130ms ease, border-color 130ms ease, filter 130ms ease;
}

button:hover,
button:focus-visible {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: rgba(var(--accent-rgb), 0.58);
  outline: 2px solid rgba(var(--accent-rgb), 0.34);
  outline-offset: 2px;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: rgba(var(--accent-rgb), 0.26);
  border-color: rgba(var(--accent-rgb), 0.62);
}

html[data-theme="light"] button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

button.danger {
  color: var(--danger);
}

button.ghost {
  background: transparent;
}

.tiny {
  min-height: 2.05rem;
  padding: 0 0.62rem;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

.tiny.is-active {
  background: rgba(var(--accent-rgb), 0.34);
  color: var(--text);
}

.compact-buttons {
  justify-content: flex-end;
  margin-top: 0;
}

.preview {
  min-height: 192px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--soft);
  text-align: center;
}

.hint,
.split-note,
.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.hint,
.split-note {
  margin: 8px 0 0;
}

code {
  padding: 0.1rem 0.35rem;
  border-radius: 0.45rem;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--font-mono);
}

.status {
  min-height: 24px;
  margin-top: 10px;
  color: var(--ok);
  font-size: 0.9rem;
}

.status.error {
  color: var(--danger);
}

.variable-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 4px;
}

.variable-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 1.15fr 0.85fr;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--soft);
}

.variable-name {
  font-weight: 820;
  word-break: break-word;
}

.formula-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.formula-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--soft);
}

.formula-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.formula-name {
  font-weight: 820;
}

.formula-code {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  margin-top: 4px;
  word-break: break-word;
}

.pill {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.12rem 0.48rem;
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent-strong);
  font-size: 0.75rem;
}

.help-box {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--soft);
  color: var(--muted);
  font-size: 0.9rem;
}

.help-box summary {
  cursor: pointer;
  font-weight: 760;
  color: var(--text);
}

.file-input {
  display: none;
}

a {
  color: var(--accent-strong);
  text-underline-offset: 0.18em;
}

footer {
  padding: 0 0 36px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
  }

  .top-controls {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .row.two,
  .row.three,
  .variable-row {
    grid-template-columns: 1fr;
  }

  .section-title,
  .formula-top {
    flex-direction: column;
  }

  .compact-buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {

  .hero,
  main,
  footer {
    width: min(100% - 22px, 1220px);
  }

  .hero {
    padding-top: 20px;
  }

  .card {
    border-radius: 22px;
  }

  .buttons {
    gap: 0.42rem;
  }

  .tiny {
    min-height: 1.9rem;
    padding: 0 0.5rem;
    font-size: 0.7rem;
  }
}


/* Info menu / prototype explanation */
.info-menu {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(14px);
}

.info-menu.is-visible {
  display: flex;
}

.info-menu__panel {
  width: min(92vw, 760px);
  max-height: min(86vh, 760px);
  overflow: auto;
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-panel);
  color: var(--text);
}

.info-menu__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.info-menu__intro {
  margin: 0 0 1rem;
  color: var(--muted);
}

.info-menu__grid {
  display: grid;
  gap: 0.75rem;
}

.info-menu__section {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--soft);
}

.info-menu__section h3 {
  margin-bottom: 0.35rem;
}

.info-menu__section p {
  margin: 0;
  color: var(--muted);
}

.info-menu__examples {
  display: grid;
  gap: 0.35rem;
  margin: 0.72rem 0 0;
  padding: 0;
  list-style: none;
}

.info-menu__examples li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.46rem 0.58rem;
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: var(--radius-md);
  background: rgba(var(--accent-rgb), 0.07);
  color: var(--muted);
}

.info-menu__examples code {
  color: var(--text);
  font-weight: 780;
  white-space: nowrap;
}

.info-menu__resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.72rem;
}

.info-menu__resource-links a {
  display: inline-flex;
  align-items: center;
  min-height: 2.1rem;
  padding: 0.5rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 740;
  text-decoration: none;
}

.info-menu__resource-links a:hover,
.info-menu__resource-links a:focus-visible {
  background: rgba(var(--accent-rgb), 0.14);
  outline: 2px solid rgba(var(--accent-rgb), 0.34);
  outline-offset: 2px;
}

.info-menu__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.info-menu__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  padding: 0.72rem 1rem;
  border: 1px solid rgba(var(--accent-rgb), 0.44);
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
}

.info-menu__link:hover,
.info-menu__link:focus-visible {
  background: rgba(var(--accent-rgb), 0.24);
  outline: 2px solid rgba(var(--accent-rgb), 0.42);
  outline-offset: 3px;
}

.info-menu__link.support {
  border-color: rgba(255, 210, 125, 0.36);
  background: rgba(255, 210, 125, 0.12);
}

@media (max-width: 620px) {
  .info-menu {
    align-items: flex-end;
    padding: 0.75rem;
  }

  .info-menu__header {
    flex-direction: column;
  }

  .info-menu__footer {
    flex-direction: column;
  }

  .info-menu__link {
    width: 100%;
  }
}