/* Online Calculator — lightweight responsive stylesheet */
:root {
  color-scheme: light;
  --page: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f0f4fa;
  --text: #172033;
  --muted: #68748a;
  --line: #e3e9f2;
  --accent: #4263eb;
  --accent-hover: #3452d5;
  --accent-soft: #e9edff;
  --operator: #edf1ff;
  --utility: #e9edf4;
  --shadow: 0 18px 55px rgba(27, 43, 75, .10);
  --radius: 22px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101522;
  --surface: #1a2233;
  --surface-soft: #222d42;
  --text: #f0f3fa;
  --muted: #a2aec3;
  --line: #303b50;
  --accent: #8298ff;
  --accent-hover: #9aabff;
  --accent-soft: #29345c;
  --operator: #2b3656;
  --utility: #303b50;
  --shadow: 0 18px 55px rgba(0, 0, 0, .28);
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  transition: background-color .2s ease, color .2s ease;
}
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.site-header {
  width: min(1120px, calc(100% - 36px));
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-size: 1.08rem; font-weight: 800;
  letter-spacing: -.04em;
}
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 12px; background: var(--accent); color: #fff; font-size: 1.35rem;
}
.brand-light { font-weight: 500; color: var(--muted); margin-left: 3px; }
.header-actions { display: flex; gap: 8px; }
.icon-button, .small-button, .text-button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .15s ease, transform .15s ease;
}
.icon-button {
  width: 42px; height: 42px; border-radius: 14px; font-size: 1.15rem;
}
.icon-button:hover, .small-button:hover { background: var(--surface-soft); }
.page-shell { width: min(1120px, calc(100% - 36px)); margin: 0 auto; }
.intro { max-width: 760px; margin: 35px auto 28px; text-align: center; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-size: clamp(1.75rem, 4.5vw, 2.7rem); line-height: 1.16; letter-spacing: -.045em; }
.intro-text { max-width: 650px; margin: 14px auto 0; color: var(--muted); font-size: 1rem; }
.calculator-section { display: flex; justify-content: center; }
.calculator {
  width: min(100%, 470px); padding: 18px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.calculator-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.mode-switch { display: inline-flex; padding: 4px; gap: 3px; border-radius: 12px; background: var(--surface-soft); }
.mode-button {
  min-height: 34px; padding: 5px 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); font-size: .82rem; font-weight: 700; cursor: pointer;
}
.mode-button.active { color: var(--accent); background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.toolbar-right { display: flex; align-items: center; gap: 6px; }
.small-button { min-height: 34px; padding: 5px 10px; border-radius: 9px; font-size: .76rem; font-weight: 750; }
.angle-button { color: var(--accent); min-width: 48px; }
.display {
  min-height: 128px; padding: 14px 14px 12px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft);
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
}
.expression {
  min-height: 25px; color: var(--muted); text-align: right; font-size: .98rem;
  overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
.result-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.result {
  min-width: 0; color: var(--text); font-size: clamp(2rem, 8vw, 2.65rem);
  line-height: 1.2; font-weight: 750; letter-spacing: -.045em; text-align: right;
  overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
.copy-button {
  flex: 0 0 34px; width: 34px; height: 34px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer;
}
.copy-button:hover { background: var(--line); color: var(--text); }
.status-message { min-height: 18px; margin: 5px 0 0; color: #d34b4b; text-align: right; font-size: .72rem; }
.scientific-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.scientific-grid[hidden], .history-panel[hidden] { display: none; }
.keypad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.key {
  min-width: 0; min-height: 58px; border: 1px solid transparent; border-radius: 15px;
  background: var(--surface-soft); color: var(--text); cursor: pointer;
  font-size: 1.18rem; font-weight: 650; transition: transform .12s ease, filter .12s ease, background .12s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.key:active { transform: scale(.96); }
.key:hover { filter: brightness(.97); }
.key.number { background: var(--surface); border-color: var(--line); }
.key.utility { background: var(--utility); color: var(--muted); font-size: 1rem; }
.key.operator, .key.function { background: var(--operator); color: var(--accent); }
.key.function { min-height: 43px; border-radius: 11px; font-size: .9rem; }
.key.equals { background: var(--accent); color: #fff; font-size: 1.45rem; }
.key.equals:hover { background: var(--accent-hover); }
.key.zero { grid-column: auto; }
.history-panel { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.history-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.history-heading h2 { margin: 0; font-size: .92rem; }
.text-button { padding: 4px 7px; border: 0; background: transparent; color: var(--accent); font-size: .78rem; }
.history-list { display: grid; gap: 7px; max-height: 190px; overflow-y: auto; margin: 10px 0 0; padding: 0; list-style: none; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.history-entry { min-width: 0; overflow: hidden; }
.history-expression { display: block; color: var(--muted); font-size: .73rem; overflow-wrap: anywhere; }
.history-result { display: block; font-size: .94rem; font-weight: 700; }
.history-recall { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--surface); color: var(--text); cursor: pointer; font-size: .75rem; }
.history-empty { color: var(--muted); font-size: .82rem; }
.calculator-hint { margin: 13px 0 0; color: var(--muted); text-align: center; font-size: .72rem; }
.info-section { max-width: 820px; margin: 58px auto 50px; }
.info-section h2 { margin: 30px 0 8px; font-size: 1.22rem; line-height: 1.35; letter-spacing: -.02em; }
.info-section h2:first-child { margin-top: 0; }
.info-section p { margin: 0; color: var(--muted); font-size: .96rem; }
kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--surface); color: var(--text); font-family: inherit; font-size: .85em;
}
.site-footer { padding: 24px 18px 30px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .78rem; }
.site-footer p { margin: 3px 0; }
@media (min-width: 700px) {
  .intro { margin-top: 48px; margin-bottom: 32px; }
  .calculator { padding: 22px; }
  .key { min-height: 62px; }
  .scientific-grid { gap: 9px; }
}
@media (max-width: 390px) {
  .site-header, .page-shell { width: min(100% - 24px, 1120px); }
  .calculator { padding: 12px; border-radius: 18px; }
  .calculator-toolbar { gap: 5px; }
  .mode-button { padding-inline: 8px; font-size: .76rem; }
  .small-button { padding-inline: 7px; font-size: .7rem; }
  .keypad { gap: 7px; }
  .key { min-height: 55px; border-radius: 12px; }
  .scientific-grid { gap: 6px; }
  .key.function { font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
