/* ============================================================
   Gradebook ledger system — shared across all tool pages.
   Ruled hairlines + tabular numerals, like entries in a grade
   book. Chalkboard green marks actions, highlighter amber
   marks results.
   ============================================================ */

:root {
  --paper: #f6f7f4;
  --card: #ffffff;
  --ink: #1b2430;
  --ink-soft: #5b6472;
  --rule: #d8dcd4;
  --chalk-green: #1f7a5c;
  --chalk-green-ink: #ffffff;
  --highlighter: #e8a33d;
  --highlighter-ink: #1b2430;
  --danger: #b3432b;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14181f;
    --card: #1b212b;
    --ink: #eef1ea;
    --ink-soft: #a3aab5;
    --rule: #2c333f;
    --chalk-green: #3fae86;
    --chalk-green-ink: #0b1210;
    --highlighter: #f0b94f;
    --highlighter-ink: #1b1204;
    --danger: #d9684a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #14181f;
  --card: #1b212b;
  --ink: #eef1ea;
  --ink-soft: #a3aab5;
  --rule: #2c333f;
  --chalk-green: #3fae86;
  --chalk-green-ink: #0b1210;
  --highlighter: #f0b94f;
  --highlighter-ink: #1b1204;
  --danger: #d9684a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

h1, h2, h3 {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
  margin: 0;
}

.mono, .result-value, .big-number, input[type="number"], select {
  font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: var(--chalk-green); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--chalk-green);
  outline-offset: 2px;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding-block: 28px 64px;
}

/* ---------- header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 16px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.15rem;
}
.brand img {
  height: 28px;
  width: 28px;
  object-fit: contain;
  border-radius: 6px;
}
.brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--chalk-green);
  color: var(--chalk-green-ink);
  font-size: 0.85rem;
  font-weight: 700;
}
.site-nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}
.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
}
.site-nav a:hover, .site-nav a.current { color: var(--ink); }

/* ---------- hero / intro ---------- */
.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chalk-green);
  font-weight: 600;
  margin-bottom: 8px;
}
.lede {
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 62ch;
  margin-top: 10px;
}

/* ---------- cards / grid ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}
@media (max-width: 560px) {
  .tool-grid { grid-template-columns: 1fr; }
}
.tool-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  transition: border-color .15s ease, transform .15s ease;
}
.tool-card:hover { border-color: var(--chalk-green); transform: translateY(-1px); }
.tool-card .icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.tool-card h3 { font-size: 1.05rem; }
.tool-card p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }

/* ---------- tool surface (the ledger card) ---------- */
.tool-surface {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
}
@media (max-width: 480px) {
  .tool-surface { padding: 16px; }
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
}
input, select {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus { border-color: var(--chalk-green); }

table.ledger {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}
table.ledger th {
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 0 8px 8px 0;
  border-bottom: 1px solid var(--rule);
}
table.ledger td {
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
table.ledger td input, table.ledger td select { padding: 8px 10px; font-size: 0.95rem; }

.row-remove {
  background: none;
  border: 1px solid var(--rule);
  color: var(--danger);
  border-radius: 6px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.row-remove:hover { border-color: var(--danger); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--chalk-green); color: var(--chalk-green-ink); }
.btn-primary:hover { opacity: 0.92; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn-ghost:hover { border-color: var(--ink-soft); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- result panel ---------- */
.result-panel {
  margin-top: 20px;
  border-top: 2px solid var(--highlighter);
  padding-top: 16px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.result-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.result-value {
  font-size: 2.6rem;
  font-weight: 600;
  color: var(--highlighter-ink);
  background: var(--highlighter);
  padding: 4px 14px;
  border-radius: 8px;
  line-height: 1.2;
}
.result-sub { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- big standalone number (CPS / tally) ---------- */
.big-number {
  font-size: clamp(3.4rem, 18vw, 6rem);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  line-height: 1;
}
.big-stage {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  margin-top: 20px;
}

/* ---------- content sections (SEO copy) ---------- */
.content-section { margin-top: 48px; }
.content-section h2 { font-size: 1.4rem; margin-bottom: 12px; }
.content-section p { color: var(--ink-soft); max-width: 68ch; }
.content-section ol, .content-section ul { color: var(--ink-soft); max-width: 68ch; padding-left: 20px; }
.content-section li { margin-bottom: 6px; }

.faq-item { border-bottom: 1px solid var(--rule); padding-block: 14px; }
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; color: var(--chalk-green); font-size: 1.2rem; }
.faq-item[open] summary::after { content: '−'; }
.faq-item p { color: var(--ink-soft); margin: 10px 0 0; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 56px;
  padding-top: 20px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.site-footer a { color: var(--ink-soft); }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--chalk-green);
  border: 1px solid var(--rule);
}

[hidden] { display: none !important; }

/* ---------- ad slot containment ---------- */
/* Keeps ad units (and any unexpected overlay/native ad formats Google
   injects) from visually overflowing onto surrounding content, and gives
   empty/loading slots a themed background instead of a stark white box. */
.ad-slot {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border-radius: var(--radius);
}
.ad-rail-right { display: none; }
@media (min-width: 1300px) {
  .ad-rail-right {
    display: block;
    position: fixed;
    top: 120px;
    right: 24px;
    width: 160px;
    max-height: 600px;
  }
}

/* ---------- reusable two-card side-by-side layout ---------- */
.two-card-layout {
  display: flex;
  gap: 20px;
  align-items: stretch;
  flex-wrap: wrap;
  margin-top: 24px;
}
.two-card-layout .tool-surface { margin-top: 0; }
.card-main { flex: 1 1 340px; min-width: 0; }
.card-side {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  max-height: 480px;
}
.card-side[hidden] { display: none; }
.card-side h3 { font-size: 1rem; margin-bottom: 12px; }
.side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.side-empty { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }
.rank-chip {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  color: var(--highlighter-ink);
  background: var(--highlighter);
  border-radius: 6px;
  min-width: 2em;
  text-align: center;
  padding: 1px 6px;
  font-size: 0.82rem;
}
