:root {
  color-scheme: light;
  --blue: #0645ad;
  --navy: #183f6e;
  --line: #9aa5b1;
  --pale: #edf3f8;
  --header: #dce8f2;
  --selected: #ffed9b;
  --green: #246b2a;
  font-family: Arial, Helvetica, "Yu Gothic", "Meiryo", sans-serif;
  font-size: 13px;
}

* { box-sizing: border-box; }
html { background: #fff; color: #202020; }
body { margin: 0; }
a { color: var(--blue); text-decoration: underline; }
button, input, select, textarea { border: 1px solid #777; border-radius: 0; background: #f5f5f5; color: #111; font: inherit; min-height: 25px; }
button, select { cursor: pointer; }
button:hover, .button-link:hover { background: #fffbd3; }
button.primary, .button-link.primary { background: #ffef8a; border-color: #806d1d; font-weight: bold; }
code { background: #eee; border: 1px solid #ccc; padding: 1px 3px; }

.page-shell { width: min(1080px, 100%); margin: 0 auto; padding: 0 6px; }
.site-header { background: var(--navy); color: #fff; border-bottom: 3px solid #d4a400; padding: 8px 10px 6px; display: flex; align-items: baseline; gap: 18px; }
.wordmark { color: #fff; font: bold 25px/1 "Yu Mincho", "MS Mincho", serif; text-decoration: none; }
.wordmark span { font: bold 16px Arial, sans-serif; margin-left: 8px; }
.tagline { color: #dce8f2; font-size: 12px; }
.tabs { display: flex; background: #d5dce3; border: 1px solid #8793a0; border-top: 0; }
.tabs a { display: block; padding: 5px 18px; border-right: 1px solid #8793a0; color: #123c68; font-weight: bold; text-decoration: none; }
.tabs a:hover { background: #fff; }
main { padding: 7px 0; }
footer { margin-top: 8px; border-top: 1px solid #aaa; padding: 7px 2px 20px; color: #555; font-size: 11px; }

.panel { border: 1px solid var(--line); margin: 0 0 7px; padding: 7px; }
.panel h1, .panel h2 { margin: -7px -7px 7px; padding: 4px 7px; background: var(--header); border-bottom: 1px solid var(--line); color: #183f6e; }
.panel h1 { font-size: 16px; }
.panel h2 { font-size: 13px; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.button-link { display: inline-block; border: 1px solid #777; padding: 4px 9px; background: #f5f5f5; color: #111; text-decoration: none; }
.manual-form { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; align-items: center; margin-top: 7px; padding-top: 7px; border-top: 1px dotted #aaa; }
.manual-form input { width: 100%; padding: 2px 4px; }
.notice { border: 1px solid #d2b34c; background: #fff9d9; margin: 0 0 7px; padding: 5px 7px; }
.data-note { color: #666; font-size: 11px; text-align: right; }

.kanji-section h2 { display: flex; justify-content: space-between; }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 2px; }
.kanji-cell { height: 34px; border: 1px solid #aaa; background: #fafafa; display: grid; place-items: center; cursor: pointer; position: relative; }
.kanji-cell:hover { border-color: #315f8b; background: #eef6ff; }
.kanji-cell.selected { background: var(--selected); border-color: #8b7417; }
.kanji-cell input { position: absolute; opacity: 0; pointer-events: none; }
.kanji-cell span { font: 21px/1 "Yu Mincho", "MS Mincho", serif; }
.large-japanese { font: 24px/1.5 "Yu Mincho", "MS Mincho", serif; overflow-wrap: anywhere; }

.vocabulary-table { width: 100%; border-collapse: collapse; table-layout: auto; margin-bottom: 7px; }
.vocabulary-table th { background: #dce8f2; color: #183f6e; }
.vocabulary-table th, .vocabulary-table td { border: 1px solid #929ca6; padding: 4px 6px; text-align: left; vertical-align: top; }
.vocabulary-table tbody tr:nth-child(even) { background: #f4f6f7; }
.vocabulary-table tbody tr.in-anki { background: #e7f4e5; }
.vocabulary-table .check-column { width: 62px; text-align: center; }
.vocabulary-table .rank-column { width: 70px; text-align: center; }
.word-cell { width: 1%; min-width: max-content; text-align: center !important; white-space: nowrap; }
.word-cell > a, .word-cell > a:visited { color: #111; font: 21px/1.45 "Yu Mincho", "MS Mincho", serif; text-decoration: none; }
.word-cell small { display: block; color: #555; }
ruby rt { font-size: .55em; color: #333; }
.anki-badge { display: inline-block; margin-top: 2px; padding: 1px 4px; border: 1px solid #609164; background: #dff1dd; color: var(--green); font-size: 10px; font-weight: bold; }
.anki-badge[hidden] { display: none; }
details { display: inline; color: #444; }
details summary { display: inline; cursor: pointer; color: var(--blue); text-decoration: underline; }
details[open] { display: block; border-top: 1px dotted #aaa; margin-top: 3px; padding-top: 3px; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; border: 1px solid var(--line); padding: 5px 8px; }
.pagination :last-child { text-align: right; }
.pagination span { color: #888; }
.empty-state { text-align: center; padding-bottom: 20px; }

.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 7px 14px; margin-bottom: 8px; }
.mapping-grid label { display: grid; grid-template-columns: 115px 1fr; align-items: center; }
.compact { table-layout: auto; }
.compact td:first-child { font: 18px "Yu Mincho", "MS Mincho", serif; }
.help-panel li { margin-bottom: 4px; }
.status-present { color: var(--green); font-weight: bold; }
.status-error { color: #a11212; font-weight: bold; }
.context-cell { width: 45%; min-width: 360px; padding: 3px !important; }
.sentence-picker { max-height: 190px; overflow-y: auto; border: 1px solid #8d98a3; background: #fff; }
.sentence-option { display: grid; grid-template-columns: 18px 1fr; gap: 1px 3px; padding: 4px; border-bottom: 1px solid #ccd3da; cursor: pointer; }
.sentence-option:last-child { border-bottom: 0; }
.sentence-option:hover { background: #fffbd3; }
.sentence-option input { grid-row: 1 / 4; align-self: start; margin: 1px 0 0; min-height: 0; }
.sentence-text { font: 16px/1.35 "Yu Mincho", "MS Mincho", serif; }
.sentence-text strong { background: var(--selected); }
.sentence-option small { grid-column: 2; color: #444; font-size: 11px; line-height: 1.25; }
.custom-sentence { grid-template-columns: 18px 1fr; }
.custom-sentence textarea { grid-column: 2; width: 100%; resize: vertical; padding: 2px 3px; background: #fff; }
dialog { border: 2px solid #555; border-radius: 0; padding: 12px; max-width: 460px; }
dialog::backdrop { background: rgb(0 0 0 / 35%); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.prose { line-height: 1.45; }
.prose h2 { margin-top: 14px; }
.error-panel { margin-top: 20px; }

@media (max-width: 620px) {
  .page-shell { padding: 0; }
  .site-header { display: block; }
  .tagline { display: block; margin-top: 4px; }
  .tabs a { flex: 1; padding: 6px 4px; text-align: center; }
  main { padding: 5px; }
  .manual-form { grid-template-columns: 1fr auto; }
  .manual-form label, .manual-form #manual-message { grid-column: 1 / -1; }
  .kanji-grid { grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); }
  .vocabulary-table { table-layout: auto; font-size: 12px; }
  .word-cell { width: auto; }
  .rank-column { display: none; }
  .mapping-grid { grid-template-columns: 1fr; }
  .context-cell { width: auto; min-width: 300px; }
}
