:root {
  --bg:     #fbfaf6;
  --ink:    #1c1c1c;
  --muted:  #6e6e6e;
  --line:   #e6e1d6;
  --card:   #ffffff;
  --accent: #f7931a;

  --past:   #cfc8b8;
  --future: #f5e6cc;
  --work:   #bdd4ee;
  --lost:   #e8c0c0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

header {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 12px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

header .bsym {
  color: var(--accent);
}

header .tagline {
  color: var(--muted);
  margin-top: 4px;
}

/* Header switches row */
.hero-switches {
  display: inline-flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}

/* Tab navigation */
.mode-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

/* Language picker (dropdown) */
.lang-picker {
  position: relative;
  display: inline-block;
}

.lang-trigger {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}

.lang-trigger:hover { color: var(--ink); }

.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  z-index: 200;
  min-width: 100px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  flex-direction: column;
}

.lang-picker.open .lang-dropdown { display: flex; }

.lang-dropdown button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: none;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--muted);
  text-align: left;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.lang-dropdown button:hover { background: var(--bg); color: var(--ink); }
.lang-dropdown button.active { color: var(--ink); }

.lang-auto {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--line);
  border-radius: 3px;
  padding: 1px 4px;
  opacity: 0.8;
}

.mode-switch a {
  display: block;
  font: inherit;
  font-size: 13px;
  padding: 5px 16px;
  text-decoration: none;
  color: var(--muted);
  background: transparent;
}

.mode-switch a.active {
  background: var(--ink);
  color: #fff;
}

.mode-switch a:hover:not(.active) {
  color: var(--ink);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 48px;
  color: var(--muted);
  font-size: 13px;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-head h2 { margin-bottom: 0; }

.hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* Inputs */
.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.input-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.field-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 2px;
}

.field-hint a { color: var(--accent); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }

.btc-inline { color: var(--accent); font-weight: 600; }

input[type="number"],
input[type="text"] {
  font: inherit;
  font-size: 15px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  width: 100px;
}

input[type="text"] { width: auto; }

input[type="number"]:focus,
input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.summary-line {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

/* View toggle */
.toggle-group {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  font: inherit;
  font-size: 13px;
  padding: 5px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.toggle-btn.active {
  background: var(--ink);
  color: #fff;
}

/* Work years toggle */
.work-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 16px;
  color: var(--ink);
}

.work-toggle input { width: auto; cursor: pointer; }

/* Life grid */
.life-grid {
  margin-bottom: 16px;
  line-height: 0;
}

.life-grid.years {
  display: grid;
  grid-template-columns: repeat(auto-fill, 14px);
  gap: 3px;
}

.life-grid.weeks {
  display: grid;
  grid-template-columns: repeat(52, 1fr);
  gap: 1px;
}

.cell {
  background: var(--future);
  border-radius: 2px;
}

.life-grid.years .cell  { width: 14px; height: 14px; }
.life-grid.weeks .cell  { aspect-ratio: 1; border-radius: 1px; }

.cell.past   { background: var(--past); }
.cell.work   { background: var(--work); }
.cell.lost   { background: var(--lost); }
/* .cell (default = future) stays as var(--future) */

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  align-items: center;
}

.legend .leg {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
}

.leg.past   { background: var(--past); }
.leg.future { background: var(--future); border: 1px solid var(--line); }
.leg.work   { background: var(--work); }
.leg.lost   { background: var(--lost); }

/* Modifiers */
.modifier-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modifier-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}

.modifier-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.modifier-item label { flex: 1; cursor: pointer; }

.mod-years {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

.mod-years input[type="number"] { width: 56px; font-size: 13px; }

/* Person list */
.person-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.person-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.person-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.person-name {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  border: none;
  background: transparent;
  padding: 0;
  min-width: 0;
}

.person-name:focus { outline: none; border-bottom: 2px solid var(--accent); }

.btn-remove {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-remove:hover { border-color: #e55; color: #e55; }

.person-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.person-inputs label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.person-inputs input[type="number"] {
  width: 76px;
  font-size: 14px;
  padding: 4px 8px;
}

.person-summary {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--muted);
}

.person-summary .days-big {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
}

/* Loved ones grid — fixed 12 columns so all cards wrap at the same point */
.person-dot-grid {
  display: grid;
  grid-template-columns: repeat(12, 14px);
  gap: 3px;
  margin-top: 8px;
}

.person-dot-grid .cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
}

/* Quote */
.quote {
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  cursor: pointer;
}

.quote .who {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 13px;
  color: var(--accent);
}

/* Footer credit */
.footer-credit {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.footer-credit a { color: var(--muted); }

/* Buttons */
.btn {
  font: inherit;
  font-size: 14px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  color: var(--ink);
}

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

/* Utils */
.hidden { display: none !important; }

/* Mobile */
@media (max-width: 600px) {
  header { padding: 28px 16px 8px; }
  header h1 { font-size: 1.5rem; }
  main { padding: 12px 16px 40px; }
  .card { padding: 16px; }

  .life-grid.years {
    grid-template-columns: repeat(auto-fill, 12px);
    gap: 2px;
  }

  .life-grid.years .cell { width: 12px; height: 12px; }

  .life-grid.weeks {
    grid-template-columns: repeat(52, 1fr);
  }

  .life-grid.weeks .cell { aspect-ratio: 1; }

  .person-list { grid-template-columns: 1fr; }
}
