/* Dear Japanese — indigo-dyed paper, hinoki nameplates */
:root {
  --paper: #edf0f2;
  --paper-2: #e1e6ea;
  --surface: #f7f8f9;
  --ink: #1d2633;
  --muted: #586273;
  --line: #c9d1d9;
  --ai: #1d3354;          /* indigo */
  --ai-deep: #13233b;
  --ai-soft: #d8e0eb;
  --on-ai: #e9eef5;
  --wood: #d6b582;
  --wood-hi: #e4c899;
  --wood-dark: #9c7a48;
  --seal: #b23a2b;
  --focus: #2f6fd1;
  --link: #1d3f73;
  --boy: #2c5a8a; --girl: #9a3f62; --uni: #5a6a3a;

  --serif: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --sans: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif;

  --s-1: .8125rem; --s0: 1rem; --s1: 1.25rem; --s2: 1.5625rem; --s3: 1.953rem; --s4: 2.441rem; --s5: 3.052rem;
  --wrap: 72rem;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121a26; --paper-2: #18222f; --surface: #1b2635; --ink: #e5e9ef; --muted: #9aa5b5; --line: #2c3a4d;
    --ai: #1a2d4b; --ai-deep: #0e1828; --ai-soft: #24364f; --on-ai: #dfe6f0;
    --focus: #7fb0ff; --link: #a9c6ee; --boy: #8cb4e0; --girl: #e09ab5; --uni: #b5c48a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121a26; --paper-2: #18222f; --surface: #1b2635; --ink: #e5e9ef; --muted: #9aa5b5; --line: #2c3a4d;
  --ai: #1a2d4b; --ai-deep: #0e1828; --ai-soft: #24364f; --on-ai: #dfe6f0;
  --focus: #7fb0ff; --link: #a9c6ee; --boy: #8cb4e0; --girl: #e09ab5; --uni: #b5c48a; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 var(--s0)/1.65 var(--sans);
  overflow-wrap: anywhere;
}
[lang="ja"] { font-family: var(--serif); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; letter-spacing: .005em; margin: 0 0 .5em; }
h1 { font-size: clamp(var(--s3), 5vw, var(--s5)); font-weight: 800; }
h2 { font-size: var(--s2); }
p { margin: 0 0 1em; }
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---- header: an indigo noren band ---- */
.site-head { background: var(--ai); color: var(--on-ai); border-bottom: 3px solid var(--ai-deep); }
.head-row { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; color: inherit; text-decoration: none; margin-right: auto; }
.brand-name { font-family: var(--serif); font-weight: 800; font-size: 1.45rem; letter-spacing: .01em; }
.brand-jp { font-size: var(--s-1); color: color-mix(in srgb, var(--on-ai) 75%, transparent); letter-spacing: .12em; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--on-ai) !important; text-decoration: none; padding: 6px 10px; border-radius: var(--r); font-size: .9375rem; }
.site-nav a:hover { background: color-mix(in srgb, white 10%, transparent); }
.site-nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--wood); border-radius: 0; }
.nav-toggle { display: none; }
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; background: none; color: inherit; border: 1px solid color-mix(in srgb, var(--on-ai) 40%, transparent); border-radius: var(--r); padding: 6px 12px; font: inherit; }
  .site-nav { display: none; width: 100%; flex-direction: column; padding-bottom: 12px; }
  .site-nav.open { display: flex; }
  .site-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--wood); }
}

/* ---- the nameplate (表札) ---- */
.plate {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; align-self: center; justify-self: start;
  padding: 1.6rem .9rem; min-height: 15rem; border-radius: 3px;
  color: #1f1a14;
  background:
    repeating-linear-gradient(90deg, transparent 0 7px, rgb(120 85 40 / .07) 7px 8px, transparent 8px 19px, rgb(120 85 40 / .05) 19px 20px),
    linear-gradient(180deg, var(--wood-hi), var(--wood) 55%, #cfab74);
  box-shadow: inset 0 0 0 1px rgb(80 55 25 / .35), inset 0 0 0 5px rgb(255 240 210 / .25), 0 10px 18px -8px rgb(0 0 0 / .45);
}
.plate > span { display: flex; flex-direction: column; align-items: center; font-family: var(--serif); font-weight: 800; font-size: 3.4rem; line-height: 1.12; }
.plate i { font-style: normal; display: block; }
.plate .plate-first { margin-top: .45em; }
.plate .plate-last:only-child, .plate .plate-first:only-child { margin: 0; }
.plate > span:empty { display: none; }
.plate.swap > span { animation: ink .5s ease-out both; }
.plate.swap .plate-first { animation-delay: .12s; }
@keyframes ink { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }
@media (prefers-reduced-motion: reduce) { .plate.swap > span { animation: none; } }
.plate-sm { min-height: 0; padding: 1rem .55rem; align-self: start; }
.plate-sm > span { font-size: 2.2rem; }

/* ---- hero ---- */
.hero { padding: 40px 0 8px; }
.hero-grid { display: grid; gap: 32px; align-items: stretch; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.25fr 1fr; gap: 48px; } }
.hero h1 { max-width: 15ch; }
.lede { font-size: var(--s1); color: var(--muted); max-width: 38em; line-height: 1.55; }
.plate-stage {
  margin: 0; background: var(--ai); border-radius: var(--r); padding: 36px 24px 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; min-height: 26rem;
  background-image: repeating-linear-gradient(0deg, transparent 0 46px, rgb(255 255 255 / .035) 46px 47px);
}
.plate-stage .plate { min-height: 18rem; align-self: center; }
.plate-stage figcaption { color: var(--on-ai); text-align: center; display: grid; gap: 2px; }
.plate-stage figcaption strong { font-family: var(--serif); font-size: var(--s1); }
.plate-stage figcaption span { font-size: var(--s-1); color: color-mix(in srgb, var(--on-ai) 75%, transparent); }

/* ---- forms ---- */
input, select, button { font: inherit; color: inherit; }
input[type="search"], input:not([type]), select {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.gen { display: grid; gap: 16px; margin-top: 8px; max-width: 36rem; }
.gen label, .f-sort { display: grid; gap: 4px; font-size: .9375rem; font-weight: 500; }
.gen-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.gen-actions { grid-template-columns: auto 1fr; align-items: end; }
.hint { font-size: var(--s-1); color: var(--muted); margin: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 22px; border-radius: var(--r);
  background: var(--ai); color: var(--on-ai) !important; border: 0; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--ai-deep); }
.btn-quiet { background: transparent; color: var(--ink) !important; border: 1px solid var(--line); font-weight: 500; }
.btn-quiet:hover { background: var(--paper-2); }
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0; }
.seg legend { font-size: .9375rem; font-weight: 500; margin-bottom: 4px; padding: 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; padding: 9px 14px; border: 1px solid var(--line); margin-left: -1px; background: var(--surface); cursor: pointer; font-size: .9375rem; }
.seg label:first-of-type span { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.seg label:last-of-type span { border-radius: 0 var(--r) var(--r) 0; }
.seg input:checked + span { background: var(--ai); color: var(--on-ai); border-color: var(--ai); position: relative; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; position: relative; z-index: 1; }

/* ---- sections ---- */
.block { padding: 48px 16px 0; }
@media (min-width: 720px) { .block { padding: 56px 28px 0; } }
.block-in { padding-top: 56px; }
.dict thead th:nth-child(5):not(:last-child) { text-align: center; }
.sec-title { font-size: var(--s2); margin-bottom: .25em; }
.sec-sub { color: var(--muted); margin-bottom: 1rem; }
.split { display: grid; gap: 40px; }
@media (min-width: 900px) { .split { grid-template-columns: 1fr 1fr; gap: 56px; } }

.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink) !important; background: var(--surface); }
.chips a:hover { border-color: var(--ai); }

.browse { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.browse li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 14px 0; }
.browse a { font-size: var(--s1); font-weight: 500; text-decoration: none; color: var(--ink) !important; display: flex; gap: 14px; align-items: baseline; }
.browse a span { font-size: var(--s0); color: var(--muted); min-width: 3.5em; }
.browse a:hover { text-decoration: underline; }
.browse small { color: var(--muted); }

.convert-teaser { background: var(--paper-2); border-radius: var(--r); padding: 24px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form label { flex: 1 1 14rem; }
.examples { color: var(--muted); margin: 12px 0 0; font-size: .9375rem; }

.tag-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
.tag-grid a { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink) !important; }
.tag-grid a:hover { border-color: var(--ai); }
.tag-grid small { color: var(--muted); }
.tag-grid-lg { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.tag-grid-lg a { display: grid; gap: 4px; padding: 16px; }
.tag-k { font-size: var(--s2); letter-spacing: .1em; }

/* ---- generator results ---- */
.results { padding-top: 40px; }
.gen-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); border-top: 1px solid var(--line); }
.gen-list li { border-bottom: 1px solid var(--line); padding: 12px 8px 12px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; }
.gen-list .pick { all: unset; cursor: pointer; display: grid; gap: 2px; border-radius: 2px; }
.gen-list .pick:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.gen-list .pick[aria-current="true"] .gk { text-decoration: underline; text-decoration-color: var(--wood-dark); text-decoration-thickness: 3px; text-underline-offset: .25em; }
.gk { font-family: var(--serif); font-size: var(--s2); font-weight: 700; letter-spacing: .06em; }
.gr { font-weight: 500; }
.gm { font-size: var(--s-1); color: var(--muted); }
.gl { font-size: var(--s-1); grid-column: 1 / -1; }
.gl a { margin-right: 10px; }

/* ---- list pages ---- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 20px 0 0; margin: 0; font-size: var(--s-1); color: var(--muted); }
.crumbs li + li::before { content: '/'; margin-right: 4px; color: var(--line); }
.crumbs a { color: var(--muted) !important; }
.page-head { padding: 16px 0 24px; }
.sub-links { display: flex; gap: 16px; flex-wrap: wrap; }
.filters { display: grid; gap: 12px; grid-template-columns: 1fr; align-items: end; padding: 16px; background: var(--paper-2); border-radius: var(--r); margin-bottom: 16px; }
@media (min-width: 900px) { .filters { grid-template-columns: minmax(16rem, 1fr) auto 14rem; } }
.f-sort span { font-size: var(--s-1); color: var(--muted); }
.az { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.az button { min-width: 36px; min-height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); cursor: pointer; padding: 0 8px; }
.az button[aria-pressed="true"] { background: var(--ai); color: var(--on-ai); border-color: var(--ai); }
.az button:disabled { opacity: .35; cursor: default; }
.f-count { grid-column: 1 / -1; margin: 0; font-size: var(--s-1); color: var(--muted); }

.table-wrap { overflow-x: auto; }
.dict { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.dict thead th { text-align: left; font-weight: 500; font-size: var(--s-1); color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.dict td, .dict tbody th { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: baseline; }
.dict tbody th { font-weight: 700; }
.dict tbody tr:hover { background: color-mix(in srgb, var(--paper-2) 60%, transparent); }
.dict a { text-decoration: none; color: var(--ink) !important; }
.dict a:hover { text-decoration: underline; }
.c-kanji { font-size: var(--s1); font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.c-kana { color: var(--muted); white-space: nowrap; }
.c-vars { text-align: center !important; font-variant-numeric: tabular-nums; }
.c-mean { color: var(--muted); }
.c-band { white-space: nowrap; }
@media (max-width: 640px) { .c-kana, .c-vars, .dict thead th:nth-child(3), .dict thead th:nth-child(5) { display: none; } .c-mean { font-size: var(--s-1); } }
.g { font-size: var(--s-1); font-weight: 700; }
.g-m { color: var(--boy); } .g-f { color: var(--girl); } .g-u { color: var(--uni); }
.empty, .note { color: var(--muted); padding: 16px 0; }
.note { font-size: var(--s-1); }

/* ---- entry pages ---- */
.entry { max-width: 52rem; padding-bottom: 24px; }
.entry-head { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; padding: 16px 0 28px; }
.entry-head h1 { margin-bottom: .1em; }
.entry-kana { font-size: var(--s2); margin-bottom: .5em; }
.entry-kana rt { font-size: .45em; color: var(--muted); }
.entry-sum { max-width: 36em; }
.entry section { padding-top: 28px; border-top: 1px solid var(--line); margin-top: 28px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.facts div { padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.facts dt { font-size: var(--s-1); color: var(--muted); }
.facts dd { margin: 0; font-size: var(--s1); font-weight: 500; }
.mor { display: inline-flex; gap: 2px; margin-left: 6px; vertical-align: 2px; }
.mor span { font-size: var(--s-1); border: 1px solid var(--line); padding: 0 5px; border-radius: 3px; }
.spellings { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.spellings li { display: grid; grid-template-columns: 6rem 1fr; gap: 16px; align-items: start; }
.sp-word { font-size: var(--s3); font-weight: 800; letter-spacing: .08em; margin: 0; }
.kbreak { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.kbreak li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.kchar { font-size: var(--s1); font-weight: 700; width: 1.6em; }
.kmean { flex: 1 1 12rem; }
.ktags a { font-size: var(--s-1); color: var(--muted) !important; margin-right: 8px; }
@media (max-width: 520px) { .spellings li { grid-template-columns: 1fr; gap: 4px; } .entry-head { grid-template-columns: 1fr; } .entry-head .plate { display: none; } }
.nicks, .pairs, .related { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.nicks li, .pairs li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 14px; font-size: var(--s1); display: grid; }
.nicks small, .pairs small { font-family: var(--sans); font-size: var(--s-1); color: var(--muted); }
.pairs li > a, .pairs li > span { font-weight: 700; letter-spacing: .06em; }
.related a { display: grid; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink) !important; background: var(--surface); }
.related a span { font-size: var(--s1); font-weight: 700; }
.related a:hover { border-color: var(--ai); }
.related-lg { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); margin-bottom: 32px; }
.related small { color: var(--muted); font-size: var(--s-1); }
.kinline { white-space: nowrap; margin-right: 10px; }

/* the save button: a hanko stamp */
.fav { display: inline-flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px 6px 6px; cursor: pointer; min-height: 40px; }
.fav-seal { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--seal); color: var(--seal); border-radius: 4px; font-size: .9rem; font-weight: 800; opacity: .45; }
.fav[aria-pressed="true"] .fav-seal { background: var(--seal); color: #fff4ef; opacity: 1; transform: rotate(-6deg); }
.fav[aria-pressed="true"] .fav-text::after { content: 'd'; }
@media (prefers-reduced-motion: no-preference) { .fav-seal { transition: transform .15s, background .15s; } }
.fav-sm { padding: 4px; border: 0; min-height: 36px; }
.fav-sm .fav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* converter */
.conv-form { max-width: 34rem; }
.conv-out { padding-top: 32px; }
.conv-main { display: grid; gap: 24px; grid-template-columns: auto 1fr; align-items: start; }
@media (max-width: 560px) { .conv-main { grid-template-columns: 1fr; justify-items: start; } }
.conv-out section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.conv-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.idea-word { font-family: var(--serif); font-size: var(--s4); font-weight: 800; letter-spacing: .1em; margin: 0 0 8px; }
.notes { padding-left: 1.2em; max-width: 40em; }
.notes li { margin-bottom: .4em; }

/* favorites */
.fav-group { margin-bottom: 32px; }
.fav-items { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.fav-items li { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.fav-items .gk { font-size: var(--s1); }
.empty-state { padding: 32px; background: var(--paper-2); border-radius: var(--r); }

/* guide */
.prose { max-width: 44rem; padding-bottom: 32px; }
.prose h2 { margin-top: 1.8em; font-size: var(--s2); }
.prose h2 span { color: var(--muted); font-weight: 500; margin-left: .3em; }
.prose p { line-height: 1.75; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 0; border-block: 1px solid var(--line); font-size: .9375rem; }

.nf { text-align: left; padding-top: 56px; padding-bottom: 56px; }
.nf-k { font-size: 5rem; font-weight: 800; line-height: 1; margin-bottom: 16px; color: var(--wood-dark); letter-spacing: .1em; }

/* footer */
.site-foot { margin-top: 72px; background: var(--ai-deep); color: var(--on-ai); padding: 40px 0; }
.site-foot a { color: var(--on-ai) !important; }
.foot-row { display: grid; gap: 24px; }
@media (min-width: 800px) { .foot-row { grid-template-columns: 1.4fr 1fr; } }
.foot-mark { font-family: var(--serif); font-weight: 800; font-size: 1.45rem; margin-bottom: 8px; }
.foot-note { font-size: var(--s-1); color: color-mix(in srgb, var(--on-ai) 72%, transparent); max-width: 40em; }
.foot-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-size: .9375rem; align-content: start; }
