:root {
  color-scheme: light;
  --ink: #172033;
  --ink-soft: #3e495e;
  --muted: #6a7282;
  --paper: #ffffff;
  --cloud: #f5f6f8;
  --line: #dfe3e8;
  --line-strong: #c7ced8;
  --accent: #a0793d;
  --accent-soft: #f5eee3;
  --blue: #2f6f9f;
  --blue-soft: #eaf2f8;
  --green: #28734f;
  --green-soft: #e9f5ee;
  --red: #a83232;
  --red-soft: #fbeceb;
  --amber: #8a5d16;
  --amber-soft: #fff4de;
  --shadow: 0 12px 36px rgba(23, 32, 51, .075);
  --sidebar: clamp(315px, 25vw, 390px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(14px, calc(12px + .18vw), 18px);
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { color: var(--ink); background: #f8f9fb; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
.ed-app { width: 100%; height: 100%; }
.ed-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); width: 100%; height: 100dvh; }
.ed-topbar {
  display: flex; align-items: center; gap: .7rem; min-height: 60px; padding: .5rem .85rem;
  background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); box-shadow: 0 4px 20px rgba(23,32,51,.045); z-index: 30;
}
.ed-brand { display: flex; align-items: center; gap: .7rem; flex: 1; min-width: 0; }
.ed-mark { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--ink); background: var(--ink); color: white; font: 700 1rem Georgia, serif; }
.ed-title { margin: 0; font-size: clamp(1.05rem, 1.4vw, 1.4rem); line-height: 1.1; letter-spacing: -.02em; }
.ed-subtitle { margin-top: .14rem; color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-top-actions { display: flex; gap: .38rem; }
.ed-button, .ed-icon-button, .ed-segment button, .ed-preset {
  border: 1px solid var(--line-strong); border-radius: 7px; background: white; color: var(--ink); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}
.ed-button:hover, .ed-icon-button:hover, .ed-segment button:hover, .ed-preset:hover { transform: translateY(-1px); box-shadow: 0 6px 15px rgba(23,32,51,.085); }
.ed-button { min-height: 38px; padding: .5rem .72rem; font-weight: 700; }
.ed-button.primary { background: var(--ink); color: white; border-color: var(--ink); }
.ed-button.accent { background: var(--accent); color: white; border-color: var(--accent); }
.ed-button.soft { background: var(--cloud); }
.ed-icon-button { min-width: 40px; min-height: 38px; padding: .35rem .55rem; display: inline-grid; place-items: center; }
.embed-mode #back-link { display: none; }
.embed-mode .ed-subtitle { display: none; }
.ed-body { min-height: 0; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.ed-sidebar { min-height: 0; overflow-y: auto; padding: .68rem; background: #f4f5f7; border-right: 1px solid var(--line); scrollbar-width: thin; }
.ed-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; }
.ed-plot-wrap { min-width: 0; min-height: 0; position: relative; background: white; }
#ed-plot { width: 100%; height: 100%; min-height: 420px; }
.ed-plot-help {
  position: absolute; z-index: 5; left: .65rem; bottom: .55rem; padding: .34rem .5rem; background: rgba(255,255,255,.88); border: 1px solid var(--line); color: var(--muted); font-size: .69rem; pointer-events: none; backdrop-filter: blur(7px);
}
.ed-results { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); background: white; }
.ed-result { min-width: 0; padding: .72rem .78rem; border-right: 1px solid var(--line); }
.ed-result:last-child { border-right: 0; }
.ed-result-label { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .065em; font-weight: 800; }
.ed-result-value { margin-top: .16rem; font-size: clamp(.95rem, 1.2vw, 1.16rem); font-weight: 780; letter-spacing: -.015em; overflow-wrap: anywhere; }
.ed-result-note { margin-top: .14rem; color: var(--muted); font-size: .67rem; line-height: 1.35; }
.ed-result.good .ed-result-value { color: var(--green); }
.ed-result.bad .ed-result-value { color: var(--red); }
.ed-result.warn .ed-result-value { color: var(--amber); }
.ed-section { margin-bottom: .58rem; background: rgba(255,255,255,.97); border: 1px solid var(--line); box-shadow: 0 3px 14px rgba(23,32,51,.025); }
.ed-section > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .67rem .7rem; font-weight: 780; cursor: pointer; user-select: none; }
.ed-section > summary::-webkit-details-marker { display: none; }
.ed-section > summary::after { content: '⌄'; color: var(--muted); transition: transform .15s ease; }
.ed-section[open] > summary::after { transform: rotate(180deg); }
.ed-section-body { padding: 0 .7rem .72rem; }
.ed-label { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin: .46rem 0 .25rem; color: var(--ink-soft); font-size: .75rem; font-weight: 730; }
.ed-input, .ed-select { width: 100%; min-height: 38px; padding: .43rem .52rem; border: 1px solid var(--line-strong); border-radius: 6px; background: white; color: var(--ink); outline: none; }
.ed-input:focus, .ed-select:focus { border-color: #6587a5; box-shadow: 0 0 0 3px rgba(47,111,159,.12); }
.ed-grid-2 { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .4rem; }
.ed-grid-3 { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .35rem; }
.ed-row { display: flex; gap: .38rem; align-items: center; }
.ed-row > * { min-width: 0; }
.ed-row.stretch > * { flex: 1; }
.ed-help { margin: .35rem 0 0; color: var(--muted); font-size: .68rem; line-height: 1.4; }
.ed-help code { color: var(--ink-soft); background: #f0f2f4; padding: .05rem .2rem; border-radius: 3px; }
.ed-segment { display: flex; gap: .2rem; padding: .18rem; background: var(--cloud); border: 1px solid var(--line); border-radius: 7px; }
.ed-segment button { flex: 1; padding: .39rem .3rem; box-shadow: none; font-size: .72rem; }
.ed-segment button.active { background: var(--ink); border-color: var(--ink); color: white; }
.ed-preset-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .3rem; }
.ed-preset { min-height: 34px; padding: .36rem .42rem; font-size: .7rem; text-align: left; }
.ed-expression-row { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr) auto; gap: .3rem; margin-top: .34rem; }
.ed-expression-row .ed-input { min-height: 34px; font-size: .74rem; }
.ed-remove { width: 34px; min-height: 34px; border: 1px solid var(--line-strong); background: white; color: var(--red); border-radius: 6px; }
.ed-callout { margin-top: .48rem; padding: .48rem .55rem; border-left: 3px solid var(--blue); background: var(--blue-soft); color: var(--ink-soft); font-size: .7rem; line-height: 1.42; }
.ed-callout.good { border-color: var(--green); background: var(--green-soft); }
.ed-callout.bad { border-color: var(--red); background: var(--red-soft); }
.ed-callout.warn { border-color: var(--amber); background: var(--amber-soft); }
.ed-error { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.ed-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-top: .55rem; }
.ed-slider-row { display: grid; grid-template-columns: minmax(0,1fr) 4.5rem; gap: .5rem; align-items: center; }
.ed-range { width: 100%; accent-color: var(--blue); }
.ed-number-chip { text-align: right; font-variant-numeric: tabular-nums; font-weight: 760; color: var(--ink-soft); font-size: .76rem; }
.ed-busy { display: none; align-items: center; gap: .4rem; margin-top: .45rem; color: var(--muted); font-size: .7rem; }
.ed-busy.show { display: flex; }
.ed-spinner { width: 13px; height: 13px; border: 2px solid #d7dce3; border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ed-mini-table { width: 100%; border-collapse: collapse; margin-top: .4rem; font-size: .69rem; }
.ed-mini-table td { padding: .26rem .1rem; border-bottom: 1px solid #edf0f3; vertical-align: top; }
.ed-mini-table td:first-child { color: var(--muted); width: 44%; }
.ed-mobile-only { display: none; }

@media (max-width: 900px) {
  html, body { overflow: auto; }
  .ed-shell { height: auto; min-height: 100dvh; }
  .ed-body { grid-template-columns: 1fr; }
  .ed-sidebar { order: 2; border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  .ed-main { order: 1; overflow: visible; grid-template-rows: auto auto; }
  #ed-plot { height: 58vh; min-height: 400px; }
  .ed-results { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .ed-result:nth-child(2) { border-right: 0; }
  .ed-result:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .ed-subtitle { display: none; }
  .ed-mobile-only { display: inline-grid; }
}
@media (max-width: 560px) {
  :root { font-size: 14px; }
  .ed-topbar { min-height: 54px; padding: .4rem .5rem; }
  .ed-mark { width: 35px; height: 35px; }
  .ed-title { font-size: .98rem; }
  .ed-top-actions .ed-button span.long { display: none; }
  #ed-plot { height: 52vh; min-height: 350px; }
  .ed-results { grid-template-columns: 1fr; }
  .ed-result { border-right: 0; border-bottom: 1px solid var(--line); }
  .ed-result:last-child { border-bottom: 0; }
  .ed-grid-2 { grid-template-columns: 1fr 1fr; }
  .ed-preset-grid { grid-template-columns: 1fr; }
  .ed-expression-row { grid-template-columns: 1fr 1fr auto; }
  .ed-plot-help { display: none; }
}


/* Selector/app polish refresh */
.ed-button, .ed-icon-button, .ed-segment button, .ed-preset, .ed-input, .ed-select, .ed-remove, .ed-section, .ed-mark {
  border-radius: 6px;
}
.ed-plot-help {
  border-radius: 5px;
  font-size: .72rem;
}
.ed-callout { line-height: 1.5; }

/* v3: mathematical workspace */
.ed-topbar {box-shadow:none;background:#f7f6f2;border-bottom:1px solid #d7d8d6;}
.ed-title {font-family:Georgia,serif;font-weight:400;}
.ed-sidebar {background:#f7f6f2;}
.ed-section {box-shadow:none;border-radius:4px;}
.ed-plot-toolbar {position:absolute;inset:0 0 auto;z-index:6;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 14px;pointer-events:none;font-size:11px;color:#667781;}
.ed-plot-toolbar button {pointer-events:auto;min-height:34px;font-size:11px;}
.ed-guides {position:absolute;left:0;top:0;z-index:3;pointer-events:none;overflow:hidden;user-select:none;}
.ed-guides [data-guide]:focus-visible {stroke:#af873f;stroke-opacity:.18;outline:none;}
.ed-equation {font-size:12px;min-width:0;max-width:100%;overflow-x:auto;padding:5px 0;}
.ed-equation mjx-container[display="true"] {margin:.6em 0!important;}
.ed-plot-help {bottom:6px;left:56px;z-index:4;border:0;background:transparent;backdrop-filter:none;}
.ed-result-note {font-size:.74rem;line-height:1.5;}
.ed-preset {min-height:38px;}
#ed-plot {touch-action:none;min-height:240px;}
@media(max-width:900px) {.ed-preset-grid{grid-template-columns:repeat(2,minmax(0,1fr));}.ed-results{grid-template-columns:repeat(2,minmax(0,1fr));}.ed-result{padding:12px;}}
@media(max-width:560px) {.ed-title{max-width:190px;line-height:1.25}.ed-result-value{font-size:1rem}.ed-result-note{font-size:.75rem}.ed-button,.ed-input,.ed-segment button{min-height:42px}.ed-plot-toolbar span{max-width:48%;font-size:10px}.ed-plot-toolbar button{min-height:36px}.ed-equation{font-size:13px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}

/* Greek mathematical symbols retain their case in result labels. */
.ed-result-label { text-transform: none; }

/* Readable controls and compact, unbroken mathematical expressions. */
:root {font-size:16px;}
.ed-input,.ed-select,.ed-button {font-size:.875rem;}
.ed-label,.ed-help,.ed-preset,.ed-segment button {font-size:.81rem;}
.ed-callout,.ed-result-label {font-size:.78rem;}
.ed-math-copy {font-size:.87rem;line-height:1.7;}
.ed-math-copy p {margin:.4rem 0 .85rem;}
.ed-equation {font-size:17px;}
.ed-equation mjx-container {max-width:100%;}
.ed-learn-link {color:var(--blue);text-underline-offset:3px;}
@media(max-width:560px) {.ed-math-copy{font-size:.9rem}.ed-title{max-width:175px}.ed-subtitle{display:none}}
