/* Date Difference Calculator — one page, one answer.
 *
 * The layout has one job: make the headline number impossible to miss and the
 * supporting numbers clearly secondary. Everything is system fonts and CSS
 * variables, no build step and no web fonts, matching the other small internal
 * tools on this fleet. Dark mode follows the OS rather than adding a toggle
 * nobody asked for. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --ink-soft: #5b6572;
  --line: #dfe3e8;
  --accent: #1f6feb;
  --accent-soft: #eaf1fd;
  --danger: #a4232b;
  --danger-soft: #fdecec;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1c2027;
    --ink: #e7eaee;
    --ink-soft: #9aa5b3;
    --line: #2c323b;
    --accent: #5b9cff;
    --accent-soft: #1d2a40;
    --danger: #ff9b9b;
    --danger-soft: #3a2022;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 3rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.page { max-width: 47rem; margin: 0 auto; }

.masthead h1 { margin: 0 0 .25rem; font-size: 1.6rem; letter-spacing: -.01em; }
.lede { margin: 0 0 1.5rem; color: var(--ink-soft); }

/* -- the form ------------------------------------------------------------ */

.pick {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.fields {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
}

.field { flex: 1 1 0; display: block; min-width: 0; }

.field-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  margin-bottom: .35rem;
}

input[type="date"] {
  width: 100%;
  padding: .6rem .7rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input[type="date"]:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.swap {
  flex: 0 0 auto;
  margin-bottom: .1rem;
  padding: .55rem .7rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.swap:hover { color: var(--accent); border-color: var(--accent); }

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  margin-top: 1rem;
}

.primary {
  padding: .55rem 1.4rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary:hover { filter: brightness(1.08); }

.shortcuts { display: flex; gap: .9rem; }

.link {
  padding: 0;
  font: inherit;
  font-size: .9rem;
  color: var(--accent);
  background: none;
  border: 0;
  border-bottom: 1px dotted currentColor;
  cursor: pointer;
}

.hint { flex: 1 1 14rem; font-size: .82rem; color: var(--ink-soft); }

/* -- the answer ---------------------------------------------------------- */

.error {
  margin: 1.25rem 0 0;
  padding: .8rem 1rem;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid currentColor;
  border-radius: var(--radius);
}

.result { margin-top: 1.5rem; }

.result-headline {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
}

.note {
  margin: -.5rem 0 1rem;
  font-size: .9rem;
  color: var(--ink-soft);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  padding: .9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tile-primary {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tile-value {
  display: block;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.tile-value small { font-size: .95rem; font-weight: 600; color: var(--ink-soft); }

.tile-label {
  display: block;
  margin-top: .15rem;
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

.tile-detail {
  display: block;
  margin-top: .35rem;
  font-size: .82rem;
  color: var(--ink-soft);
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .5rem 1.5rem;
  margin: 1.25rem 0 0;
}

.fact dt { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.fact dd { margin: 0; }

.actions-row { margin: 1rem 0 0; }

/* -- the tail ------------------------------------------------------------ */

.explainer {
  margin-top: 2rem;
  padding: .9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: .9rem;
}

.explainer summary { cursor: pointer; font-weight: 600; }
.explainer p { color: var(--ink-soft); }
.explainer p:last-child { margin-bottom: 0; }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.25rem;
  margin-top: 1.5rem;
  font-size: .8rem;
  color: var(--ink-soft);
}

.foot a { color: inherit; }
.foot code { font-size: .95em; }

@media (max-width: 34rem) {
  .fields { flex-wrap: wrap; }
  .field { flex-basis: 100%; }
  .swap { order: 3; margin: 0; }
}
