:root {
  --bg: #f6f4ef;
  --ink: #1c1c1c;
  --muted: #8a8780;
  --past: #1c1c1c;
  --remaining-border: #1c1c1c;
  --warning: #a14a1a;
  --box: 20px;
  --gap: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 40px;
  height: 100vh;
  padding: 32px 40px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: auto;
  min-height: 0;
}

header h1 {
  font-size: 1.9rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
}

form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

form input,
form select {
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  padding: 4px 0;
  outline: none;
  text-transform: none;
  letter-spacing: 0;
}

form input:focus,
form select:focus {
  border-bottom-width: 2px;
  padding-bottom: 3px;
}

form select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%231c1c1c' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 4px center;
}

form label.slider {
  gap: 8px;
}

form label.slider span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.05rem;
  color: var(--ink);
}

form label.slider output {
  font-weight: 600;
}

form input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  accent-color: var(--ink);
}

form input[type="range"]:focus {
  border: none;
  padding: 0;
}

[data-tpl] { display: none; }
.template-family [data-tpl="family"],
.template-spouse [data-tpl="spouse"],
.template-friend [data-tpl="friend"],
.template-other  [data-tpl="other"] { display: inline; }

.template-family .field-met,
.template-family .field-pastFreq { display: none; }

.template-spouse .field-pastFreq,
.template-spouse .field-transition { display: none; }

.template-friend .field-transition { display: none; }

.output {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

.readout .huge {
  font-size: 4.5rem;
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1;
  font-weight: 500;
}

.readout .huge-sub {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 1rem;
}

.readout .medium {
  margin: 0;
  font-size: 1.2rem;
}

.readout .small {
  margin: 2px 0 0;
  color: var(--muted);
}

.warning {
  margin: 8px 0 0;
  color: var(--warning);
  font-size: 0.9rem;
}

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--box));
  grid-auto-rows: var(--box);
  gap: var(--gap);
  align-content: start;
  justify-content: start;
  overflow: hidden;
  min-height: 0;
}

.box {
  width: var(--box);
  height: var(--box);
  border: 1px solid var(--remaining-border);
  border-radius: 1px;
}

.box.past {
  background: var(--past);
}

.box.remaining {
  background: transparent;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
    padding: 24px;
  }

  .controls {
    overflow: visible;
  }

  .grid {
    overflow: visible;
  }

  .readout .huge {
    font-size: 3.5rem;
  }
}
