:root {
  --ink: #1d2b26;
  --muted: #5b6b66;
  --green: #214943;
  --sage: #537772;
  --gold: #aca078;
  --line: #d6ddd8;
  --soft: #eef3f1;
  --paper: #ffffff;
  --bg: #f3f5f2;
  --soon: #8a5a12;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Times New Roman", Times, Georgia, serif;
  font-size: 16px;
  line-height: 1.35;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
button:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; border-radius: 4px; }
a { color: var(--green); }

.page {
  height: 100vh;
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Header */
.top { display: flex; align-items: center; gap: 18px; }
.logo { height: 58px; width: auto; }
.titles { flex: 1; }
.titles h1 { margin: 0; font-size: 28px; color: var(--green); font-weight: bold; letter-spacing: 0.3px; }
.titles p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.today-box { text-align: right; color: var(--muted); font-size: 14px; }
.today-box strong { color: var(--ink); font-size: 17px; }

/* Two tiles */
.tiles {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 2fr) 3fr;
  gap: 16px;
}
.tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 6px;
}
.tile-head h2 { margin: 0; font-size: 21px; color: var(--green); }
.tile-head .sub { color: var(--muted); font-size: 14px; }

/* Now list */
.now-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
.now-list li + li { border-top: 1px solid var(--soft); }
.now-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "title meta" "lead meta";
  column-gap: 12px;
  padding: 7px 4px;
  border-radius: 6px;
}
.now-item:hover { background: var(--soft); }
.now-title { grid-area: title; font-size: 16.5px; }
.now-lead { grid-area: lead; color: var(--muted); font-size: 13.5px; }
.now-meta { grid-area: meta; text-align: right; display: flex; flex-direction: column; justify-content: center; }
.now-date { font-size: 14.5px; }
.now-count { font-size: 13.5px; color: var(--muted); }
.now-count.soon { color: var(--soon); font-weight: bold; }
.empty { color: var(--muted); }

/* Month grid */
.months {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.month {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  min-height: 0;
  overflow-y: auto;
}
.month.current { border: 2px solid var(--gold); background: #fbf9f1; }
.month-name { font-weight: bold; color: var(--green); font-size: 15px; margin-bottom: 2px; }
.now-label { font-weight: normal; font-size: 12px; color: #6f6337; border: 1px solid var(--gold); border-radius: 8px; padding: 0 6px; margin-left: 4px; }
.month ul { list-style: none; margin: 0; padding: 0; }
.month-item { font-size: 13.5px; line-height: 1.3; padding: 1px 2px; border-radius: 4px; width: 100%; }
.month-item:hover { background: var(--soft); }
.mday { display: inline-block; min-width: 1.4em; color: var(--muted); }

/* Strips under each tile */
.strip { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; display: flex; gap: 10px; align-items: baseline; }
.strip-label { color: var(--muted); font-size: 14px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--soft);
  color: var(--green);
  border: 1px solid #d9e3df;
  border-radius: 14px;
  padding: 2px 10px;
  font-size: 14px;
}
.chip:hover { border-color: var(--sage); }

/* Marks */
.est { font-style: italic; color: var(--muted); font-size: 0.9em; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--soon); margin-left: 5px; vertical-align: middle; }
.dot.inline { margin: 0 2px 0 6px; }
.tag { display: inline-block; font-size: 12.5px; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; color: var(--muted); }
.tag.confirm { border: 1px dashed var(--soon); color: var(--soon); }
.tag.label-firm { border-color: var(--sage); color: var(--green); }
.tag.label-practice { border-color: var(--gold); color: #6f6337; }

.foot { color: var(--muted); font-size: 13.5px; text-align: center; }

/* Popup */
.overlay[hidden] { display: none; }
.overlay {
  position: fixed; inset: 0;
  background: rgba(20, 35, 31, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 10;
}
.dialog {
  position: relative;
  background: var(--paper);
  border-radius: 12px;
  max-width: 680px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px 26px 22px;
}
.dialog h2 { margin: 0 34px 6px 0; color: var(--green); font-size: 23px; }
.dialog h3 { font-size: 17px; color: var(--green); margin: 14px 0 4px; }
.dialog ol, .dialog ul { margin: 0; padding-left: 22px; }
.dialog li { margin: 3px 0; }
.close { position: absolute; top: 10px; right: 14px; font-size: 28px; line-height: 1; color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0 4px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.rules .source { display: block; color: var(--muted); font-size: 14px; font-style: italic; }
.confirm-note { border: 1px dashed var(--soon); border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; }
.note { background: var(--soft); border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; }

/* Small screens: stack the tiles and let the page scroll */
@media (max-width: 960px) {
  .page { height: auto; }
  .tiles { grid-template-columns: 1fr; }
  .months { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; }
  .now-list, .month { overflow: visible; }
  .titles p { display: none; }
}
@media print {
  .page { height: auto; }
  .now-list, .month { overflow: visible; }
}

/* Date picker: preview the calendar as another day */
.dateview { margin-top: 6px; font-size: 13px; display: flex; gap: 8px;
            align-items: center; justify-content: flex-end; }
.dateview label { color: var(--muted); }
.dateview input { font: inherit; font-size: 13px; padding: 2px 6px;
                  border: 1px solid var(--line); border-radius: 4px;
                  color: var(--ink); background: var(--paper); }
body.previewing .today-box { background: #fbf4e2; border: 1px solid var(--gold);
                             border-radius: 6px; padding: 8px 12px; }
body.previewing #today-label { color: var(--soon); font-weight: bold; }
