/* Paper calendar: ink on paper, one flat color per event (--a1 light / --a2 dark). */
:root {
  --paper: #f3eee4;
  --paper-2: #ebe4d6;
  --ink: #1d1b17;
  --muted: #6f685c;
  --rule: #d6cdbc;
  --display: "Fraunces", "Noto Serif KR", "Noto Serif JP", Georgia, serif;
  --sans: "IBM Plex Sans", "IBM Plex Sans KR", "IBM Plex Sans JP", system-ui, sans-serif;
  /* Plex Mono has no Hangul/Kana: fall back to Plex Sans KR/JP, not the OS monospace font. */
  --mono: "IBM Plex Mono", "IBM Plex Sans KR", "IBM Plex Sans JP", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171512;
    --paper-2: #211e19;
    --ink: #ece5d8;
    --muted: #a0978a;
    --rule: #3a352d;
    color-scheme: dark;
  }
}
/* --accent must resolve on the element that sets --a1/--a2 (body, each calendar row). */
body, .cal li { --accent: var(--a1, #b2382a); }
@media (prefers-color-scheme: dark) {
  body, .cal li { --accent: var(--a2, #e0806f); }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Header: wordmark + language codes */
.top {
  max-width: 880px; margin: 0 auto; padding: 20px 16px 14px;
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--ink);
}
.brand { font: italic 400 24px/1 var(--display); text-decoration: none; letter-spacing: -.01em; }
.langs { display: flex; gap: 14px; font: 500 12px/1 var(--mono); letter-spacing: .08em; }
.langs a { text-decoration: none; color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.langs a:hover { color: var(--ink); }
.langs a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

main { max-width: 880px; margin: 0 auto; padding: 0 16px 48px; }

/* Labels */
.kicker, .crumb, .sec h2, .month h3, .lbl, .cd, .mini, .code, .dates th, .ad, .foot, .textbtn, .note {
  font-family: var(--mono); letter-spacing: .06em;
}
.kicker { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.kicker::before { content: ""; display: inline-block; width: .7em; height: .7em; margin-right: .6em; background: var(--accent); vertical-align: -.05em; }
.crumb { margin: 0 0 22px; font-size: 12px; }
.crumb a { text-decoration: none; color: var(--muted); }
.crumb a:hover { color: var(--ink); text-decoration: underline; }
.code {
  display: inline-block; min-width: 2.6em; padding: 1px 4px; margin-right: 6px; text-align: center;
  font-size: 11px; font-weight: 500; border: 1px solid currentColor; border-radius: 2px;
}

/* Hero */
.hero { padding: 40px 0 28px; }
.hero.small { padding: 40px 0 8px; }
h1 {
  font: 600 clamp(32px, 5.4vw, 54px)/1.05 var(--display);
  font-variation-settings: "opsz" 72; letter-spacing: -.01em;
  margin: 0 0 28px; max-width: 18em; text-wrap: balance;
}
.body { font-size: 17px; max-width: 62ch; margin: 0 0 14px; }
.lead { color: var(--muted); margin-top: -12px; }

/* Clock: one huge day count, small h:m:s beside it */
.clock {
  display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 16px 40px;
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); padding: 20px 0 24px;
}
.clock[hidden] { display: none; }
.num { font-family: var(--display); font-variant-numeric: lining-nums tabular-nums; }
.days { display: flex; flex-direction: column; }
.days .num {
  font-size: clamp(110px, 24vw, 230px); font-weight: 700; line-height: .82;
  font-variation-settings: "opsz" 144; letter-spacing: -.04em;
}
.days .num::after { content: ""; display: block; height: 10px; margin-top: 14px; background: var(--accent); }
.days .lbl { margin-top: 10px; }
.lbl { font-size: 12px; text-transform: uppercase; color: var(--muted); }
.hms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; align-self: end; max-width: 340px; }
.hms .unit { display: flex; flex-direction: column; padding: 0 0 4px 14px; border-left: 1px solid var(--rule); }
.hms .num { font-size: clamp(30px, 5vw, 46px); font-weight: 500; line-height: 1; }
.hms .lbl { margin-top: 8px; }
.arrived { font: 600 clamp(30px, 6vw, 52px)/1.1 var(--display); margin: 8px 0 20px; border-top: 2px solid var(--ink); padding-top: 20px; }

.textbtn {
  font-size: 12px; text-transform: uppercase; color: var(--ink); cursor: pointer;
  background: none; border: 0; padding: 14px 0 0; text-decoration: underline; text-underline-offset: 4px;
}
.textbtn:hover { color: var(--accent); }

/* Sections */
.sec { border-top: 2px solid var(--ink); margin-top: 36px; padding-top: 4px; }
.sec h2 { font-size: 12px; font-weight: 500; text-transform: uppercase; color: var(--muted); margin: 18px 0 12px; }
.note { font-size: 12px; color: var(--muted); }

.dates { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.dates th { text-align: left; font-size: 11px; font-weight: 500; text-transform: uppercase; color: var(--muted); padding: 6px 8px 6px 0; border-bottom: 1px solid var(--ink); }
.dates td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--rule); }
.dates tbody tr:first-child td { font-weight: 600; }
.dates tbody tr:first-child td:first-child { box-shadow: inset 4px 0 0 var(--accent); padding-left: 12px; }
.bycountry a { text-decoration: none; }
.bycountry a:hover { text-decoration: underline; }
.bycountry tbody tr:first-child td:first-child { box-shadow: none; padding-left: 0; }

/* Calendar rows: date · name ········· N days */
.month h3 { font-size: 12px; font-weight: 500; text-transform: uppercase; margin: 32px 0 0; padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
.cal { list-style: none; margin: 0; padding: 0; }
.cal a {
  display: flex; align-items: baseline; gap: 12px; text-decoration: none;
  padding: 12px 0; border-bottom: 1px solid var(--rule);
}
.cd { flex: 0 0 6.5em; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.cn { font: 500 clamp(18px, 2.6vw, 22px)/1.25 var(--display); }
.cn::before { content: ""; display: inline-block; width: .42em; height: .42em; margin-right: .5em; background: var(--accent); vertical-align: .12em; }
.dots { flex: 1; }
.cal .dots { min-width: 16px; border-bottom: 1px dotted var(--muted); transform: translateY(-4px); margin: 0; }
.mini { font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal a:hover .cn { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* Countries */
.countries { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.countries a { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.countries a:hover span:last-child { text-decoration: underline; }

.rootlangs { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; font-family: var(--mono); }

/* Ads: a quiet ruled slot */
.ad { margin: 32px 0; min-height: 90px; }
.ad-placeholder {
  display: grid; place-items: center; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 11px; text-transform: uppercase; color: var(--muted); background: var(--paper-2);
}

.foot {
  max-width: 880px; margin: 0 auto; padding: 16px 16px 40px; display: flex; justify-content: space-between;
  font-size: 11px; text-transform: uppercase; color: var(--muted); border-top: 2px solid var(--ink);
}

/* Ambient mode: just the numbers on paper */
.exit { display: none; }
body.ambient { cursor: none; }
body.ambient.show-ui { cursor: auto; }
body.ambient .top, body.ambient .sec, body.ambient .ad, body.ambient .foot,
body.ambient #ambient-btn, body.ambient .crumb { display: none; }
body.ambient main { max-width: 1200px; }
body.ambient .hero { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
body.ambient .days .num { font-size: clamp(140px, 34vw, 420px); }
body.ambient .hms { max-width: 520px; }
body.ambient .hms .num { font-size: clamp(36px, 7vw, 80px); }
body.ambient .exit { display: block; position: fixed; top: 16px; right: 20px; padding: 0; opacity: 0; transition: opacity .3s; }
body.ambient.show-ui .exit { opacity: 1; }

@media (max-width: 600px) {
  .clock { grid-template-columns: 1fr; }
  .hms { max-width: none; }
  .hms .unit:first-child { border-left: 0; padding-left: 0; }
  .cd { flex-basis: 5.4em; font-size: 12px; }
  .hero { padding-top: 28px; }
}

/* Korean / Japanese: no synthetic italics, no Latin letter-spacing on labels */
:lang(ko) .brand, :lang(ja) .brand { font-style: normal; font-weight: 600; font-size: 20px; }
:lang(ko) .kicker, :lang(ko) .crumb, :lang(ko) .sec h2, :lang(ko) .month h3, :lang(ko) .lbl, :lang(ko) .cd,
:lang(ko) .mini, :lang(ko) .dates th, :lang(ko) .ad, :lang(ko) .foot, :lang(ko) .textbtn, :lang(ko) .note,
:lang(ja) .kicker, :lang(ja) .crumb, :lang(ja) .sec h2, :lang(ja) .month h3, :lang(ja) .lbl, :lang(ja) .cd,
:lang(ja) .mini, :lang(ja) .dates th, :lang(ja) .ad, :lang(ja) .foot, :lang(ja) .textbtn, :lang(ja) .note {
  letter-spacing: 0;
}
:lang(ko) .cd, :lang(ja) .cd { flex-basis: 5.6em; }
:lang(ko) h1, :lang(ja) h1 { letter-spacing: -.02em; line-height: 1.2; word-break: keep-all; }
:lang(ko) .body, :lang(ko) .cn { word-break: keep-all; }
.themelink { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.themelink:hover { color: var(--ink); }

/* Header link to "My dates" */
.mylink { margin-left: auto; font: 500 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; text-decoration: none; color: var(--ink); }
.mylink:hover { color: var(--accent); }
:lang(ko) .mylink, :lang(ja) .mylink { letter-spacing: 0; }

/* My dates page */
.myroot [hidden] { display: none !important; }
.myform {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end;
  border-top: 2px solid var(--ink); padding: 18px 0 22px; margin-top: 8px;
}
.myform label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.myform input, .mylinkbox {
  font: 16px/1.2 var(--sans); color: var(--ink); background: transparent;
  border: 1px solid var(--ink); border-radius: 0; padding: 10px 12px; width: 100%; min-width: 0;
}
.myform input:focus, .mylinkbox:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-ink {
  font: 500 13px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink); padding: 12px 18px; height: 42px;
}
.btn-ink:hover { background: var(--accent); border-color: var(--accent); }
.myroot .cd { flex-basis: 10.5em; }
#my-list li { display: flex; align-items: baseline; }
#my-list li a { flex: 1; min-width: 0; }
#my-list .cn { overflow-wrap: anywhere; }
.del { padding: 0 0 0 14px; text-decoration: none; color: var(--muted); font-size: 14px; }
.del:hover { color: var(--accent); }
.since { margin: -16px 0 12px; }
.myactions { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.mylinkbox { margin-top: 14px; font-family: var(--mono); font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); margin: 0; z-index: 10;
  font: 500 13px/1 var(--mono); background: var(--ink); color: var(--paper); padding: 12px 18px;
}
body.ambient .myactions, body.ambient .mylinkbox, body.ambient .toast { display: none !important; }
@media (max-width: 600px) {
  .myform { grid-template-columns: 1fr 1fr; }
  .myform .f-name { grid-column: 1 / -1; }
  .btn-ink { grid-column: 1 / -1; }
  .myroot .cd { flex-basis: 7.5em; font-size: 11px; }
  .mylink { margin-left: 0; order: 3; }
}
