@charset "UTF-8";

:root {
  color-scheme: light;
  --paper: #f5f3ec;
  --panel: #fcfbf6;
  --well: #efeee5;
  --ink: #30382f;
  --muted: #73786b;
  --line: #dcded1;
  --green: #42654e;
  --green-dark: #314e3a;
  --green-pale: #e9eee3;
  --error: #a24535;
  --ui: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, monospace;
  font: 14px/1.5 var(--ui);
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button, input, select, textarea { border: 1px solid var(--line); border-radius: 5px; }
button { min-height: 32px; padding: 5px 12px; background: var(--panel); transition: background 120ms ease, border-color 120ms ease; }
button:hover:not(:disabled) { background: var(--green-pale); border-color: #b7c6af; }
button:active:not(:disabled) { background: #dce5d5; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, canvas:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
input, textarea { background: var(--panel); }
input { min-width: 0; width: 100%; padding: 7px 8px; }
textarea { resize: vertical; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
::selection { background: #d9e4cf; }

.app-shell { width: min(1120px, 100%); min-height: 100vh; min-height: 100svh; margin: 0 auto; display: flex; flex-direction: column; padding: 0 28px; }
.app-header { display: flex; gap: 25px; align-items: center; min-height: 86px; padding: 15px 0; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font: 400 32px/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.8px; }
.mode-switch { display: flex; flex-shrink: 0; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--well); }
.mode-switch button { min-height: 31px; padding: 5px 16px; border-color: transparent; color: var(--muted); background: transparent; font-size: 12px; }
.mode-switch button[aria-pressed="true"] { border-color: #d1d8c9; color: var(--green-dark); background: var(--panel); box-shadow: 0 1px 3px #2d3a2510; }
.engine-status { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.engine-status::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 7px 2px 0; border-radius: 50%; background: #a4aa97; }
.engine-status[data-state="ready"]::before { background: #648257; }
.engine-status[data-state="error"] { color: var(--error); }
.engine-status[data-state="error"]::before { background: var(--error); }

.scientific-layout { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 520px; margin: 28px auto 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: 0 7px 30px #333c2506; }
.calculator-panel { min-width: 0; padding: 22px; }
.expression-panel { padding: 15px 17px 10px; border: 1px solid #d9dfd0; border-radius: 6px; background: #f0f3e9; }
.section-heading { display: flex; min-height: 27px; align-items: center; justify-content: space-between; gap: 10px; }
.section-heading > label, h2 { margin: 0; color: var(--muted); font: 600 10px/1.4 var(--ui); letter-spacing: .12em; text-transform: uppercase; }
.expression-actions { display: flex; align-items: center; gap: 4px; }
.expression-actions button { min-height: 25px; padding: 2px 7px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.expression-actions button[data-action="backspace"] { font-size: 17px; line-height: 1; }
#expression, #large-expression { display: block; width: 100%; min-height: 64px; max-height: 190px; margin: 8px 0 0; padding: 4px 0; border: 0; border-radius: 0; background: transparent; font: 20px/1.55 var(--mono); overflow-wrap: anywhere; }
#expression:focus-visible, #large-expression:focus-visible { outline-offset: 4px; }
.result-line { display: flex; align-items: baseline; min-height: 62px; gap: 14px; padding-top: 9px; border-top: 1px solid #dce2d4; }
.result-label { color: #99a38b; font: 22px/1 var(--mono); }
#result { min-width: 0; margin-left: auto; overflow-wrap: anywhere; text-align: right; color: #344b34; font: 400 clamp(23px, 3.5vw, 33px)/1.35 var(--mono); font-variant-numeric: tabular-nums; }
.large-result-line { align-items: flex-start; }
#large-result { display: block; min-width: 0; flex: 1; padding-bottom: 5px; overflow-wrap: anywhere; word-break: break-word; text-align: right; color: #344b34; font: 400 20px/1.55 var(--mono); font-variant-numeric: tabular-nums; user-select: text; }
.large-result-actions { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.large-result-actions .text-button { flex-shrink: 0; padding-right: 0; }
.result-note { margin: 0; color: var(--muted); font-size: 10px; }
.large-mode-help { margin: 17px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.error-message { margin: 7px 0 0; color: var(--error); font-size: 12px; overflow-wrap: anywhere; }
.error-message:empty { display: none; }
.calculator-settings { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin: 15px 0; }
.angle-setting { display: inline-flex; gap: 9px; align-items: center; color: var(--muted); font-size: 11px; }
#angle-mode { min-height: 29px; max-width: 103px; padding: 3px 5px; background: var(--panel); font-size: 11px; }
#large-precision { min-height: 29px; max-width: 160px; padding: 3px 5px; background: var(--panel); font-size: 11px; }
.memory-controls { display: flex; align-items: center; gap: 4px; }
.memory-label { margin-right: 4px; color: var(--muted); font-size: 10px; }
.memory-controls button { min-height: 26px; padding: 3px 7px; border-color: transparent; background: var(--well); color: var(--muted); font: 11px/1.4 var(--mono); }
.keypad { display: grid; gap: 13px; }
.function-keys { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.large-layout .function-keys { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.function-keys button { min-height: 38px; padding: 4px 0; background: var(--well); border-color: transparent; color: #58634f; font: 13px/1 var(--mono); }
.number-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.number-keys button { min-height: 45px; padding: 6px 0; background: #fffef9; font: 23px/1.2 var(--mono); box-shadow: 0 1px 1px #38462805; }
.number-keys button.operator { color: var(--green); background: var(--green-pale); border-color: #d5dfcc; }
button.primary { color: #fffef6; background: var(--green); border-color: var(--green); }
button.primary:hover:not(:disabled) { color: #fffef6; background: var(--green-dark); border-color: var(--green-dark); }
button.primary:active:not(:disabled) { background: #263e2e; }
.keyboard-hint { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 14px 0 0; color: var(--muted); font-size: 10px; }
.keyboard-hint > span { margin: 0 4px; }
kbd { font: inherit; }

.history-panel { display: flex; min-width: 0; flex-direction: column; padding: 22px 20px 17px; border-top: 1px solid var(--line); background: #f7f7f0; }
.text-button { min-height: 27px; padding: 3px 7px; border-color: transparent; background: transparent; color: var(--green); font-size: 11px; }
.history-list { flex: 1; max-height: 230px; margin: 13px -7px 0; padding: 0; list-style: none; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #c5ccba transparent; }
.history-list:empty::before { content: "No calculations yet."; display: block; margin: 10px 7px; color: #8b9280; font-size: 12px; }
.history-list li { border-bottom: 1px solid #e3e5da; }
.history-list li > button { display: flex; width: 100%; min-width: 0; flex-direction: column; align-items: stretch; gap: 6px; margin: 0; padding: 12px 8px; border: 0; border-radius: 4px; background: transparent; text-align: left; }
.history-expression { display: block; overflow-wrap: anywhere; font: 12px/1.5 var(--mono); color: var(--muted); }
.history-result { display: block; overflow-wrap: anywhere; text-align: right; font: 17px/1.4 var(--mono); color: var(--green-dark); }
.history-hint { padding-top: 14px; margin: auto 0 0; color: #8b9280; font-size: 10px; }

.graphing-layout { display: grid; grid-template-columns: 255px minmax(0, 1fr); min-height: 580px; margin: 28px 0 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: 0 7px 30px #333c2506; }
.graph-controls { min-width: 0; padding: 20px 16px; border-right: 1px solid var(--line); background: #f7f7f0; }
.functions-list { display: grid; gap: 8px; margin-top: 16px; }
.function-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.function-row input[type="text"], .function-row input:not([type]) { flex: 1; width: 0; min-width: 80px; padding: 8px; font: 13px/1.4 var(--mono); }
.function-row label { color: var(--muted); font: 12px/1 var(--mono); }
.function-color { display: inline-block; width: 7px; height: 7px; flex: none; border-radius: 50%; }
.function-row input[type="color"] { width: 16px; height: 25px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.function-row button { width: 25px; min-height: 28px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 18px; }
.function-error { flex-basis: 100%; margin: 0; color: var(--error); font-size: 11px; }
.bounds { min-width: 0; margin: 27px 0 0; padding: 13px 0 0; border: 0; border-top: 1px solid var(--line); }
.bounds legend { padding: 0 9px 0 0; color: var(--muted); font: 600 10px/1.4 var(--ui); letter-spacing: .12em; text-transform: uppercase; }
.bounds-head, .bounds-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) minmax(0, 1fr); gap: 7px; align-items: center; margin-top: 7px; }
.bounds-head { margin-top: 0; color: var(--muted); font-size: 9px; text-align: center; }
.bounds-row input { font: 12px/1.5 var(--mono); text-align: center; }
.axis-label { color: var(--green); font: italic 15px/1 Georgia, serif; }
.graph-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 17px; }
.graph-actions button { padding-inline: 5px; font-size: 12px; }
.graph-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.graph-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; min-height: 42px; gap: 8px; padding: 9px 15px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.graph-tools { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.graph-tools button { min-height: 24px; width: 26px; padding: 0; background: transparent; font-size: 15px; line-height: 1; }
#graph-readout { font: 10px/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.graph-tools #graph-readout { margin-right: 7px; }
.graph-stage { position: relative; flex: 1; min-height: 400px; overflow: hidden; background: #fcfbf6; }
#graph { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.syntax-help { margin: 0 0 20px; color: var(--muted); font-size: 12px; }
.syntax-help summary { width: fit-content; padding: 2px 0; color: var(--green); cursor: pointer; }
.syntax-content { max-width: 800px; padding: 0 0 0 15px; }
.syntax-content p { margin: 10px 0; }
code { padding: 1px 4px; border-radius: 3px; background: #eaece1; color: #4c5d43; font: 11px/1.5 var(--mono); white-space: nowrap; }
.app-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: auto; padding: 12px 0 14px; border-top: 1px solid var(--line); font-size: 11px; }
.app-footer a { color: var(--muted); }
.app-footer a:hover { color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 1000px) and (min-height: 850px) {
  .app-header { min-height: 100px; }
  .scientific-layout, .graphing-layout { margin-top: 40px; }
  .calculator-panel { padding: 28px; }
  .history-panel { padding: 28px 24px 20px; }
  .number-keys button { min-height: 51px; }
  .graphing-layout { min-height: 630px; }
}

@media (max-width: 760px) {
  .app-shell { padding-inline: 18px; }
  .app-header { gap: 18px; min-height: 76px; }
  h1 { font-size: 28px; }
  .mode-switch button { padding-inline: 12px; }
  .engine-status { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .scientific-layout { margin-top: 20px; }
  .calculator-panel { padding: 15px; }
  .history-panel { padding: 17px 13px; }
  .memory-label { display: none; }
  .function-keys { gap: 5px; }
  .function-keys button { font-size: 12px; }
  .graphing-layout { grid-template-columns: 215px minmax(0, 1fr); margin-top: 20px; min-height: 540px; }
  .graph-controls { padding: 16px 12px; }
}

@media (max-width: 660px) {
  .app-shell { padding-inline: 12px; }
  .app-header { display: grid; grid-template-columns: 1fr auto; gap: 12px 10px; padding: 16px 0 13px; }
  h1 { font-size: 28px; }
  .mode-switch { grid-row: 2; grid-column: 1 / -1; }
  .mode-switch button { flex: 1; }
  .engine-status { grid-column: 2; grid-row: 1; max-width: 160px; font-size: 10px; }
  .scientific-layout { margin: 15px auto; }
  .calculator-panel { padding: 14px; }
  .expression-panel { padding: 11px 13px 8px; }
  #expression, #large-expression { min-height: 60px; font-size: 19px; }
  .result-line { min-height: 52px; }
  #result { font-size: 27px; }
  .calculator-settings { margin-block: 12px; }
  .memory-label { display: inline; }
  .function-keys button { min-height: 38px; }
  .number-keys button { min-height: 46px; }
  .history-panel { padding: 14px 17px; }
  .history-list { margin-top: 8px; }
  .history-hint { padding-top: 10px; }
  .graphing-layout { display: flex; flex-direction: column; margin: 15px 0; }
  .graph-controls { padding: 15px; border-right: 0; border-bottom: 1px solid var(--line); }
  .functions-list { margin-top: 10px; }
  .bounds { margin-top: 19px; }
  .bounds-head, .bounds-row { grid-template-columns: 15px 1fr 1fr; }
  .graph-actions { margin-top: 12px; }
  .graph-stage { min-height: 360px; }
  .syntax-help { font-size: 11px; }
}

@media (max-width: 340px) {
  .app-shell { padding-inline: 8px; }
  .calculator-panel { padding: 10px; }
  .memory-label { display: none; }
  .function-keys { gap: 4px; }
  .function-keys button { font-size: 11px; }
  .calculator-settings { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* Compact spacing for application windows, without changing standalone sizing. */
.embedded .app-shell { padding-inline: 14px; }
.embedded .app-header { display: flex; min-height: 43px; padding-block: 7px; gap: 8px; }
.embedded h1 { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.embedded .mode-switch { flex: 1; }
.embedded .mode-switch { padding: 2px; }
.embedded .mode-switch button { min-height: 26px; padding: 3px 11px; font-size: 11px; }
.embedded .engine-status { font-size: 10px; }
.embedded .scientific-layout, .embedded .graphing-layout { margin-block: 11px; }
.embedded .calculator-panel { padding: 12px; }
.embedded .expression-panel { padding: 6px 10px; }
.embedded .section-heading { min-height: 20px; }
.embedded #expression, .embedded #large-expression { height: 40px; min-height: 40px; margin-top: 3px; padding-block: 2px; font-size: 17px; line-height: 1.3; }
.embedded .result-line { min-height: 34px; padding-top: 4px; }
.embedded #result { font-size: 26px; }
.embedded #large-result { font-size: 17px; line-height: 1.4; }
.embedded .calculator-settings { margin-block: 6px; gap: 6px; }
.embedded .angle-setting { font-size: 10px; gap: 5px; }
.embedded #angle-mode, .embedded #large-precision { min-height: 25px; font-size: 10px; padding: 2px 4px; }
.embedded .memory-controls button { min-height: 24px; padding: 2px 6px; font-size: 10px; }
.embedded .keypad { gap: 6px; }
.embedded .function-keys, .embedded .number-keys { gap: 4px; }
.embedded .function-keys button { min-height: 26px; padding-block: 3px; font-size: 11px; }
.embedded .number-keys button { min-height: 30px; padding-block: 3px; font-size: 19px; }
.embedded .keyboard-hint { display: none; }
.embedded .large-mode-help { margin-top: 9px; font-size: 10px; }
.embedded .history-panel { padding: 12px; }
.embedded .history-expression { font-size: 11px; }
.embedded .history-result { font-size: 14px; }
.embedded .history-hint { padding-top: 8px; }
.embedded .syntax-help { margin-bottom: 8px; font-size: 10px; }
.embedded .app-footer { padding-block: 7px; font-size: 10px; }
.embedded .graphing-layout { min-height: calc(100svh - 113px); grid-template-columns: 205px minmax(0, 1fr); }
.embedded .graph-controls { padding: 12px; }
.embedded .graph-stage { min-height: 250px; }
.embedded .function-row input[type="text"] { padding: 5px; font-size: 12px; }
.embedded .bounds { margin-top: 17px; }
.embedded .bounds-row input { padding: 5px; font-size: 11px; }
.embedded .graph-toolbar { min-height: 33px; padding: 5px 9px; }
@media (max-width: 660px) {
  .embedded .app-shell { padding-inline: 9px; }
  .embedded .app-header { gap: 7px; }
  .embedded .mode-switch button { padding-inline: 7px; }
  .embedded .calculator-panel { padding: 10px; }
  .embedded .graphing-layout { display: flex; }
}
