/* Direction: SmartCalc — cool slate paper, electric indigo keys, a geometric display */
/* Completed by the platform from the short form: both modes, every
   palette token, each text-on-ground pair at its floor. To restyle, write the
   short form again (the decisions in one :root) and it is completed again. */

:root {
  --canvas: #eef1f7;
  --surface: #ffffff;
  --surface-2: #e3e5ec;
  --border: #ced1d9;
  --border-strong: #aaacb7;
  --ink: #12172a;
  --muted: #626572;
  --accent: #4f46e5;
  --accent-hover: #433cc3;
  --accent-ink: #ffffff;
  --accent-text: #4338ca;
  --accent-strong: #4f46e5;
  --accent-soft: #d8d9f4;
  --accent-border: #a6a4ef;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #d4e3e1;
  --success-strong: #116d34;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #e7deda;
  --warning-strong: #994607;
  --danger: #c62828;
  --danger-ink: #ffffff;
  --danger-soft: #e9d9de;
  --danger-strong: #b62525;
  --chart-1: #4f46e5;
  --chart-2: #ce31b1;
  --chart-3: #8c2906;
  --chart-4: #8e7a06;
  --chart-5: #015d36;
  --chart-6: #198ba4;

  --font-display: "Manrope", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius-card: 24px;
  --radius-btn: 16px;
  --display-weight: 800;
  --display-tracking: -0.03em;
  --shadow-card: 0 20px 50px -24px rgba(30, 35, 90, 0.35);
  --font-sans: "Inter", system-ui, sans-serif;
  --eyebrow-tracking: 0.08em;
}

html[data-theme="dark"] {
  --canvas: #080817;
  --surface: #21212e;
  --surface-2: #141423;
  --border: #2b2b37;
  --border-strong: #52525d;
  --ink: #eef1f7;
  --muted: #92949d;
  --accent: #4f46e5;
  --accent-hover: #6962e9;
  --accent-ink: #ffffff;
  --accent-text: #817bed;
  --accent-strong: #817bed;
  --accent-soft: #181644;
  --accent-border: #282474;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #0b221f;
  --success-strong: #499c68;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #2e1914;
  --warning-strong: #c57a40;
  --danger: #c62828;
  --danger-ink: #ffffff;
  --danger-soft: #320f1b;
  --danger-strong: #d76565;
  --chart-1: #5954f3;
  --chart-2: #dc41bd;
  --chart-3: #db450e;
  --chart-4: #9c8600;
  --chart-5: #0f985d;
  --chart-6: #1799b4;
}

.screen {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem 1.1rem;
  min-height: 8.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  overflow: hidden;
}
.screen-expr {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 1.4rem;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
}
.screen-result {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 3rem;
  line-height: 1.15;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--ink);
  letter-spacing: -0.03em;
}
.screen-result[data-len="m"] { font-size: 2.3rem; }
.screen-result[data-len="l"] { font-size: 1.7rem; }
.screen-result.is-error { color: var(--danger-strong); font-size: 1.5rem; }
.screen-result.flash { animation: sc-pop 0.28s ease-out; }
@keyframes sc-pop {
  from { transform: translateY(8px) scale(0.97); }
  to { transform: none; }
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.key {
  display: grid;
  place-items: center;
  height: 4rem;
  border-radius: 18px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}
.key:hover { background: var(--accent-soft); }
.key:active, .key.is-down { transform: translateY(2px) scale(0.95); box-shadow: none; }
.key:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.key .icon { width: 1.5rem; height: 1.5rem; }
.key-fn { color: var(--accent-text); }
.key-op { background: var(--accent-soft); color: var(--accent-strong); font-size: 1.7rem; }
.key-eq { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-size: 1.8rem; }
.key-eq:hover { background: var(--accent-hover); }
@media (min-width: 640px) { .key { height: 4.25rem; } .screen-result { font-size: 3.4rem; } }
@media (max-width: 380px) { .key { height: 3.5rem; font-size: 1.25rem; } .keys { gap: 0.45rem; } }

.hist-item {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  animation: sc-in 0.25s ease-out;
}
@keyframes sc-in { from { transform: translateX(-10px); } to { transform: none; } }
.hist-load {
  flex: 1;
  min-width: 0;
  text-align: right;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.hist-load:hover { background: var(--accent-soft); }
.hist-load:active { transform: scale(0.98); }
.hist-load:focus-visible, .hist-use:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hist-expr { display: block; font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-res { display: block; font-family: var(--font-mono); font-weight: 700; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; }
.hist-use {
  padding: 0 0.8rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  color: var(--accent-text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
}
.hist-use:hover { background: var(--accent-soft); }

html.reduced-motion .key, html.reduced-motion .hist-item, html.reduced-motion .screen-result { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .key, .hist-item, .screen-result.flash { animation: none; transition: none; }
}
