/* Calculate ’Em Turbo — counter calculator and receipt pad, not a racetrack. */
:root {
  --paper: #e7deca;
  --paper-2: #fffaf0;
  --ink: #1a1814;
  --muted: #5a5348;
  --line: #cfc3a8;
  --pine: #24543c;
  --pine-ink: #e8f3ee;
  --ember: #c24a1a;
  --ember-ink: #fff6f1;
  --shell: #141612;
  --readout: #0b120e;
  --readout-num: #f3cf6a;
  --readout-glow: rgba(243, 207, 106, 0.32);
  --readout-label: #b7b39a;
  --bezel: #2c3228;
  --danger: #8f1d1d;
  --danger-bg: #f8e6e4;
  --focus: #24543c;
  --shadow: 0 12px 28px rgba(26, 24, 20, 0.1);
  --radius: 12px;
  --max: 70rem;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image:
    linear-gradient(180deg, rgba(255, 250, 240, 0.55), transparent 14rem),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 31px,
      rgba(26, 24, 20, 0.035) 32px
    );
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
}

a {
  color: var(--pine);
}

a:hover {
  color: var(--ember);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.tm-skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 20;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: #fff;
}

.tm-skip:focus {
  top: 0.75rem;
}

.tm-wrap {
  width: min(var(--max), calc(100% - 2rem));
  margin-inline: auto;
}

.tm-top {
  background: var(--shell);
  color: #f4efe3;
  border-bottom: 6px solid var(--ember);
  box-shadow: 0 8px 0 #0b0c0a;
}

.tm-top a {
  color: inherit;
  text-decoration: none;
}

.tm-top-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.8rem 0;
}

.tm-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.tm-badge {
  display: inline-grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  background: var(--readout);
  color: var(--readout-num);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--bezel), 0 0 10px var(--readout-glow);
}

.tm-mark span {
  color: var(--readout-num);
}

.tm-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.95rem;
}

.tm-nav a {
  padding: 0.2rem 0;
}

.tm-nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.28em;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--readout-num);
}

.tm-main {
  flex: 1;
  padding: 1.6rem 0 3rem;
}

.tm-kicker {
  margin: 0 0 0.35rem;
  color: var(--ember);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.tm-lead,
.tm-prose p,
.tm-note,
.tm-when p {
  max-width: 42rem;
}

.tm-lead {
  margin: 0 0 1.25rem;
}

.tm-grid {
  display: grid;
  gap: 1rem;
}

.tm-grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.tm-grid-tools {
  grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
}

.tm-tile {
  position: relative;
  display: block;
  padding: 1rem 1.05rem 1.1rem 1.35rem;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0 11px,
      rgba(26, 24, 20, 0.035) 11px 12px
    ),
    var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 4px 12px 12px 4px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}

.tm-tile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  background:
    radial-gradient(circle at 4px 7px, var(--paper) 3px, var(--ember) 3.4px) 0 0 / 12px 14px;
}

.tm-tile:hover {
  border-color: #b7a888;
}

.tm-tile h2,
.tm-tile h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}

.tm-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.tm-workbench {
  display: grid;
  gap: 0.85rem;
  margin: 1.25rem 0 1.75rem;
  padding: 0.85rem;
  background: linear-gradient(180deg, #3a3d34, #242620);
  border-radius: 18px;
  box-shadow: 0 14px 0 #0e0f0d, 0 22px 36px rgba(26, 24, 20, 0.22);
}

@media (max-width: 879px) {
  .tm-readout {
    order: -1;
    max-height: none;
    position: static;
  }

  .tm-explain,
  .tm-limit {
    font-size: 0.88rem;
  }
}

@media (min-width: 880px) {
  .tm-workbench {
    grid-template-columns: minmax(0, 1.1fr) minmax(16rem, 0.9fr);
    align-items: start;
  }
}

.tm-panel,
.tm-when,
.tm-faq,
.tm-extras,
.tm-search,
.tm-next {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tm-panel {
  background:
    linear-gradient(180deg, #fffef8, #f6eedc);
  border: 2px solid #c9b892;
  box-shadow: inset 0 1px 0 #fff, var(--shadow);
}

.tm-panel,
.tm-when,
.tm-faq,
.tm-extras,
.tm-search {
  padding: 1rem 1.1rem 1.15rem;
}

.tm-readout {
  position: sticky;
  top: 0.6rem;
  padding: 1.05rem 1.1rem 1.15rem;
  background:
    linear-gradient(180deg, rgba(243, 207, 106, 0.07), transparent 42%),
    var(--readout);
  color: #f4efe3;
  border: 5px solid var(--bezel);
  border-radius: 10px;
  box-shadow:
    inset 0 0 42px rgba(0, 0, 0, 0.4),
    0 0 0 1px #090b08,
    0 14px 28px rgba(0, 0, 0, 0.18);
}

.tm-readout h2 {
  margin: 0 0 0.65rem;
  color: var(--readout-label);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tm-figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.tm-figure + .tm-figure {
  padding-top: 0.7rem;
  border-top: 1px dashed #3a4034;
}

.tm-figure-label {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--readout-label);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tm-num {
  font-family: var(--mono);
  font-size: clamp(1.9rem, 5vw, 2.75rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--readout-num);
  text-shadow: 0 0 14px var(--readout-glow);
  line-height: 1.05;
}

.tm-num-sub {
  font-size: clamp(1.25rem, 3vw, 1.7rem);
}

.tm-copy {
  appearance: none;
  border: 1px solid #6f6844;
  background: #171b14;
  color: var(--readout-num);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.tm-copy:hover {
  background: #22271d;
}

.tm-explain,
.tm-limit {
  margin: 0.45rem 0 0;
  color: #e4decc;
  font-size: 0.95rem;
}

.tm-limit {
  color: #c9c3b0;
}

.tm-modes {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.tm-modes button {
  appearance: none;
  width: 100%;
  border: 1px solid #c9b892;
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 0 #d8ccb0;
}

.tm-modes button[aria-pressed="true"] {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
  box-shadow: 0 2px 0 #163628;
}

.tm-field {
  display: grid;
  gap: 0.28rem;
  margin-bottom: 0.85rem;
}

.tm-field label {
  font-weight: 650;
}

.tm-field input:not([type="radio"]):not([type="checkbox"]),
.tm-field select,
.tm-field textarea,
.tm-search input {
  width: 100%;
  min-height: 2.85rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid #c4b48e;
  border-radius: 8px;
  background: #f7f1e2;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1.12rem;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65);
}

.tm-field textarea {
  min-height: 6.5rem;
  resize: vertical;
  font-family: inherit;
  font-size: 1.05rem;
}

.tm-field input[aria-invalid="true"],
.tm-field textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.tm-err {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 0.88rem;
}

.tm-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.tm-example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.8rem;
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffef8;
}

.tm-example .tm-btn {
  flex: 0 0 auto;
}

.tm-example span {
  color: var(--muted);
  font-size: 0.92rem;
  flex: 1 1 12rem;
}

.tm-choices,
fieldset.tm-field {
  border: 0;
  margin: 0 0 0.85rem;
  padding: 0;
  min-width: 0;
}

.tm-choices legend,
fieldset.tm-field legend {
  padding: 0;
  margin: 0 0 0.45rem;
  font-weight: 650;
}

.tm-radios {
  display: grid;
  gap: 0.5rem;
}

.tm-radios label {
  display: grid;
  grid-template-columns: 1.2rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef8;
  font-weight: 500;
}

.tm-radios label:has(input:checked) {
  border-color: var(--pine);
  background: #eef6f1;
}

.tm-radios input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  min-width: 1.15rem;
  margin: 0.2rem 0 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  accent-color: var(--pine);
}

.tm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.tm-btn {
  appearance: none;
  border: 0;
  background: var(--pine);
  color: #fff;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 0 #163628;
}

.tm-btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 #d8ccb0;
}

.tm-cheaper {
  outline: 2px solid var(--pine);
  outline-offset: 4px;
  border-radius: 8px;
  background: #eef6f1;
}

.tm-panel .tm-grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem 1.25rem;
}

.tm-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px dashed #3a4034;
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

.tm-next {
  margin-top: 1rem;
  padding: 1rem 1.1rem 1.15rem;
}

.tm-more {
  margin-bottom: 0.85rem;
  padding: 0.15rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef8;
}

.tm-more[open] {
  padding-bottom: 0.75rem;
}

.tm-more summary {
  cursor: pointer;
  font-weight: 650;
  padding: 0.55rem 0.1rem;
  list-style: none;
}

.tm-more summary::-webkit-details-marker {
  display: none;
}

.tm-more summary::before {
  content: "+";
  display: inline-block;
  width: 1.15rem;
  margin-right: 0.2rem;
  color: var(--pine);
  font-family: var(--mono);
}

.tm-more[open] summary::before {
  content: "–";
}

.tm-when h2,
.tm-faq h2,
.tm-extras h2,
.tm-search h2,
.tm-next h2,
.tm-prose h2 {
  margin: 0 0 0.55rem;
  font-size: 1.2rem;
}

.tm-extras ol {
  margin: 0;
  padding-left: 1.2rem;
}

.tm-extras li + li,
.tm-faq details + details {
  margin-top: 0.65rem;
}

.tm-faq details {
  border-top: 1px dashed var(--line);
  padding: 0.55rem 0 0.15rem;
}

.tm-faq details:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.tm-faq summary {
  cursor: pointer;
  font-weight: 650;
}

.tm-foot {
  margin-top: auto;
  padding: 1.35rem 0 1.6rem;
  background:
    repeating-linear-gradient(
      90deg,
      var(--paper) 0 10px,
      transparent 10px 14px
    ),
    #ddd3bb;
  color: var(--muted);
  font-size: 0.92rem;
  border-top: 2px dashed #c4b48e;
}

.tm-foot-inner {
  display: grid;
  gap: 0.65rem;
}

.tm-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
}

.tm-foot a {
  color: var(--pine);
}

.tm-empty {
  color: var(--muted);
}

.tm-lines {
  display: grid;
  gap: 0.55rem;
}

.tm-line-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(8.5rem, 11rem) auto;
  gap: 0.45rem 0.65rem;
  align-items: start;
}

.tm-line-row .tm-field {
  margin-bottom: 0;
}

.tm-line-row .tm-remove {
  margin-top: 1.85rem;
  padding: 0 0.85rem;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .tm-line-row {
    grid-template-columns: 1fr;
  }

  .tm-line-row .tm-remove {
    grid-column: 1 / -1;
    margin-top: 0;
  }
}

.tm-remove {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  min-height: 2.75rem;
  font: inherit;
  cursor: pointer;
}

@media (max-width: 879px) {
  .tm-figure {
    grid-template-columns: 1fr;
  }

  .tm-copy {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .tm-top-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
