:root {
  color-scheme: light;
  --ink: #241d2f;
  --plum: #33213f;
  --plum-deep: #1f172c;
  --muted: #756b7e;
  --paper: #fffaf0;
  --paper-warm: #f6eddf;
  --line: #ddcdbd;
  --gold: #c8892d;
  --gold-bright: #efbd57;
  --crimson: #b7334e;
  --jade: #167c78;
  --violet: #7050a5;
  --shadow: 0 18px 45px rgba(55, 31, 55, .13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(239, 189, 87, .24), transparent 25rem),
    radial-gradient(circle at 92% 18%, rgba(183, 51, 78, .14), transparent 24rem),
    linear-gradient(135deg, #f6eddf 0%, #fffaf0 42%, #eee3dd 100%);
  color: var(--ink);
  font: 16px/1.55 system-ui, "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .28;
  background-image: repeating-linear-gradient(135deg, rgba(51, 33, 63, .045) 0 1px, transparent 1px 13px);
}

.shell { max-width: 1160px; margin: auto; padding: 28px 24px 72px; }

.preview-banner {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(239, 189, 87, .75);
  border-radius: 7px;
  padding: 10px 17px;
  margin-bottom: 22px;
  background: linear-gradient(105deg, var(--plum-deep), #55233f 62%, #9b6425);
  box-shadow: 0 10px 24px rgba(51, 33, 63, .18);
  color: #fff7dc;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.preview-banner::after {
  position: absolute;
  top: -30px;
  right: 8%;
  width: 150px;
  height: 95px;
  border: 1px solid rgba(255, 240, 181, .35);
  transform: rotate(28deg);
  content: "";
}

header {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(221, 205, 189, .9);
  border-radius: 18px;
  padding: 38px 42px 34px;
  background: rgba(255, 250, 240, .82);
  box-shadow: var(--shadow);
}

header::before, header::after {
  position: absolute;
  width: 115px;
  height: 115px;
  border: 1px solid rgba(183, 51, 78, .22);
  transform: rotate(45deg);
  content: "";
}

header::before { top: -64px; right: 8%; }
header::after { top: -37px; right: 12%; border-color: rgba(200, 137, 45, .34); }

h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 720px;
  margin-bottom: 12px;
  color: var(--plum);
  font-family: Georgia, "Yu Mincho", serif;
  font-size: clamp(2.5rem, 7vw, 5.4rem);
  font-weight: 900;
  letter-spacing: -.055em;
  line-height: .92;
  text-shadow: 2px 3px 0 rgba(200, 137, 45, .18);
}

header p:last-child { max-width: 680px; margin-bottom: 0; color: var(--muted); }
.eyebrow { position: relative; z-index: 1; color: var(--crimson); font-size: .72rem; font-weight: 900; letter-spacing: .2em; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 26px 0 16px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 250, 240, .76);
  box-shadow: 0 8px 22px rgba(55, 31, 55, .08);
}

.toolbar h2 { flex: 1; min-width: 190px; margin: 0; color: var(--plum); font-family: Georgia, "Yu Mincho", serif; font-size: 1.65rem; letter-spacing: .02em; }
.toolbar button {
  border: 1px solid var(--plum);
  border-radius: 7px;
  background: var(--plum);
  color: #fffaf0;
  padding: 8px 13px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.toolbar button:hover { background: #51335f; box-shadow: 0 5px 12px rgba(51, 33, 63, .2); transform: translateY(-1px); }
.toolbar label { color: var(--muted); font-weight: 700; }
.toolbar select { margin-left: 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); padding: 8px 10px; font: inherit; font-weight: 700; }
.toolbar select:hover, .toolbar select:focus { border-color: var(--gold); background: #fffdf8; color: var(--ink); box-shadow: 0 3px 10px rgba(55, 31, 55, .12); }
.count { min-width: 3.5em; color: var(--crimson); font-size: .9rem; font-weight: 900; text-align: right; white-space: nowrap; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 240, .72);
  box-shadow: var(--shadow);
}

.weekday, .day { min-height: 122px; padding: 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.weekday { min-height: auto; border-bottom: 2px solid var(--plum); background: var(--plum); color: #fff5dc; font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-align: center; }
.weekday:nth-child(7) { color: #f2a6af; }
.weekday:nth-child(8n), .day:nth-child(7n + 1) { background: rgba(183, 51, 78, .035); }
.day time { display: inline-grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: var(--muted); font-size: .8rem; font-weight: 800; }
.blank { background: rgba(51, 33, 63, .035); }

.event {
  display: block;
  width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin-top: 7px;
  border: 1px solid rgba(51, 33, 63, .12);
  border-left: 4px solid var(--gold);
  border-radius: 5px;
  padding: 6px 7px;
  background: #fffdf8;
  box-shadow: 0 3px 8px rgba(51, 33, 63, .08);
  color: var(--ink);
  font-size: .77rem;
  font-weight: 700;
  line-height: 1.28;
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.event:hover { box-shadow: 0 7px 14px rgba(51, 33, 63, .16); transform: translateY(-2px); }
.event.character { border-left-color: var(--violet); }
.event.story { border-left-color: var(--jade); }
.event.magazine { border-left-color: var(--crimson); }
.event.sample { border-style: dashed; border-color: var(--gold); background: #fff4d5; color: #704916; }

.partial-dates { grid-column: 1 / -1; padding: 16px; border-top: 2px solid var(--gold); background: rgba(239, 189, 87, .1); }
.partial-dates h3 { color: var(--plum); font-family: Georgia, serif; }
.empty { margin: 20px 4px; color: var(--muted); font-weight: 700; }

dialog { width: min(650px, calc(100% - 28px)); border: 1px solid var(--gold); border-radius: 14px; padding: 30px; background: linear-gradient(145deg, #2b1b38, #442541); box-shadow: 0 25px 80px rgba(31, 23, 44, .38); color: #fffaf0; }
dialog::backdrop { background: rgba(31, 23, 44, .58); backdrop-filter: blur(4px); }
dialog h2 { color: #ffe3a0; font-family: Georgia, "Yu Mincho", serif; font-size: 1.8rem; line-height: 1.15; }
dialog h3 { margin-top: 24px; color: var(--gold-bright); font-size: .95rem; letter-spacing: .08em; }
dialog strong { color: #f3c978; }
.close { float: right; border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%; background: transparent; color: #fffaf0; font-size: 1.35rem; line-height: 1; padding: 4px 10px; cursor: pointer; }
.close:hover { background: rgba(255, 255, 255, .12); }
.sample-note { border-left: 3px solid var(--gold-bright); padding-left: 10px; color: #ffe0a0; font-weight: 800; }
dialog a { color: #ffd77e; }

@media (max-width: 650px) {
  .shell { padding: 14px 10px 42px; }
  header { padding: 28px 22px 25px; border-radius: 13px; }
  h1 { font-size: clamp(2.3rem, 15vw, 4rem); }
  .toolbar { padding: 11px; }
  .toolbar h2 { order: -1; flex-basis: 100%; min-width: 0; text-align: center; }
  .toolbar label { width: 100%; }
  .toolbar select { width: calc(100% - 65px); }
  .count { margin-left: auto; }
  .weekday { padding: 5px 2px; font-size: .68rem; }
  .day { min-height: 92px; padding: 4px; }
  .day time { width: 23px; height: 23px; font-size: .72rem; }
  .event { border-left-width: 3px; padding: 5px 4px; font-size: .67rem; }
}

.view-tabs { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-bottom: 2px; }
.view-tab { border: 1px solid var(--line) !important; background: #fffaf0 !important; color: var(--plum) !important; }
.view-tab.active { border-color: var(--plum) !important; background: var(--plum) !important; color: #fffaf0 !important; box-shadow: 0 4px 10px rgba(51, 33, 63, .2); }
.view-tab:focus-visible, .toolbar button:focus-visible, .toolbar select:focus-visible, .search-panel input:focus-visible, .event-row-button:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.view-controls { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 300px; }
.view-controls h2 { flex: 1; }
.year-list, .search-panel { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: rgba(255, 250, 240, .78); box-shadow: var(--shadow); }
.timeline-list { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: rgba(255, 250, 240, .78); box-shadow: var(--shadow); }
.year-group + .year-group { margin-top: 22px; }
.timeline-group + .timeline-group { margin-top: 26px; }
.year-group h3 { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--gold); color: var(--plum); font-family: Georgia, "Yu Mincho", serif; }
.timeline-group h3 { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--gold); color: var(--plum); font-family: Georgia, "Yu Mincho", serif; scroll-margin-top: 16px; }
.event-row + .event-row { margin-top: 6px; }
.event-row-button { display: grid; grid-template-columns: 180px minmax(0, 1fr) minmax(150px, .8fr); gap: 12px; align-items: center; width: 100%; border: 1px solid rgba(51, 33, 63, .12); border-left: 4px solid var(--gold); border-radius: 6px; padding: 9px 12px; background: #fffdf8; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.event-row-button:hover { background: #fff4d5; }
.event-row-button time { color: var(--crimson); font-weight: 800; white-space: nowrap; }
.event-row-button strong { overflow-wrap: anywhere; }
.event-row-button span { color: var(--muted); font-size: .86rem; }
.search-panel > label { display: block; margin-bottom: 6px; color: var(--plum); font-weight: 800; }
.search-panel input { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 11px 13px; background: #fffdf8; color: var(--ink); font: inherit; }
.search-hint { margin: 12px 0 0; color: var(--muted); font-weight: 700; }
.search-results { margin-top: 14px; }
.today-panel { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: rgba(255, 250, 240, .78); box-shadow: var(--shadow); }
.today-controls { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; }
.today-controls button { border: 1px solid var(--plum); border-radius: 7px; padding: 8px 14px; background: var(--plum); color: #fffaf0; cursor: pointer; font: inherit; font-weight: 700; }
.today-panel h2 { margin-bottom: 4px; color: var(--plum); font-family: Georgia, "Yu Mincho", serif; text-align: center; }
.today-note { margin: 0; color: var(--muted); font-size: .88rem; text-align: center; }
.timeline-controls { display: flex; align-items: center; }
.timeline-controls label { color: var(--muted); font-weight: 700; }
.timeline-controls select { min-width: 150px; }

@media (max-width: 650px) {
  .view-controls { min-width: 0; width: 100%; }
  .view-tabs { order: -2; }
  .event-row-button { grid-template-columns: 1fr; gap: 2px; }
  .event-row-button time { white-space: normal; overflow-wrap: anywhere; }
}

/* Review checkpoint refinements: keep the hero present, but return the calendar
   to the first viewport and make native Windows select/dialog text explicit. */
header { padding: 23px 32px 21px; }
h1 { margin-bottom: 8px; font-size: clamp(2.15rem, 4.5vw, 3.75rem); }
.preview-banner { margin-bottom: 14px; padding-top: 8px; padding-bottom: 8px; }
.toolbar { margin-top: 16px; }
.toolbar select { min-width: 150px; }
.toolbar select option { background: #fffaf0; color: #241d2f; font-weight: 700; }

.metadata-badges { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 18px; padding-right: 38px; }
.metadata-badge { display: inline-flex; align-items: baseline; gap: 6px; border: 1px solid rgba(255, 240, 181, .7); border-radius: 999px; padding: 7px 12px; background: #fff1bf; color: #271a30; font-size: 1rem; font-weight: 850; line-height: 1.2; box-shadow: 0 3px 10px rgba(0, 0, 0, .16); }
.metadata-label { color: #51355b; font-size: .72rem; font-weight: 700; letter-spacing: .04em; }
.metadata-badge.category-badge { background: #eadcff; border-color: #c7a7ec; }
.metadata-badge.date-badge { background: #c9f0e6; border-color: #75c9b5; }
.metadata-badge.confidence-badge { background: #ffe4a0; border-color: #e5ae43; }

@media (max-width: 650px) {
  header { padding: 21px 20px 18px; }
  h1 { font-size: clamp(2rem, 13vw, 3.2rem); }
  .preview-banner { margin-bottom: 12px; }
  .metadata-badges { gap: 6px; padding-right: 0; }
  .metadata-badge { padding: 6px 9px; font-size: .9rem; }
}
