:root {
  --bg: #f6f2ea;
  --card: #fffdf9;
  --ink: #2b2520;
  --muted: #8a7f72;
  --line: #e6ddcd;
  --accent: #8c2f1f;      /* dharma maroon */
  --accent-soft: #f3e3dc;
  --gold: #c08a2d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 37, 32, .06), 0 8px 24px rgba(43, 37, 32, .07);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) 1.25rem 2rem;
}

.head { text-align: center; margin-bottom: 1.75rem; }

h1 {
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0 0 .4rem;
}

.tagline {
  color: var(--muted);
  margin: 0 auto 1.4rem;
  max-width: 34rem;
}

/* tradition segmented control */
.tradition {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px;
  margin: 0;
  gap: 2px;
}
.tradition .seg { position: relative; }
.tradition input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.tradition span {
  display: block;
  padding: .4rem 1.1rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.tradition input:checked + span {
  background: var(--accent);
  color: #fff;
}
.tradition input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* cards */
.cards {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--line);
}

.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span { font-size: .85rem; font-weight: 500; color: var(--muted); }
.field small { font-weight: 400; }
.field-row { display: flex; gap: .8rem; }
.field-row .field { flex: 1; }

input[type="date"],
input[type="number"],
select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: .55rem .65rem;
  appearance: none;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checks { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.check {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .9rem;
  color: var(--ink);
  cursor: pointer;
}
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }

button[type="submit"] {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  padding: .65rem 1rem;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
button[type="submit"]:hover { filter: brightness(1.08); }
button[type="submit"]:active { transform: translateY(1px); }

/* results */
.result {
  position: relative;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  padding-bottom: 1.6rem;
  margin-top: .2rem;
}
.result.error .note { color: var(--accent); }

.result-clear {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: .2rem;
  line-height: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
}
.result-clear:hover { color: var(--accent); }

.result .big {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: .6rem;
  color: var(--accent);
}

.result dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  gap: .4rem 1.2rem;
}
.result dl > div { display: contents; }
.result dt { white-space: nowrap; color: var(--muted); font-size: .9rem; }
.result dd { margin: 0; font-weight: 500; }
.result .muted { color: var(--muted); font-weight: 400; }

.tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .05rem .4rem;
  border-radius: 5px;
  vertical-align: middle;
}

.note { font-size: .9rem; color: var(--muted); margin: .6rem 0 0; }

/* multiple matches for an ambiguous Tibetan date */
.multi { display: flex; flex-direction: column; gap: .6rem; }
.multi-row { display: flex; flex-direction: column; gap: .1rem; }
.choice-label { font-size: .85rem; color: var(--muted); }
.choice-date { font-weight: 600; color: var(--accent); }

.foot {
  margin-top: 2.5rem;
  font-size: .85rem;
  color: var(--muted);
}
.foot a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.foot a:hover { border-bottom-color: var(--accent); }

/* GitHub link: keep the mark and label together, no underline under the icon */
.foot a.gh-link { white-space: nowrap; border-bottom: none; }
.foot a.gh-link:hover { text-decoration: underline; }
.gh-icon { vertical-align: -.15em; margin-right: .3em; }
