* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --ink: #322820;
  --muted: #71614f;
  --rule: #d4c3a8;
  --red: #8d3025;
  --paper: #fcf6e8;
  --serif: "Songti SC", "STSong", "SimSun", serif;
  --brush: "Kaiti SC", "KaiTi", "STKaiti", "BiauKai", var(--serif);
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font: 15px/1.6 var(--sans);
  color: var(--ink);
  background: #f1e9d9;
}
body {
  margin: 0;
  min-height: 100svh;
  background: radial-gradient(ellipse at 32% 20%, #fcf8ed, transparent 69%), #eee5d4;
}
h1, h2, h3, p { margin: 0; }
button, select, input, textarea { color: inherit; font: inherit; }
button, select { cursor: pointer; }
button {
  border: 0; border-radius: 3px; background: transparent; min-height: 44px;
  transition: background-color 140ms, transform 140ms, color 140ms;
}
button:hover:not(:disabled) { background-color: #80512112; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .43; cursor: default; }
:focus-visible { outline: 2px solid #a13c2b; outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: #ead2b7; }
.wrap { width: min(1100px, calc(100% - 72px)); margin-inline: auto; }
.skip {
  position: fixed; top: 8px; left: 12px; z-index: 10;
  padding: 10px; color: var(--ink); background: var(--paper);
}
.skip:not(:focus) { clip-path: inset(50%); }
.nav {
  color: #fff1d6;
  background: linear-gradient(100deg, #53261f, #733229 56%, #542720);
  border-bottom: 3px double #c1a076;
}
.header-inner, .brand, nav, .board-head, .position-mode, .board-tools,
.board-actions, .transport, .feedback, .dialog-head, .scan-tools {
  display: flex; align-items: center;
}
.header-inner { min-height: 69px; justify-content: space-between; gap: 12px; }
.brand { gap: 12px; white-space: nowrap; }
.brand b { font: 700 35px/1 var(--brush); letter-spacing: .06em; }
.brand span { padding-left: 13px; border-left: 1px solid #b98a6d; color: #e7ccb1; font: 15px var(--serif); letter-spacing: .15em; }
.seal {
  display: block; position: relative; width: 29px; height: 29px; color: #edd5ad;
  border: 3px double currentColor; border-radius: 4px;
}
.seal::before, .seal::after { content: ""; position: absolute; }
.seal::before {
  inset: 3px; border: 1px solid currentColor;
  background: linear-gradient(45deg, transparent 47%, currentColor 48% 52%, transparent 53%),
              linear-gradient(-45deg, transparent 47%, currentColor 48% 52%, transparent 53%);
}
.seal::after { inset: 3px 49%; border-left: 1px solid; }
nav { gap: 6px; }
nav button { color: #fff0d6; padding-inline: 14px; }
nav button:hover:not(:disabled) { background: #ffffff18; }
nav button:focus-visible { outline-color: #f3d29c; }
.work { padding: clamp(18px,3.3vh,34px) 0 40px; }
.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(0, 1fr);
  gap: clamp(28px,4.2vw,62px); align-items: start;
}
.board-card, aside { min-width: 0; }
.board-card { width: min(100%, max(385px, calc((100svh - 238px) * .88))); justify-self: center; }
.board-head { justify-content: space-between; gap: 12px; margin: 0 2px 13px; }
h1 { font: 700 clamp(23px,2.5vw,32px)/1.35 var(--brush); }
.position-mode { justify-content: end; flex-wrap: wrap; gap: 0 10px; color: var(--muted); font-size: 13px; }
#turn { white-space: nowrap; }
#turn::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; background: #342e23;
}
#turn[data-side="w"]::before { background: #a23828; }
#boardTitle:empty { display: none; }
.board-field {
  position: relative; isolation: isolate; padding: 4px 7px;
  border: 5px solid #87502a; border-radius: 6px;
  background-color: #e6bf86; background-image: var(--wood); background-size: 100% 100%;
  box-shadow: inset 0 0 0 1px #edca95, inset 0 0 10px #84572d70,
    0 1px 0 1px #693e23, 0 4px 0 #754529, 0 6px 8px #4b301d36, 0 13px 22px -15px #493221;
}
.board-files {
  display: grid; grid-template-columns: repeat(9,1fr); align-items: center;
  height: 17px; text-align: center; color: #382818; font: 600 12px/1 var(--serif);
}
.board {
  aspect-ratio: 9/10; container-type: inline-size; position: relative; user-select: none;
  touch-action: manipulation; text-size-adjust: 100%;
}
.board canvas, #pieces { position: absolute; inset: 0; width: 100%; height: 100%; }
.cell {
  position: absolute; display: grid; place-items: center; min-height: 0;
  width: 11.11111%; height: 10%; padding: 0; border-radius: 50%; z-index: 1;
}
.cell:hover:not(:disabled) { background-color: #80512112; }
.cell:focus-visible { outline-offset: -2px; }
.stone, .guide-stone {
  display: grid; place-items: center; border-radius: 50%; position: relative;
  background: radial-gradient(ellipse at 37% 26%, #fff0c7, #f1d59e 54%, #d9ac6c 78%, #a97038 94%);
  border: 1px solid #96703e;
  color: #30251b;
  text-shadow: 0 1px 0 #ffe8b7;
  box-shadow: inset 1px 1.5px 1px #fff4d3, inset -1px -2px 2px #a97940,
    0 2px 0 #af8047, 0 3px 0 #8d6235, 1px 4px 2px #49301977, 2px 6px 5px #58402055;
}
.stone {
  width: 88%; aspect-ratio: 1;
  font: 700 5.25cqw/1 var(--brush);
  transition: transform 120ms, box-shadow 120ms;
}
.stone::before, .guide-stone::before {
  content: ""; position: absolute; inset: 7%; border: 1px solid currentColor;
  box-shadow: 0 1px 0 #ffedbf; border-radius: 50%; opacity: .68;
}
.stone.red, .guide-stone { color: #9a2d1d; }
.cell.selected .stone { transform: translateY(-3px); }
.cell.last::after, .cell.selected::after, .cell.origin::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  --mark: #902e20;
  background:
    linear-gradient(var(--mark) 0 0) top left / 21% 2px,
    linear-gradient(var(--mark) 0 0) top left / 2px 21%,
    linear-gradient(var(--mark) 0 0) bottom right / 21% 2px,
    linear-gradient(var(--mark) 0 0) bottom right / 2px 21%;
  background-repeat: no-repeat;
}
.cell.origin::after { inset: 24%; opacity: .7; }
.cell.selected::after { --mark: #453d24; }
.cell.target::after {
  content: ""; position: absolute; width: 20%; aspect-ratio: 1;
  background: #854020; border: 1px solid #fff1cd; border-radius: 50%; pointer-events: none;
}
.cell.target:has(.stone)::after { width: 92%; background: transparent; border: 2px dashed #882f20; }
.board-tools {
  gap: 6px; flex-wrap: wrap; margin-top: 13px; padding-block: 8px;
  border-block: 1px solid var(--rule); justify-content: space-between;
}
.quiet { color: var(--muted); padding-inline: 8px; font-size: 13px; }
.board-actions, .transport { gap: 5px; }
.compact-label { display: none; }
.primary, .secondary { font-weight: 600; padding-inline: 16px; }
.primary { background: #88372a; color: #fff7e8; box-shadow: inset 0 1px 0 #b5674d; }
.primary:hover:not(:disabled) { background: #713025; }
.primary:disabled { opacity: 1; background: #dfd3bd; color: #756655; box-shadow: none; }
.secondary { border: 1px solid #bdab8c; background: #faf3e4; }
.transport button { font: 24px Georgia, serif; width: 32px; }
.transport output { min-width: 59px; color: var(--muted); text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
aside {
  margin-top: 4px; border: 1px solid #cbb99d; border-radius: 2px;
  background: var(--paper); border-left: 4px double #b59a76;
  box-shadow: 2px 3px 0 -1px #e8deca, 3px 4px 0 -1px #cbbc9f, 0 7px 18px -12px #77604466;
}
.paper { padding: clamp(20px,3vw,36px); }
h2 { font: 700 clamp(21px,2.2vw,28px)/1.4 var(--brush); overflow-wrap: anywhere; }
.section-label { font-size: 12px; color: var(--red); margin-top: 5px; }
#comment { margin-top: 14px; overflow-wrap: anywhere; }
#comment p { margin-bottom: 10px; font: 17px/1.94 var(--serif); }
#moveGuide {
  position: relative; margin: 26px 0 4px; height: 89px; overflow: hidden;
  background: linear-gradient(transparent 49%, #b39c7666 49% 50.5%, transparent 50.5%);
  mask-image: linear-gradient(90deg, transparent, black 13% 87%, transparent);
}
.guide-file {
  position: absolute; inset: 0; opacity: .48;
  background: repeating-linear-gradient(90deg, transparent 0 calc(12.5% - 1px), #a98a60 calc(12.5% - 1px) 12.5%);
  mask-image: linear-gradient(transparent, black 35% 65%, transparent);
}
.guide-stone, .guide-end { position: absolute; top: 50%; transform: translate(-50%,-50%); }
.guide-stone { left: 75%; width: 44px; height: 44px; font: 700 26px/1 var(--brush); }
.guide-end { left: 25%; width: 11px; height: 11px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px #ac8060; }
.guide-path { position: absolute; left: 25%; right: 25%; top: 50%; border-top: 2px dashed #aa7154; }
#branches:not(:empty), .feedback { margin-top: 20px; }
#branches h3, #scanResult h3 { font: 600 15px var(--serif); margin-bottom: 8px; color: var(--muted); }
.moves .current { background: #ebdcc4; color: var(--red); }
.feedback-form {
  margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--rule);
  display: grid; gap: 7px; font-size: 14px;
}
.feedback-form textarea { width: 100%; min-width: 0; padding: 8px; font: inherit; resize: vertical; }
.feedback-form textarea + label { margin-top: 4px; }
.feedback-consent { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.feedback-consent input { accent-color: var(--red); flex: none; width: 17px; height: 17px; }
.feedback-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
#feedbackNotice:empty { display: none; }
.moves { display: grid; grid-template-columns: 1fr 1fr; max-height: 250px; overflow: auto; margin-top: 12px; }
.moves button { text-align: left; font-family: var(--serif); }
.scan-tools, .dialog-head { justify-content: space-between; gap: 6px; margin-block: 12px; }
select, input, textarea { border: 1px solid #bdaa8a; border-radius: 3px; background: #fffaf0; }
select { min-height: 44px; padding-inline: 6px; }
.issue, .error { color: var(--red); }
.issue { display: block; text-align: left; }
#status:not(:empty) { padding: 10px 18px; border-bottom: 1px solid var(--rule); background: #f4ead5; color: #6c4831; font-size: 14px; }
dialog { width: min(470px, calc(100% - 24px)); max-height: 85dvh; padding: 18px 22px 24px; background: var(--paper); border: 1px solid #9c8060; border-top: 4px solid var(--red); color: var(--ink); box-shadow: 0 12px 36px #33271c40; }
dialog::backdrop { background: #2d1e15a3; }
.dialog-head { margin-top: 0; }
.dialog-head h2 { font-size: 26px; }
.dialog-head button { font-size: 25px; min-width: 44px; }
textarea, .dialog-head + div input { display: block; width: 100%; margin: 8px 0 14px; padding: 10px; }
@media (max-width: 1099px) {
  .board-tools:has(.transport:not([hidden])) .transport { order: -1; width: 100%; justify-content: center; }
  .transport button { width: 44px; }
}
@media (max-width: 899px) {
  .wrap { width: min(calc(100% - 24px), 595px); }
  .header-inner { min-height: 52px; }
  .brand { gap: 7px; }
  .brand b { font-size: 27px; }
  .brand span { font-size: 12px; padding-left: 8px; }
  .seal { width: 22px; height: 22px; }
  nav { gap: 0; }
  nav button { padding-inline: 7px; font-size: 13px; }
  .columns { grid-template-columns: 1fr; gap: 17px; }
  .work { padding-top: 14px; }
  .board-card { width: 100%; }
  .board-head { margin-bottom: 9px; gap: 5px; }
  .board-field { border-width: 4px; padding: 2px; }
  .board-files { height: 15px; font-size: 11px; }
  .board-tools { margin-top: 10px; padding-block: 6px; }
  .board-tools:has(.transport:not([hidden])) { row-gap: 0; }
  .transport button { width: 46px; }
  aside { margin: 0; }
  .paper { padding: 17px 20px; }
  #comment { margin-top: 8px; }
  #moveGuide { margin-top: 12px; height: 56px; }
}
@media (max-width: 360px) {
  .brand span { display: none; }
  .position-mode { font-size: 12px; }
  .primary, .secondary { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.evaluation {
  display: flex; align-items: center; gap: 12px; min-height: 32px;
  padding: 3px 11px; margin-bottom: 8px; color: #fff3df;
  position: relative; isolation: isolate; overflow: hidden;
  background: #302e2c; font-size: 13px;
}
.evaluation::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: #963e34; transform-origin: left;
  transform: scaleX(var(--red-share, .5));
  transition: transform 320ms ease-out;
}
.evaluation:not([data-scored]) { background: #524943; }
.evaluation:not([data-scored])::before { visibility: hidden;
}
.evaluation > span { color: #eadbc6; }
.evaluation output { font-weight: 600; }
.evaluation small { margin-left: auto; font-size: 12px; color: #f2e4ce; }
.evaluation button { color: inherit; min-height: 32px; }
.transport #prev, .transport #next { width: auto; padding: 0 8px; font: 14px var(--sans); white-space: nowrap; }
.editing .columns { grid-template-columns: minmax(0, 1fr); }
.editing aside, .editing nav, .editing .board-actions, .editing #boardTitle { display: none; }
.editing .board, .reserve-slot { touch-action: none; }
.editing .board-card { width: min(100%, max(350px, calc((100svh - 325px) * .83))); }
.reserve {
  display: grid; grid-template-columns: repeat(6,1fr); align-items: center;
  margin: 4px 0 8px; padding: 3px 8px; border-radius: 4px;
  background: linear-gradient(#654530,#78563d);
  box-shadow: inset 0 2px 4px #36251b55;
}
#bottomReserve { margin: 10px 0 4px; }
.reserve-slot { padding: 0; position: relative; display: grid; place-items: center; min-height: 42px; }
.reserve-slot .stone { width: 33px; font: 700 21px/1 var(--brush); }
.reserve-slot small {
  position: absolute; top: 0; left: calc(50% + 7px); min-width: 15px; border-radius: 10px;
  color: white; background: #803226; font: 600 11px/15px var(--sans);
}
.reserve-slot.empty .stone { color: #ead7b6; border-color: #cfaf84; opacity: .65; background: transparent; box-shadow: none; text-shadow: none; }
.reserve-slot.empty small { display: none; }
.reserve-slot[aria-pressed="true"] { outline: 2px solid #ffe0a7; outline-offset: -2px; }
#setupInfo { padding: 4px 2px; font-size: 13px; }
#setupProblem:not(:empty) { color: var(--red); font-weight: 600; }
.editing .board-tools { margin-top: 4px; }
.setup-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.setup-actions button { padding-inline: 9px; }
.drag-stone {
  position: fixed; transform: translate(-50%,-65%); z-index: 8; pointer-events: none;
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
  border: 3px double #936d3e; background: #f3d59d; box-shadow: 1px 6px 6px #33241455;
  font: 700 27px var(--brush);
}
.drag-stone.red { color: var(--red); }
@media (min-width: 900px) {
  .board-card { width: min(100%, max(360px, calc((100svh - 290px) * .84))); }
}
@media (max-width: 899px) {
  .editing .board-card { width: 100%; }
  .editing .work { padding-top: 8px; }
  .editing .board-tools { gap: 2px; }
  .editing .transport { border-bottom: 1px solid var(--rule); }
}

#candidatePanel { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #d9cbb3; }
#candidateOptions, #candidateRows li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
#candidateOptions input { width: 5rem; }
#candidateRows { list-style: none; padding: 0; margin: .5rem 0 0; }
#candidateRows li { padding: .4rem 0; border-top: 1px solid #e6dac6; }
#candidateRows .secondary { margin-left: auto; }
#candidateRows .candidate-choice { padding: 4px 8px; font-weight: 600; }
#candidateRows .candidate-choice[aria-pressed="true"] { background: #e0ecdd; color: #205439; }
#candidateHint:empty { display: none; }

nav [aria-current="page"] { color: #fff6e2; box-shadow: inset 0 -2px #e0bd82; }
.record-head, .record-actions, .section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.record-head, .section-head { justify-content: space-between; }
.record-head { border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
.record-actions { margin-left: auto; }
.record-head strong:empty { display: none; }
.record-head strong { overflow-wrap: anywhere; }
.record-actions button, .section-head button, #backReview, #savedStudy button { color: var(--red); }
.shelf { max-width: 760px; padding-block: 32px; }
.shelf h1 { font-family: var(--serif); }
#libraryList button { display: block; width: 100%; padding: 12px 2px; text-align: left; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
#libraryList small { display: block; color: var(--muted); }
#libraryStatus, #savedStudy:not(:empty) { padding-block: 12px; }
#savedStudy button, #dialogBody .menu-choice { display: block; text-align: left; }
#dialogBody input[type=text] { width: 100%; }
.editing .record-actions { display: none; }
.in-match aside, .in-match .record-head, .in-match .board-actions,
.in-match .transport, .in-match #boardTitle { display: none; }
.in-match .columns { display:block; max-width:730px; }
#matchHead, #matchActions, .match-fields, .shelf-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
#matchHead { justify-content:space-between; border-bottom:1px solid var(--rule); padding-bottom:8px; }
#matchActions { justify-content:flex-end; }
#resignBtn { min-width: 54px; color: var(--red); }
.match-result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.match-result-actions button { min-width: 56px; }
#matchResultReason { color: var(--muted); }
#matchResultError:not(:empty) { margin-top: 8px; }
.match-fields label { display:grid; gap:4px; }
.shelf-row { flex-wrap:nowrap; border-bottom:1px solid var(--rule); }
#libraryList .shelf-row button { border:0; }
#libraryList .shelf-row button:not(:first-child) { width:auto; color:var(--red); flex-shrink:0; }
#libraryList .shelf-row button:first-child { width:auto; min-width:0; flex:1; }
.board .cell { touch-action:manipulation; }
@media (max-width:420px) { .header-inner nav { gap:0; } .header-inner nav button { padding-inline:7px; } }

.shelf-switch, .drill-actions, .issue-row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.shelf-switch { border-bottom:1px solid var(--rule); margin-top:12px; }
.shelf-switch [aria-pressed="true"] { color:var(--red); box-shadow:inset 0 -2px var(--red); }
.issue-row .issue { flex:1; text-align:left; }
.in-drill aside, .in-drill .record-head, .in-drill .transport, .in-drill .board-actions,
.in-drill #title, .in-drill #boardTitle, .in-drill #evaluation { display:none; }
.in-drill .columns { display:block; max-width:730px; }
#drillHead { scroll-margin-top:12px; }
#drillPanel { border-top:1px solid var(--rule); padding-top:12px; }
#drillAnswer h3 { margin:14px 0 6px; }
.drill-row { display:grid; grid-template-columns:6em 1fr auto; gap:6px; padding:6px 0; border-bottom:1px solid var(--rule); }
.drill-line { color:var(--muted); margin-bottom:8px; }
.drill-lecture { white-space:pre-line; }

.photo-import { display: grid; gap: 10px; }
.photo-pickers, .photo-fields { display: flex; gap: 12px; }
.photo-status, .photo-correction > p { font-size: 14px; }
.photo-reference summary { cursor: pointer; color: var(--red); }
.photo-reference canvas { display: block; width: 100%; max-height: 38dvh; object-fit: contain; margin: 6px auto; }
.photo-correction { min-width: 0; }
.photo-correction .board-field { margin: 8px 0 12px; }
.photo-board .uncertain { outline: 2px dashed #804420; outline-offset: -2px; }
.photo-board .unknown { background: #f6e9c9; }
.photo-palette { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; margin: 6px 0; }
.photo-palette button { display: grid; place-items: center; min-width: 0; padding: 0; }
.photo-palette .stone { width: min(84%, 35px); font: 700 clamp(16px, 4.5vw, 21px)/1 var(--brush); }
.photo-palette .remove-stone { grid-column: 1 / -1; justify-self: start; color: var(--red); padding-inline: 6px; }
@media (max-width: 759px) {
  dialog:has(.photo-import) { padding-inline: 12px; width: calc(100% - 12px); }
}
.photo-fields { margin-block: 12px; }
.photo-fields label, .photo-fields select { display: block; }
.photo-fields select { min-height: 44px; }
@media (min-width: 760px) {
  dialog:has(.photo-import) { width: min(840px, 92vw); }
  .photo-content:has(.photo-correction) { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
  .photo-reference canvas { max-height: 65dvh; }
}

#reviewChart { width: 100%; height: 96px; touch-action: pan-y; border-bottom: 1px solid var(--rule); }
.review-trend-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; }
.review-caption { color: var(--muted); font-size: 13px; }
.review-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin-bottom:8px; border-top:1px solid var(--rule); padding-top:8px; }
.issue[aria-current=step] { background: #eedbb8; box-shadow: inset 3px 0 #963f25; }
.move-badge, .board-badge { background: #854321; color: #fff8e6; border-radius: 4px; font: 600 11px/1.35 var(--sans); padding: 1px 3px; }
.move-badge { margin-left: 4px; }
.board-badge { position: absolute; right: -2px; top: -2px; z-index: 3; pointer-events:none; }
.board canvas.board-arrow { z-index: 4; pointer-events:none; }
.reviewing-score .board-actions, .reviewing-score .record-head { display:none; }
.review-actions button { min-height:44px; padding-inline:2px; }
[data-grade="官"], [data-grade="优"] { background:#356848; }
[data-grade="良"] { background:#456871; }
[data-grade="中"] { background:#69645e; }
[data-grade="差"] { background:#94501d; }
[data-grade="错"] { background:#973c31; }
.mate-king .stone { outline: 3px solid #a52719; outline-offset: 1px; animation: mate-ring .72s ease-out; }
@keyframes mate-ring { 0%,65% { box-shadow: 0 0 0 6px #b52d1f70; } 100% { box-shadow: 0 0 0 1px transparent; } }
@media(prefers-reduced-motion:reduce) { .mate-king .stone { animation:none; } }

.mate-final .stone { outline: 3px solid #a52719; outline-offset: 1px; }

#reviewTrend { margin-top: 13px; }
#reviewTrend h3 { font-size: 16px; }
#reviewChart { display: block; cursor: crosshair; }

.grade-key { color:var(--muted); font-size:13px; margin:8px 0; }
.grade-key summary { cursor:pointer; }

@media (max-width: 599px) {
  .reviewing-score .columns { gap: 8px; }
  .reviewing-score .board-field {
    width: min(100%, clamp(248px, 78vw, 306px), max(248px, calc((100svh - 400px) * .9)));
    margin-inline: auto;
  }
  .reviewing-score #reviewTrend { margin-top: 8px; }
  .reviewing-score #reviewChart { height: 78px; }
  .reviewing-score .board-tools { gap: 0; margin-top: 0; padding-block: 0; border: 0; }
  .reviewing-score .board-tools:has(.transport:not([hidden])) .transport { order: 0; flex: 1; width: auto; gap: 0; }
  .reviewing-score .transport button, .reviewing-score .quiet { min-width: 44px; }
  .reviewing-score .transport output { min-width: 44px; margin-inline: 2px; }
  .reviewing-score .transport #prev, .reviewing-score .transport #next { width: 44px; padding-inline: 0; }
  .reviewing-score .full-label { display: none; }
  .reviewing-score .compact-label { display: inline; }
  .reviewing-score .review-actions { margin-bottom: 0; padding-top: 4px; }
  .reviewing-score #score { padding: 0 10px 8px; }
  .reviewing-score #score h2 { font-size: 19px; }
  .reviewing-score .scan-tools { justify-content: start; flex-wrap: wrap; margin: 0; gap: 4px 12px; }
  .reviewing-score .scan-tools label, .reviewing-score #scanResult { font-size: 13px; }
  .reviewing-score .moves {
    display: flex; margin-top: 4px; max-height: none;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  }
  .reviewing-score .moves button {
    flex: none; white-space: nowrap; padding-inline: 8px; border-right: 1px solid var(--rule);
  }
  .reviewing-score .moves button:focus-visible { outline-offset: -2px; }
}

#compareActions { display:flex; flex-wrap:wrap; gap:6px; margin-block:14px; }
#compareActions[hidden] { display:none; }
#compareActions button { min-height:44px; padding-inline:12px; }
#compareDialog {
  width:min(calc(100% - 16px), 490px, max(285px, calc((100dvh - 175px) * .9)));
  max-height:calc(100dvh - 16px);
  padding:10px 12px 14px;
}
#compareDialog .dialog-head { margin:0 0 2px; }
#compareDialog h2 { font-size:21px; }
#compareDialog .dialog-head button { font-size:14px; }
#comparePrompt { margin:0 0 8px; font-size:14px; }
#compareNotice { margin:7px 0 0; }
#compareNotice:empty { display:none; }

.compare-line { display:flex; flex-wrap:wrap; gap:2px 4px; }
.compare-line button { min-height:44px; padding-inline:6px; color:var(--red); font:600 15px var(--serif); }
.compare-line [aria-current="step"] { background:#eadbc2; color:var(--ink); box-shadow:inset 0 -2px var(--red); }
.lecture-sequence + .lecture-sequence { border-top:1px solid var(--rule); }
.lecture-sequence > span { display:block; margin-top:8px; font-size:13px; color:var(--muted); }
#lineReplay { padding-block:12px 4px; }
#lineReplay h3 { margin:0 0 4px; font:600 15px var(--serif); color:var(--muted); }
#boardPage:has(#lineReplay:not([hidden])) :is(#ask,#recommend) { display:none; }
#notes { max-height:82dvh; overflow-y:auto; scrollbar-gutter:stable; }
.chat-turn { padding-bottom:16px; margin-bottom:18px; border-bottom:1px solid var(--rule); }
.chat-question { color:var(--red); font:600 15px/1.6 var(--serif); margin:0 0 6px; }
.chat-reply { white-space:pre-line; font:16px/1.85 var(--serif); }
.replay-hint { color:var(--muted); font-size:13px; margin:0 0 8px; }
.replay-target { font-size:15px; margin:10px 0 0; }
#returnLine { color:var(--red); padding-inline:0; }
@media (max-width:899px) {
  #notes { max-height:76dvh; }
}
#savedStudy details { border-top:1px solid var(--rule); }
#savedStudy summary { display:list-item; padding-block:12px; cursor:pointer; color:var(--muted); font-size:14px; }
.analysis-pending :is(#notes,#backReview,#score,.board-tools,#lineReplay,#reviewActions) { display:none; }
.analysis-pending .record-actions, .analysis-pending nav { opacity:.5; }
#status:focus:not(:focus-visible), #noteTitle:focus { outline:0; }

.lesson-controls { display:flex; flex-wrap:wrap; gap:6px 12px; align-items:center; }
#feedbackToggle { color:var(--muted); font-size:13px; padding:0 4px; text-decoration:underline; text-underline-offset:3px; }
#guideSpot { position:fixed; pointer-events:none; z-index:80; border:2px solid #f4db9c;
  border-radius:8px; box-shadow:0 0 0 200vmax rgb(28 21 18 / 72%); }
#guideHint { position:fixed; z-index:81; left:50%; transform:translateX(-50%);
  width:min(430px,calc(100% - 24px)); background:var(--paper); color:var(--ink);
  padding:10px 14px; border:1px solid var(--rule); border-radius:6px; }
#guideHint p { margin:0; }
#guideExit { min-height:40px; color:var(--red); }
@media (max-width:599px) {
  .header-inner .brand span { display:none; }
  .header-inner nav button { white-space:nowrap; padding-inline:5px; }

}
@media (max-width:360px) {
  .header-inner .seal { display:none; }
  .header-inner { gap:4px; }
}
#trainPieces { position:absolute; inset:0; }
#trainingStatus { margin:5px 0; min-height:1.5em; }
.catalogue-filters { display:flex; flex-wrap:wrap; gap:10px; margin-block:18px; }
.catalogue-filters input, .catalogue-filters select { min-height:44px; border:1px solid var(--rule); border-radius:4px; background:var(--paper); padding:6px 12px; }
.catalogue-filters input { width:min(24rem,100%); min-width:0; }
.catalogue-layout { display:grid; grid-template-columns:minmax(155px,200px) minmax(0,1fr); gap:clamp(20px,4vw,48px); align-items:start; }
.catalogue-menu { display:grid; border-inline-end:1px solid var(--rule); padding-inline-end:16px; }
.catalogue-menu button { text-align:left; padding:6px 12px; }
.catalogue-menu [aria-expanded]::after { content:"＋"; float:right; color:var(--muted); }
.catalogue-menu [aria-expanded="true"]::after { content:"－"; }
.catalogue-menu [aria-pressed="true"] { color:var(--red); background:#e9dcc8; font-weight:600; }
.catalogue-submenu { display:flex; flex-wrap:wrap; gap:2px; margin:4px 0 8px 12px; border-inline-start:2px solid var(--rule); padding-left:6px; }
.catalogue-submenu button { font-size:14px; }
.catalogue-status { color:var(--muted); margin:8px 0; }
.catalogue-results { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,235px),1fr)); column-gap:20px; }
.catalogue-results .menu-choice { text-align:left; padding:12px 6px; border-bottom:1px solid var(--rule); font-weight:600; overflow-wrap:anywhere; }
.catalogue-results small { display:block; color:var(--muted); font-weight:normal; }
.puzzle-head { margin-bottom:16px; }
.puzzle-head button { color:var(--red); padding-inline:0; }
.training-layout { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); gap:clamp(20px,4vw,48px); align-items:start; }
.training-layout .board-field { width:min(100%,max(320px,calc((100svh - 220px) * .84))); justify-self:center; }
.training-details { border-top:1px solid var(--rule); padding-block:12px; min-width:0; }
@media (max-width:680px) {
  .catalogue-layout, .training-layout { grid-template-columns:minmax(0,1fr); gap:12px; }
  .catalogue-menu { display:flex; flex-wrap:wrap; padding:0; border:0; border-bottom:1px solid var(--rule); }
  .catalogue-submenu { order:1; flex-basis:100%; }
  .catalogue-filters input { width:0; flex:1; }
}
#trainNotes p { margin:8px 0; }
#trainNotes button { margin-right:6px; }
.lesson-controls { margin-top:6px; }
