/* Layout: a tool page. Form steps at the start side, the result at the end side; the result's
   signature element is a wall-calendar leaf (takvim yaprağı) showing the last day. */
:root {
  --paper: #f2f4f7;
  --surface: #ffffff;
  --ink: #17202c;
  --muted: #5b6676;
  --line: #dce1e8;
  --court: #1e3a5c;
  --court-ink: #ffffff;
  --court-soft: #e6ecf4;
  --red: #b42318;
  --red-soft: #fbeae8;
  --notice: #fdf5e3;
  --notice-line: #ead7a8;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-figure: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-code: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e131a; --surface: #151c26; --ink: #e7ebf1; --muted: #9aa6b6; --line: #263040;
    --court: #a8c1e6; --court-ink: #0e1724; --court-soft: #1c2837; --red: #ff8a7f; --red-soft: #3a1f1d;
    --notice: #2a2414; --notice-line: #5c4c22;
    color-scheme: dark;
  }
}

/* Scripts the Latin faces do not cover use the platform's own fonts. Barlow Condensed has no
   Cyrillic, so Russian headings use one condensed face throughout instead of mixing two. */
:root:lang(ru) { --font-figure: "Arial Narrow", "Roboto Condensed", "IBM Plex Sans", sans-serif; }
:root:lang(ar) {
  --font-ui: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
  --font-figure: "Barlow Condensed", "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", sans-serif;
}
:root:lang(zh) {
  --font-ui: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-figure: "Barlow Condensed", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
:root:lang(ja) {
  --font-ui: "IBM Plex Sans", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif;
  --font-figure: "Barlow Condensed", "Hiragino Sans", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif;
}
/* Letter-spacing breaks the joins of Arabic script. */
:root:lang(ar) * { letter-spacing: normal; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--font-ui); }
a { color: var(--court); text-underline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); z-index: 10; }
.skip:focus { inset-inline-start: 16px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--court) 50%, transparent); outline-offset: 2px; }

/* header */
.bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.12rem; }
.brand__mark { width: 30px; height: 30px; }
.m-sheet { fill: var(--surface); stroke: var(--court); stroke-width: 2; }
.m-band { fill: var(--court); }
.m-ring { fill: var(--court); stroke: var(--surface); stroke-width: 1; }
.m-day { fill: var(--red); font: 700 15px Georgia, "Times New Roman", serif; text-anchor: middle; }
.bar__nav { display: flex; align-items: center; gap: 18px; font-size: 0.95rem; }
.bar__nav a { color: var(--muted); text-decoration: none; }
.bar__nav a:hover { color: var(--ink); }
.lang select { font: inherit; font-size: 0.9rem; color: var(--ink); background-color: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding-block: 5px; padding-inline: 8px 28px; }
@media (max-width: 560px) { .bar__nav a:not(:last-of-type) { display: none; } }

/* intro */
.intro { padding-block: 34px 18px; max-width: 760px; display: grid; gap: 10px; }
.intro h1 { margin: 0; font: 700 clamp(2.2rem, 5vw, 3.3rem)/1.02 var(--font-figure); letter-spacing: 0.005em; text-wrap: balance; }
.intro p { margin: 0; color: var(--muted); font-size: 1.06rem; max-width: 64ch; }

.modes { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 18px; }
.modes button { border: 0; background: transparent; color: var(--muted); font: 600 0.95rem var(--font-ui); padding: 8px 16px; border-radius: 999px; cursor: pointer; }
.modes button[aria-selected="true"] { background: var(--court); color: var(--court-ink); }

/* tool layout */
.tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .tool { grid-template-columns: minmax(0, 1fr); } }

.form { display: grid; gap: 12px; }
.step { margin: 0; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); display: grid; gap: 12px; min-width: 0; }
.step legend { display: flex; align-items: center; gap: 10px; float: inline-start; width: 100%; font-weight: 650; font-size: 1.02rem; padding: 0; }
.step legend + * { clear: both; }
.step__n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--court-soft); color: var(--court); font: 600 0.8rem var(--font-code); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 500 0.92rem var(--font-ui); padding: 7px 12px; border-radius: 999px; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--court); border-color: var(--court); color: var(--court-ink); }
.seg--small button { font-size: 0.86rem; padding: 6px 11px; }

.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.pack { text-align: start; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; font: inherit; color: var(--ink); }
.pack strong { font-weight: 650; }
.pack span { color: var(--muted); font-size: 0.84rem; line-height: 1.35; }
.pack[aria-checked="true"] { border-color: var(--court); box-shadow: inset 0 0 0 1px var(--court); background: var(--court-soft); }

.date-row { display: flex; gap: 8px; flex-wrap: wrap; }
input[type="date"], input[type="number"], select {
  font: 500 1rem var(--font-ui); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 11px; min-width: 0;
}
/* WebKit sizes a native select by its longest option (long calendar names pushed phone layouts
   sideways), so selects draw their own arrow and cut long text with an ellipsis. */
select {
  -webkit-appearance: none; appearance: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-inline-end: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
[dir="rtl"] select { background-position: 12px 55%, 17px 55%; }
input[type="date"] { flex: 1 1 180px; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--court); font: 600 0.92rem var(--font-ui); border-radius: var(--r-md); padding: 8px 14px; cursor: pointer; }
.field { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.field select { width: 100%; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset { border: 1px dashed var(--line); background: transparent; color: var(--ink); border-radius: var(--r-md); padding: 7px 10px; cursor: pointer; font: inherit; font-size: 0.9rem; display: grid; text-align: start; line-height: 1.25; }
.preset small { color: var(--muted); font-size: 0.76rem; }
.preset[aria-checked="true"] { border-style: solid; border-color: var(--court); background: var(--court-soft); }
.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period input { width: 96px; }
.period select { flex: 1 1 140px; }
.unit-text { color: var(--muted); font-size: 0.92rem; }

.opts { display: grid; gap: 14px; }
.opt { display: grid; gap: 6px; }
.opt__q { font-weight: 600; font-size: 0.95rem; }
.opt__choices { display: grid; gap: 6px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 11px; cursor: pointer; font-size: 0.92rem; }
.choice input { margin-top: 3px; accent-color: var(--court); }
.choice:has(input:checked) { border-color: var(--court); background: var(--court-soft); }
.opt__hint { color: var(--muted); font-size: 0.82rem; line-height: 1.45; margin: 0; }
.adv { border-top: 1px solid var(--line); padding-top: 10px; }
.adv summary { cursor: pointer; font-weight: 600; color: var(--court); }
.adv__hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 0.92rem; }

/* result */
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: grid; gap: 16px; min-width: 0; position: sticky; top: 16px; }
@media (max-width: 900px) { .result { position: static; } }
.verdict { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.leaf { width: 128px; flex: 0 0 auto; border-radius: 12px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 2px 0 var(--line), 0 10px 24px color-mix(in srgb, var(--ink) 10%, transparent); text-align: center; position: relative; }
.leaf::before { content: ""; position: absolute; left: 0; right: 0; top: 30px; border-top: 2px dotted color-mix(in srgb, var(--court-ink) 55%, transparent); }
.leaf__month { background: var(--court); color: var(--court-ink); font: 700 0.95rem/1 var(--font-figure); letter-spacing: 0.06em; padding: 9px 6px 12px; }
.leaf__day { font: 700 4.6rem/1 var(--font-figure); color: var(--red); padding-top: 8px; font-variant-numeric: tabular-nums; }
.leaf__weekday { font: 600 1rem/1 var(--font-figure); color: var(--ink); padding: 4px 6px 12px; letter-spacing: 0.02em; }
.verdict__text { display: grid; gap: 2px; min-width: 0; }
.verdict__label { margin: 0; color: var(--muted); font-size: 0.9rem; }
.verdict__date { margin: 0; font: 700 clamp(1.6rem, 3vw, 2.05rem)/1.12 var(--font-figure); letter-spacing: 0.005em; }
.verdict__time { margin: 0; color: var(--muted); font-size: 0.95rem; }
.countdown { margin: 4px 0 0; font-weight: 600; font-size: 0.95rem; }
.countdown.past { color: var(--red); }

.changes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.changes:empty { display: none; }
.changes li { font-size: 0.84rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--court-soft); color: var(--court); }

.months { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.month h3 { margin: 0 0 6px; font: 600 1.05rem var(--font-figure); letter-spacing: 0.02em; }
.month table { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.month th { color: var(--muted); font-weight: 500; font-size: 0.72rem; padding-bottom: 2px; }
.month td { text-align: center; height: 30px; border-radius: 7px; position: relative; }
.month td.out { visibility: hidden; }
.month td.we { color: var(--muted); }
.month td.recess { background: var(--court-soft); }
.month td.hol { color: var(--red); font-weight: 600; }
.month td.hol::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--red); }
.month td.half::after { background: transparent; border: 1px solid var(--red); width: 5px; height: 5px; margin-left: -3px; }
.month td.start { box-shadow: inset 0 0 0 1.5px var(--muted); }
.month td.counted { box-shadow: inset 0 0 0 1.5px var(--court); outline: 1.5px dashed var(--court); outline-offset: -1.5px; }
.month td.final { background: var(--red); color: var(--surface); font-weight: 700; }
.month td.final::after { display: none; }
.legend { list-style: none; margin: -4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 0.8rem; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.legend .k-final { background: var(--red); }
.legend .k-counted { outline: 1.5px dashed var(--court); outline-offset: -1.5px; }
.legend .k-recess { background: var(--court-soft); }
.legend .k-hol { position: relative; }
.legend .k-hol::after { content: ""; position: absolute; left: 5px; top: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--red); }
.legend .k-start { box-shadow: inset 0 0 0 1.5px var(--muted); }

.why { margin: 4px 0 -6px; font-size: 1.02rem; font-weight: 650; }
.trace { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 8px; }
.trace li { counter-increment: step; position: relative; padding-block: 9px; padding-inline: 42px 12px; border-inline-start: 2px solid var(--line); font-size: 0.93rem; }
.trace li::before { content: counter(step); position: absolute; inset-inline-start: 10px; top: 9px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); font: 600 0.75rem var(--font-code); color: var(--muted); background: var(--surface); }
.trace li.changed { border-inline-start-color: var(--court); }
.trace li.changed::before { background: var(--court); color: var(--court-ink); border-color: var(--court); }
.cite { display: inline-block; margin-top: 3px; font-size: 0.82rem; font-weight: 600; color: var(--court); }
.notices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notices:empty { display: none; }
.notices li { background: var(--notice); border: 1px solid var(--notice-line); border-radius: var(--r-md); padding: 10px 12px; font-size: 0.9rem; }
.error { color: var(--red); font-weight: 600; margin: 0; }

.actions { position: relative; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--court); background: var(--court); color: var(--court-ink); font: 600 0.92rem var(--font-ui); border-radius: var(--r-md); padding: 9px 14px; cursor: pointer; }
.btn--ghost { background: transparent; color: var(--court); }
.toast { color: var(--muted); font-size: 0.88rem; }
.addcal > summary { display: inline-flex; align-items: center; gap: 7px; list-style: none; }
.addcal > summary::-webkit-details-marker { display: none; }
.addcal__menu { position: absolute; z-index: 5; inset-inline: 0; top: calc(100% + 6px); max-width: 360px; display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 8px 24px rgb(0 0 0 / 0.14); }
.addcal__menu button, .addcal__menu a { display: block; text-align: start; padding: 9px 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font: 600 0.92rem var(--font-ui); text-decoration: none; cursor: pointer; }
.addcal__menu button:hover, .addcal__menu a:hover { background: var(--court-soft); }
.addcal__note { margin: 4px 10px 6px; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.code summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; font-weight: 500; }
pre { margin: 8px 0 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; font: 0.84rem/1.6 var(--font-code); }

/* business days */
.holidays { list-style: none; margin: 0; padding: 0; display: grid; font-size: 0.92rem; }
.holidays li { display: flex; gap: 12px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.holidays li:last-child { border-bottom: 0; }
.holidays time { min-width: 7.2em; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { font-size: 0.74rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }

/* developers */
.dev { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 28px; align-items: start; padding-block: 44px 10px; border-top: 1px solid var(--line); margin-top: 40px; }
@media (max-width: 900px) { .dev { grid-template-columns: minmax(0, 1fr); } }
.dev h2 { margin: 0 0 8px; font: 700 1.9rem/1.1 var(--font-figure); }
.dev p { margin: 0 0 10px; color: var(--muted); max-width: 60ch; }
.codetabs { display: flex; gap: 4px; }
.codetabs button { border: 1px solid var(--line); border-bottom: 0; background: var(--paper); color: var(--muted); font: 600 0.86rem var(--font-ui); padding: 6px 12px; border-radius: var(--r-sm) var(--r-sm) 0 0; cursor: pointer; }
.codetabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); }
.snippet { margin: 0; background: var(--surface); border-start-start-radius: 0; }

.foot { color: var(--muted); font-size: 0.86rem; padding-block: 28px 44px; }
.foot__row { display: grid; gap: 4px; }
.foot p { margin: 0; max-width: 80ch; }
