/* 版式照 Jisho：大搜索框 → 原文词块条 → 左边词条、右边侧栏。黑白灰为主，强调色藍色 #165E83 */
:root {
  --bg: #fff;
  --fg: #222;
  --muted: #999;
  --soft: #666;
  --line: #e5e5e5;
  --box: #ddd;
  --hover: #f2f2f2;
  --accent: #165e83;
  --link: #165e83;
  --label: #909dc0;
  --label-soft: #b5b5b5;
  --footer: #f7f7f7;
  --field: #fff;
  --known: #c4c4c4;
  --logo: #5a5a5a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --logo: #cfcfcf;
    --bg: #1c1d1f;
    --fg: #dedede;
    --muted: #8a8a8a;
    --soft: #aaa;
    --line: #333;
    --box: #3a3b3e;
    --hover: #2a2b2e;
    --accent: #4a9ccc;
    --link: #7fb8dc;
    --label: #5d6789;
    --label-soft: #555;
    --footer: #232427;
    --field: #232427;
    --known: #555;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --logo: #cfcfcf;
  --bg: #1c1d1f;
  --fg: #dedede;
  --muted: #8a8a8a;
  --soft: #aaa;
  --line: #333;
  --box: #3a3b3e;
  --hover: #2a2b2e;
  --accent: #4a9ccc;
  --link: #7fb8dc;
  --label: #5d6789;
  --label-soft: #555;
  --footer: #232427;
  --field: #232427;
  --known: #555;
}

* { box-sizing: border-box; }
/* 字号三档：整页按比例缩放（大 = 原来的尺寸） */
html { -webkit-text-size-adjust: 100%; font-size: 14px; }
html[data-size="s"] { font-size: 12.5px; }
html[data-size="l"] { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
[lang="ja"] {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.row { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- 顶部 ---------- */
.site-header { display: flex; align-items: flex-start; justify-content: space-between; padding-top: 14px; padding-bottom: 6px; }
.logo { margin: 0; font-size: 4rem; line-height: 1; font-weight: 800; letter-spacing: -.02em; }
.logo a { position: relative; display: inline-block; color: var(--logo); text-decoration: none; padding-top: 22px; }
.logo .seal { position: absolute; left: 4px; top: 2px; width: 16px; height: 16px; border-radius: 3px; background: var(--accent); }
.nav { display: flex; gap: 28px; padding-top: 8px; }
.nav a, .nav-btn { color: var(--link); font-size: 1.25rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.nav-btn { border: 0; padding: 0; background: none; font-family: inherit; }

/* ---------- 搜索区：左边输入方式图标 + 粗灰边单行搜索框（照 Jisho） ---------- */
.search-row { display: flex; align-items: center; gap: 22px; }
.input-methods { display: flex; gap: 6px; flex: none; }
.input-method {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 64px; padding: 4px 0; border: 0; border-radius: 4px;
  background: transparent; color: var(--soft); cursor: pointer; font: inherit;
}
.input-method:hover { background: var(--hover); color: var(--fg); }
.input-method svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.input-method span { font-size: 0.9375rem; line-height: 1.2; }

.search { flex: 1; min-width: 0; border: 5px solid var(--box); border-radius: 6px; }
.search-inner { display: flex; align-items: center; background: var(--field); padding: 5px; gap: 4px; }
.search-type { flex: none; display: flex; align-items: center; padding: 0 10px 0 12px; border-right: 1px solid var(--line); height: 40px; }
.search-type select {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 1.0625rem; cursor: pointer;
  -webkit-appearance: none; appearance: none; padding-right: 14px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 4px center, right 0 center; background-size: 4px 4px; background-repeat: no-repeat;
}
#input {
  flex: 1;
  min-width: 0;
  height: 3.25rem;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--fg);
  font-size: 1.625rem;
  line-height: 3.25rem;
  padding: 0 10px;
  white-space: pre;
  overflow: hidden;
}
#input::placeholder { color: var(--muted); opacity: .8; }
.icon-btn {
  flex: none; width: 3.25rem; height: 3.25rem; border: 0; border-radius: 2px;
  background: transparent; color: var(--soft); cursor: pointer; display: grid; place-items: center;
}
.icon-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.icon-btn:hover { color: var(--fg); }
.icon-btn.submit { background: var(--hover); width: 3.5rem; }
.icon-btn.submit:disabled { cursor: wait; opacity: .5; }
.status { color: var(--muted); font-size: 0.875rem; margin: 6px 0 0; min-height: 21px; }

/* ---------- 原文词块条（zen bar） ---------- */
.zen { position: relative; margin: 1.4rem 0 0.5rem; font-size: 1.5rem; line-height: 1.3; max-height: 45vh; overflow-y: auto; overscroll-behavior: contain; }
.zen.expanded { max-height: none; overflow: visible; }
/* 长文里屏幕外的行先不排版，贴整篇小说也不卡 */
.zen ul { content-visibility: auto; contain-intrinsic-size: auto 48px; }
.zen-toggle { display: block; margin: 0 0 6px; padding: 0; border: 0; background: none; color: var(--link); font: inherit; font-size: 0.875rem; cursor: pointer; }
.zen-toggle:hover { text-decoration: underline; }
.zen ul { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; align-items: flex-end; }
.zen li { margin: 0 3px 6px 0; }
.zen a { display: inline-block; color: var(--fg); padding: 2px 3px; border-radius: 3px; border-bottom: 2px solid transparent; }
.zen a:hover { background: var(--hover); text-decoration: none; }
.zen a.current { border-bottom-color: var(--accent); }
.zen li.dim a { color: var(--muted); }
.zen li:not(:has(a)) { padding: 2px 0; }
rt { font-size: 0.75rem; color: var(--muted); }
.no-furigana rt { visibility: hidden; }

/* ---------- 两栏 ---------- */
.columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 2.5rem; margin-top: 1.1rem; }
.block-title {
  margin: 0 0 4px;
  padding-bottom: 6px;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--soft);
  border-bottom: 1px solid var(--line);
}
.result-count { font-weight: 400; color: var(--muted); }

/* ---------- 词条（Jisho 的 concept_light） ---------- */
.concept {
  position: relative;
  display: grid;
  grid-template-columns: 25% 1fr;
  gap: 0 1.5rem;
  padding: 1.25rem 0 1.75rem;
  border-bottom: 1px solid var(--line);
}
.concept.current { background: linear-gradient(90deg, var(--hover), transparent 60%); }
.representation { font-size: 2.25rem; line-height: 1.25; overflow-wrap: anywhere; }
.representation rt { font-size: 0.875rem; }
.representation.long { font-size: 1.75rem; }
.representation.longer { font-size: 1.375rem; }
.no-furigana .representation rt { display: none; }
.status { margin-top: 10px; font-size: 0.8125rem; }
.label {
  display: inline-block;
  margin: 0 2px 4px 0;
  padding: 3px 7px;
  border-radius: 3px;
  background: var(--label);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.3;
  white-space: nowrap;
}
.label-count { background: var(--label-soft); }
.status-link { display: block; color: var(--muted); font-size: 0.8125rem; line-height: 1.7; }
.status-link:hover { color: var(--soft); }

.concept-meanings { min-width: 0; }
.meaning-tags { color: var(--soft); font-size: 0.8125rem; margin: 8px 0 2px; }
.meaning-tags:first-child { margin-top: 2px; }
.meaning { font-size: 1.125rem; line-height: 1.5; margin-bottom: 6px; }
.divider { color: var(--muted); }
.supplemental { display: block; color: var(--muted); font-size: 0.8125rem; }
.details-link { position: absolute; right: 0; bottom: 8px; font-size: 0.8125rem; color: var(--muted); }
.details-link:hover { color: var(--soft); }

/* 逐词模式：一次一个词，字放大（Jisho 的单词页） */
.focus-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 0 0.2rem; }
.focus-nav .button:disabled { opacity: 0.4; cursor: default; }
.focus-pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.focus-pos b { color: var(--fg); }
.concept.focus { grid-template-columns: 30% 1fr; padding-top: 1.6rem; border-bottom: 0; }
.concept.focus .representation { font-size: 3.6rem; }
.concept.focus .representation rt { font-size: 1.1rem; }
.concept.focus .meaning { font-size: 1.6rem; }
.concept.focus .meaning-tags { font-size: 1rem; }
.concept.known .representation, .concept.known .meaning-text { color: var(--known); }

.empty { color: var(--muted); padding: 20px 0; }

/* ---------- 侧栏 ---------- */
.side-block { margin-bottom: 28px; }
.side-block .block-title { font-size: 1rem; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; font-size: 0.9375rem; color: var(--soft); }
.side-row.check { justify-content: flex-start; cursor: pointer; user-select: none; }
.side-row select { font: inherit; font-size: 0.9375rem; padding: 3px 6px; background: var(--field); color: var(--fg); border: 1px solid var(--box); border-radius: 3px; }
.minor { color: var(--muted); font-size: 0.875rem; margin: 8px 0; }
.button {
  font: inherit;
  font-size: 0.9375rem;
  padding: 8px 18px;
  border: 0;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.button:hover { filter: brightness(1.1); }
.secondary-btn { background: var(--hover); color: var(--fg); }

/* ---------- 汉字：侧栏小卡片（照 Jisho 的 kanji_light） ---------- */
.kanji-light { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 0 14px; padding: 12px 0 26px; border-bottom: 1px solid var(--line); }
.kanji-light-info { grid-column: 1 / -1; color: var(--muted); font-size: 0.8125rem; margin-bottom: 4px; }
.kanji-light-char { font-size: 3.75rem; line-height: 1; color: var(--fg); }
.kanji-light-char:hover { text-decoration: none; color: var(--link); }
.kanji-light-en { font-size: 1rem; margin-bottom: 4px; }
.kanji-light-r { font-size: 0.9375rem; }
.rtype { color: var(--soft); font-weight: 600; }

/* ---------- 汉字详情页（照 Jisho 的 kanji 页） ---------- */
.kanji-view { margin-top: 18px; }
.back { margin: 0 0 14px; font-size: 0.9375rem; }
.kanji-details { display: grid; grid-template-columns: 200px 1fr 300px; gap: 0 36px; }
.kd-char { font-size: 9.375rem; line-height: 1; margin: 6px 0 18px; }
.kd-meta { font-size: 1.25rem; margin-bottom: 20px; }
.kd-anim { position: relative; width: 150px; height: 150px; }
.kd-anim > svg { width: 100%; height: 100%; }
.kd-anim path { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; }
.kd-anim path.bg { stroke: var(--line); }
.kd-anim path.anim { stroke: var(--fg); stroke-dasharray: 0 999; }
.kd-play { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; border: 0; background: transparent; cursor: pointer; padding: 0; color: var(--soft); }
.kd-play svg { width: 100%; height: 100%; }
.kd-play circle { fill: var(--bg); fill-opacity: .6; stroke: currentColor; stroke-width: 4; }
.kd-play path { fill: currentColor; }
.kd-play:hover { color: var(--fg); }
.kd-en { font-size: 2.25rem; line-height: 1.3; margin: 0 0 14px; }
.kd-readings { font-size: 1.625rem; line-height: 1.8; }
.kd-readings .rtype { font-size: 1.25rem; color: var(--fg); }
.kreading { border-bottom: 1px solid var(--fg); padding: 0 2px; }
.kd-links { display: flex; flex-wrap: wrap; gap: 8px 30px; margin-top: 30px; font-size: 1.25rem; }
.kd-links a { text-decoration: underline; text-underline-offset: 3px; }
.kd-links a.active { color: var(--fg); text-decoration: none; font-weight: 600; }
.kd-side { font-size: 1.25rem; line-height: 1.8; padding-top: 10px; }
.kd-h { font-size: 1.625rem; font-weight: 600; margin: 36px 0 12px; }
.stroke-order { display: flex; flex-wrap: wrap; border-top: 2px solid var(--box); border-left: 2px solid var(--box); width: fit-content; max-width: 100%; }
.stroke-box { width: 100px; height: 100px; border-right: 2px solid var(--box); border-bottom: 2px solid var(--box); background: var(--field); }
.stroke-box path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.stroke-box .grid { stroke: var(--box); stroke-width: 1; stroke-dasharray: 3 3; }
.stroke-box .ghost { stroke: transparent; stroke-width: 3; }
.stroke-box .done { stroke: var(--label-soft); stroke-width: 3; }
.stroke-box .now { stroke: var(--fg); stroke-width: 3.5; }
.stroke-box .dot { fill: #e0303a; }
.kd-compounds { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.compounds { list-style: none; padding: 0; margin: 0; font-size: 1.125rem; line-height: 1.9; }

.size-switch { display: inline-flex; border: 1px solid var(--box); border-radius: 4px; overflow: hidden; }
.size-switch button { border: 0; border-radius: 0; padding: 0.2rem 0.75rem; color: var(--soft); background: var(--field); }
.size-switch button + button { border-left: 1px solid var(--box); }
.size-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.size-switch button:nth-child(1) { font-size: 0.8rem; }
.size-switch button:nth-child(3) { font-size: 1.15rem; }

/* ---------- 导出对话框 ---------- */
.export-formats { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.6rem; margin: 0.9rem 0 0.4rem; }
.export-format { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; text-align: left; padding: 0.7rem 0.9rem; border: 1px solid var(--box); border-radius: 5px; background: var(--field); color: var(--fg); cursor: pointer; }
.export-format b { font-size: 1.05rem; color: var(--accent); }
.export-format span { font-size: 0.85rem; color: var(--muted); }
.export-format:hover, .export-format:focus-visible { border-color: var(--accent); }
.export-range { margin-top: 0.6rem; }
.link-btn { border: 0; background: none; padding: 0 0 0 0.8rem; color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--fg); }
.export-status { min-height: 1.3em; margin: 0.3rem 0; font-size: 0.9rem; color: var(--soft); }
.export-preview summary { cursor: pointer; color: var(--link); font-size: 0.9rem; margin: 0.4rem 0; }
dialog {
  width: min(640px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
  padding: 18px 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h2 { margin: 0 0 4px; font-size: 1.25rem; }
#exportText { width: 100%; font-size: 0.9375rem; background: var(--hover); color: var(--fg); border: 1px solid var(--line); border-radius: 3px; padding: 8px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.spacer { flex: 1; }

/* ---------- 页脚 ---------- */
.site-footer { margin-top: 60px; background: var(--footer); color: var(--muted); font-size: 0.8125rem; padding-bottom: 30px; }
.ornament { height: 4px; background: repeating-linear-gradient(90deg, var(--line) 0 12px, transparent 12px 18px); }
.footer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding-top: 22px; }
.footer-cols p { margin: 0; }
.site-footer a { color: var(--soft); }

/* ---------- 手机 ---------- */
@media (max-width: 800px) {
  .columns { grid-template-columns: 1fr; gap: 10px; }
  .secondary { order: -1; }
  .side-block.tip { display: none; }
  .footer-cols { grid-template-columns: 1fr; }
  .kanji-details { grid-template-columns: 150px 1fr; }
  .kd-side { grid-column: 1 / -1; }
  .kd-compounds { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .logo { font-size: 2.75rem; }
  .nav { gap: 16px; }
  .nav a, .nav-btn { font-size: 1rem; }
  .search-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .input-methods { justify-content: flex-start; }
  #input { font-size: 1.25rem; height: 2.75rem; line-height: 2.75rem; }
  .icon-btn { height: 2.75rem; width: 2.5rem; }
  .icon-btn.submit { width: 44px; }
  .search-type { padding: 0 6px; height: 34px; }
  .zen { font-size: 1.25rem; }
  .concept { grid-template-columns: 1fr; padding-bottom: 36px; }
  .representation { font-size: 2rem; }
  .status .status-link { display: inline-block; margin-right: 10px; }
  .kanji-details { grid-template-columns: 1fr; }
  .kd-char { font-size: 6.875rem; }
  .kd-en { font-size: 1.75rem; }
  .kd-readings { font-size: 1.375rem; }
  .kd-links { font-size: 1.0625rem; gap: 6px 18px; }
  .stroke-box { width: 76px; height: 76px; }
}
