@import url("design-tokens.css");
.pgn-shell { margin: auto; }
h1 { margin-bottom: .2rem; } h2 { font-size: 1.1rem; }
a { color: inherit; }
.info-panel { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 16px; padding: 1rem; }
.privacy, .help { font-size: .85rem; }
.pgn-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1rem; }
g-chess-board { display: block; width: 100%; }
.controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .7rem 0; }
button, select, input { font: inherit; color: var(--ink); }
button:not(.icon-btn), select, input[type=search] { border: 1px solid var(--panel-border); border-radius: 8px; background: #fffaf0; padding: .55rem; }
button { cursor: pointer; min-height: 42px; } button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid #007f86; outline-offset: 3px; }
.moves { position: relative; overflow-y: auto; display: flex; flex-wrap: wrap; gap: .3rem; padding: .3rem; }
.comment {
  margin: 1.1rem 0 .5rem;
  padding: 0;
  font-family: "PGN Notation", Georgia, serif;
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.7;
  color: var(--ink);
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#status, #storage-status { overflow-wrap: anywhere; }
#status[data-error=true], #storage-status { color: #8c361a; }
.last-move { position: absolute; width: 12.5%; height: 12.5%; box-sizing: border-box; background: #ecbc2860; pointer-events: none; }
#trial { border-top: 1px solid var(--panel-border); }
dialog { max-width: min(400px, 85vw); border-radius: 15px; border: 1px solid var(--panel-border); background: #fffaf0; }
#trial-moves, #analysis-result { overflow-wrap: anywhere; }
.piece-glyph { display: inline-block; width: 24px; height: 24px; vertical-align: middle; }
@media (max-width: 1024px) { .pgn-layout { grid-template-columns: minmax(0, 1fr); } body { padding: .75rem .4rem; } }
/* The library and game picker use the same cards as the home page. */
.pgn-browser { color-scheme: light; }
.pgn-browser .welcome { margin-top: .5rem; }
.pgn-browser .welcome h1 { overflow-wrap: anywhere; }
.library-actions { text-align: center; margin-bottom: 24px; }
.upload { position: relative; cursor: pointer; margin-top: 0; }
.upload input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.upload:focus-within { outline: 3px solid #a45b20; outline-offset: 5px; }
.pgn-browser .privacy { color: var(--hero-muted); margin-top: 12px; }
.pgn-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pgn-card { min-height: 150px; justify-content: center; gap: 10px; padding-right: 42px; }
.pgn-card h2 { overflow-wrap: anywhere; }
.pgn-card p { margin: 0; color: #7c765f; font-size: .85rem; line-height: 1.6; overflow-wrap: anywhere; }
.file-card { position: relative; min-width: 0; }
.file-card .pgn-card { box-sizing: border-box; }
.delete-file { position: static; }
.search-label { display: block; color: var(--hero-ink); }
.search-label input { display: block; width: min(440px, 100%); box-sizing: border-box; margin: 8px auto 0; padding: .8rem 1rem; border-radius: 999px; }
.empty-state { text-align: center; padding: 40px 20px; border-radius: 24px; background: #fffaf0ef; color: #7c765f; }
.pgn-browser #status { text-align: center; color: var(--hero-ink); }
.pgn-browser #status[data-error=true] { color: #8c361a; background: #fffaf0; border-radius: 12px; }
.pgn-shell { max-width: none; width: 100%; }
.player-header h1 { font-size: clamp(1.3rem, 3vw, 2rem); margin: .3rem 0; }
.player-header { margin-bottom: 1.25rem; padding-right: 3rem; }
.player-header p { color: var(--muted); font-size: .85rem; }
.board-panel > .controls { justify-content: center; }
#play { background: linear-gradient(#dc9a4c, #c9762f); color: #fffaf0; border-color: var(--accent-dark); min-width: 44px; font-weight: 700; }
#position-label { text-align: center; color: var(--muted); font-size: .85rem; }
summary { cursor: pointer; font-weight: 650; padding: .6rem 0; }
.info-panel { border-radius: 24px; padding: 1.25rem; }
@media (max-width: 600px) { .info-panel { padding: 1rem; } }
.comment:empty, #status:empty, #storage-status:empty { display: none; }
@media (max-width: 1024px) { .pgn-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .pgn-cards { grid-template-columns: minmax(0, 1fr); } .pgn-card { min-height: 125px; } .pgn-shell { padding: 0; } .player-header { margin-bottom: .75rem; } }

.pgn-layout { align-items: start; }
.player-header h1 { overflow-wrap: anywhere; }

#analysis-result { min-height: 1.25rem; margin: .4rem 0; font-size: .8rem; color: var(--muted); }
.analysis-card { margin-top: .5rem; border-top: 1px solid var(--panel-border); }
.analysis-head { display: flex; align-items: center; gap: .75rem; padding: .5rem 0 0; }
.analysis-field { flex: none; }
.analysis-summary { flex: 1; min-width: 0; text-align: right; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.analysis-body { padding: .25rem 0; }
.analysis-tablist { display: flex; flex: none; }
.analysis-tablist chess-button[type="tab"] > button { --icon-fg: var(--ink); position: relative; z-index: 1; min-width: 46px; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; background: transparent; box-shadow: none; color: var(--ink); }
.analysis-tablist chess-button[type="tab"] > button[aria-selected="true"] { border-color: var(--panel-border); background: #eef5f1; box-shadow: inset 0 3px 0 var(--accent); }
.analysis-tablist chess-button[type="tab"] > button[aria-selected="true"]::after { content: ""; position: absolute; top: 100%; left: -1px; right: -1px; height: 2px; background: #eef5f1; border: solid var(--panel-border); border-width: 0 1px; }
.analysis-settings:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 0 0 .25rem; padding: 2px 8px; border: 1px solid var(--panel-border); border-radius: 10px 0 10px 10px; background: #eef5f1; font-size: .85rem; }
.analysis-stepper { display: flex; align-items: center; gap: .4rem; }
.analysis-stepper button { width: 36px; min-height: 36px; padding: .2rem; font-size: 1.1rem; }
.analysis-stepper output { min-width: 1.5rem; text-align: center; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .analysis-stepper button { width: 44px; min-height: 44px; } }
.analysis-line { display: flex; align-items: baseline; gap: .75rem; min-height: 2.8rem; box-sizing: border-box; padding: .5rem 0; border-bottom: 1px solid var(--panel-border); }
.analysis-score { flex: 0 0 3.8rem; font-family: "PGN Notation", Georgia, serif; font-size: .95rem; font-weight: 400; font-variant-numeric: tabular-nums; line-height: 1.9; color: var(--accent-dark); white-space: nowrap; }
.analysis-pv { min-width: 0; font-family: "PGN Notation", Georgia, serif; font-size: 1.05rem; line-height: 1.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; font-variant-numeric: tabular-nums; text-align: left; }

.moves {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: .45rem .8rem;
  padding: .3rem .15rem;
  scrollbar-width: thin;
  scrollbar-color: #d5c7a8 transparent;
}
.move-row { display: inline-flex; align-items: baseline; gap: .1rem; margin: 0; }
.move-row > span {
  font-family: "PGN Notation", Georgia, serif;
  font-size: .95rem;
  color: var(--ink);
  margin-right: .25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.moves .move-row button {
  position: relative;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: .25rem .35rem;
  min-height: 40px;
  font-size: 1.15rem;
  font-weight: 450;
  line-height: 1.5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color .15s, color .15s;
}
.moves .move-row button:hover { background: #c9762f0d; color: var(--accent-dark); }
.moves .move-row button[aria-current=true] {
  background: #c9762f18;
  color: var(--accent-dark);
  font-weight: 450;
  box-shadow: inset 0 -2px 0 #c9762f80;
}

@font-face { font-family: "PGN Notation"; src: url("fonts/FreeSerif.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
.notation-token { display: inline-flex; align-items: center; white-space: nowrap; vertical-align: baseline; font-family: "PGN Notation", Georgia, serif; font-size: 1em; line-height: 1; font-weight: 400; }
.notation-san { line-height: 1; }
.notation-piece { font-family: "PGN Notation", Georgia, serif; font-weight: 400; font-size: 1.15em; line-height: 1; display: inline-block; margin-right: .04em;  }
.notation-space { white-space: pre-wrap; }


button.analysis-line { width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--panel-border); border-radius: 0; color: var(--ink); }
button.analysis-line:hover:not(:disabled) { background: #e8ddba50; }
button.analysis-line:disabled { opacity: 1; }

body.pgn-player { padding-right: 6rem; }
@media (max-width: 1024px) {
  body.pgn-player { padding-right: .4rem; }
}

.control-icon { display: grid; place-items: center; }
.control-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; }
.info-panel .player-header { padding-right: 0; margin-bottom: 1rem; }
.info-panel .player-header h1 { font-size: 1.2rem; }


.playback-controls { gap: .5rem; }
.playback-controls button { display: grid; place-items: center; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 10px; transition: background-color .15s, border-color .15s; }
.playback-controls button:not(#play):not(:disabled):hover { background: #f7e8d3; border-color: var(--accent-dark); }
.playback-controls svg { width: 22px; height: 22px; fill: none; stroke: currentColor; }

/* Let the board use the viewport, placing notation below on narrower screens. */
@media (max-width: 1024px) {
  .pgn-layout { grid-template-columns: minmax(0, 1fr); }

}

.info-panel .player-header { padding-bottom: 1rem; border-bottom: 1px solid var(--panel-border); }
.info-panel #game-title { display: flex; align-items: center; gap: .85rem; margin: 0; }
.game-number { display: grid; place-items: center; flex: 0 0 auto; min-width: 48px; height: 48px; box-sizing: border-box; padding: 0 .65rem; border-radius: 14px; background: linear-gradient(145deg, #fffaf0, #f4dfb8); border: 1px solid #d5b987; box-shadow: inset 0 1px 0 #fff, 0 2px 5px #4a3f2b0a; color: var(--accent-dark); font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.game-players { display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.game-player { display: flex; align-items: baseline; gap: .55rem; font-size: 1rem; line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; }
.game-player::before { content: ''; flex: 0 0 .65rem; width: .65rem; height: .65rem; border: 1px solid #8a7f5e; border-radius: 50%; background: #fffaf0; }
.game-player.black::before { background: #4a3f2b; border-color: #4a3f2b; }

@media print {
  .notation-token, .move-row > span { color: #000; }
  .moves .move-row button[aria-current=true] { background: transparent; color: #000; box-shadow: none; }
}

.analysis-pv .notation-number { font-size: .82em; color: var(--muted); }
.analysis-pv .notation-space { word-spacing: .08em; white-space: pre; }
.analysis-line:last-child { border-bottom: 0; }
@media print {
  .analysis-score, .analysis-pv .notation-number { color: #000; }
}

#topic-editor { width: min(760px, 94vw); max-width: 760px; max-height: 88dvh; padding: 1.25rem; color: var(--ink); }
#topic-editor::backdrop { background: #29272060; }
.editor-header, .editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.editor-header h2 { margin-top: 0; }
.editor-header button { font-size: 1.5rem; background: transparent; border: 0; }
.editor-help { font-size: .85rem; line-height: 1.6; color: var(--muted); }
#topic-names { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .5rem; margin: 1rem 0; }
.topic-name { display: flex; gap: .3rem; }
#topic-editor input { min-width: 0; padding: .5rem; border: 1px solid var(--panel-border); border-radius: 7px; background: #fff; }
.topic-name input { width: 100%; }
#topic-assignments { max-height: 280px; overflow: auto; margin: 1rem 0; }
.topic-assignment { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 40%); gap: .5rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--panel-border); font-size: .85rem; }
.topic-assignment span { overflow-wrap: anywhere; }
.topic-assignment select { width: 100%; }
.editor-footer { flex-wrap: wrap; }

.file-tags { display: flex; gap: .35rem; flex-wrap: wrap; }
.file-tag { padding: .2rem .55rem; border-radius: 999px; background: #c9762f12; color: #8a5424; font-size: .75rem; line-height: 1.4; overflow-wrap: anywhere; max-width: 100%; }
.topic-preview { order: -1; display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; aspect-ratio: 1; border: 0; border-radius: 8px; overflow: hidden; margin: 0; }
.preview-square { display: grid; place-items: center; aspect-ratio: 1; }
.preview-square.light { background: var(--square-color-light, #f0d9b5); }
.preview-square.dark { background: var(--square-color-dark, #b58863); }
.preview-piece { width: 100%; height: 100%; background: center / 90% no-repeat; }
.topic-preview.unavailable { display: flex; justify-content: center; align-items: center; padding: 1rem; background: #eee8dc; color: #8a7f5e; font-size: .8rem; }
.preview-piece.white.king { background-image: var(--active-king); }
.preview-piece.white.queen { background-image: var(--active-queen); }
.preview-piece.white.rook { background-image: var(--active-rook); }
.preview-piece.white.bishop { background-image: var(--active-bishop); }
.preview-piece.white.knight { background-image: var(--active-knight); }
.preview-piece.white.pawn { background-image: var(--active-pawn); }
.preview-piece.black.king { background-image: var(--black-king); }
.preview-piece.black.queen { background-image: var(--black-queen); }
.preview-piece.black.rook { background-image: var(--black-rook); }
.preview-piece.black.bishop { background-image: var(--black-bishop); }
.preview-piece.black.knight { background-image: var(--black-knight); }
.preview-piece.black.pawn { background-image: var(--black-pawn); }

.editable-name { cursor: text; }
.editable-name:hover { text-decoration: underline; text-decoration-color: #c9762f50; text-underline-offset: .2em; }
.inline-name { font: inherit; color: inherit; width: 100%; min-width: 0; box-sizing: border-box; border: 0; border-bottom: 2px solid var(--accent, #c9762f); background: #fffaf0; padding: .15em .25em; border-radius: 4px; }
.metadata-tags { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem; margin-top: .5rem; }
.metadata-tag { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; background: #fffaf0d9; color: #8a5424; padding: .2rem .5rem; font-size: .75rem; }
.metadata-tag button, .add-tag { min-height: 26px; min-width: 26px; padding: 0; border: 0; background: transparent; color: inherit; font-size: 1rem; }
.add-tag { border-radius: 50%; color: #8a5424; background: #fffaf080; }
.inline-tag { max-width: 160px; font: inherit; font-size: .85rem; border: 1px solid #d5b987; border-radius: 6px; padding: .35rem .5rem; background: #fff; color: #4a3f2b; }
.topic-open { display: flex; flex-direction: column; align-items: center; gap: .4rem; width: 100%; text-decoration: none; }
.topic-card h2 { font-size: 1.05rem; margin: .25rem 0 0; }
.topic-count { font-size: .8rem; color: #7c765f; }
.topic-card .metadata-tags { margin-top: 0; }

.topic-caption { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; width: 100%; text-align: left; }
.topic-caption h2 { min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.topic-caption .topic-count { white-space: nowrap; flex-shrink: 0; }

.pgn-cards[data-view=topics] { gap: 22px; }
.topic-card {
  align-items: stretch;
  padding: 14px;
  gap: 12px;
  border-radius: 22px;
  border: 1px solid #e1d8c4;
  background: linear-gradient(160deg, #fffdf7, #faf4e8);
  box-shadow: 0 4px 14px #66532b0c, inset 0 1px 0 #fff;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.topic-card:hover { transform: translateY(-3px); border-color: #cfb98d; box-shadow: 0 12px 26px #66532b18; }
.topic-card:focus-within { border-color: #c9762f; }
.topic-open { box-sizing: border-box; padding: 7px; border-radius: 14px; background: #e9dfc9; box-shadow: inset 0 1px 3px #66532b12; }
.topic-open:hover { background: #e1d3b6; }
.topic-open:focus-visible { outline: 3px solid #a45b20; outline-offset: 3px; }
.topic-caption { padding: 0 3px; }
.topic-caption h2 { font-size: 1rem; font-weight: 650; line-height: 1.5; letter-spacing: -.015em; color: #51452f; }
.topic-caption .topic-count { font-size: .72rem; padding: .25rem .55rem; border-radius: 999px; background: #f1e5ce; color: #8a642d; text-decoration: none; }
.topic-caption .topic-count:hover { background: #e9d4ac; }
.topic-card .metadata-tags { justify-content: flex-start; padding: 0 3px; min-height: 28px; }
.topic-card .metadata-tag { background: #efe8da; color: #847252; }
.topic-card .add-tag { color: #b6a483; background: transparent; border: 1px dashed #d6c9af; }
.topic-card .add-tag:hover { color: #a45b20; border-color: #a45b20; }
@media (prefers-reduced-motion: reduce) { .topic-card { transition: none; } .topic-card:hover { transform: none; } }

.lesson-card .topic-caption a { color: inherit; text-decoration: none; }
.lesson-card .topic-caption a:hover { color: #a45b20; }
.lesson-card .topic-count { flex-shrink: 1; min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.lesson-card .topic-count:empty { display: none; }


/* File and topic headers share a compact hierarchy aligned with their cards. */
.picker-header { margin: 8px 0 26px; color: var(--hero-ink); }
.picker-path { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--hero-muted); font-size: .78rem; line-height: 1.5; }
.picker-path a { text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-path a:first-child { flex-shrink: 0; }
.picker-path a:hover { text-decoration: underline; text-underline-offset: 3px; }
.picker-path > span { flex-shrink: 0; }
.picker-path [hidden] { display: none; }
.picker-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin: 16px 0 10px; }
.picker-title-row > chess-button { margin-left: auto; flex-shrink: 0; }
.pgn-browser[data-page="games"] .picker-title-row { width: 100%; box-sizing: border-box; justify-content: space-between; }
.picker-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; min-width: 0; }
.picker-title-row h1 { min-width: 0; max-width: 100%; margin: 0; font-size: clamp(1.8rem, 3.5vw, 2.7rem); line-height: 1.2; letter-spacing: -.035em; overflow-wrap: anywhere; }
.picker-count { margin: 0; padding: 6px 11px; border: 1px solid #ffffff70; border-radius: 999px; background: #fffaf070; color: var(--hero-muted); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.picker-count:empty { display: none; }
.picker-header #heading-tags { justify-content: flex-start; margin: 0; gap: 6px; min-height: 30px; }
.picker-metadata { display: grid; grid-template-columns: 1fr; gap: 3px; color: var(--hero-muted); font-size: .72rem; }
.file-tag-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; color: var(--hero-muted); font-size: .72rem; }
.file-tag-filters[hidden] { display: none; }
.file-tag-filters .metadata-tags { justify-content: flex-start; margin: 0; gap: 6px; }
.file-tag-filter { text-decoration: none; cursor: pointer; }
.file-tag-filter:hover { background: #fffaf0; text-decoration: underline; text-underline-offset: 2px; }
.picker-header .metadata-tag { background: #fffaf0b0; }
.picker-header .add-tag { min-height: 28px; padding: 3px 8px; font-size: .72rem; border: 1px dashed #8d826c60; border-radius: 7px; background: transparent; }
.picker-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #ffffff80; }
.picker-search { display: flex; align-items: center; gap: 10px; width: min(420px, 100%); min-width: 120px; border: 1px solid #d9d4c3; border-radius: 12px; padding: 0 14px; background: #fffaf0d9; color: #8a806a; }
.picker-search svg { width: 19px; height: 19px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.picker-search input[type=search] { width: 100%; min-width: 0; height: 44px; border: 0; padding: 0; background: transparent; font-size: .9rem; }
.picker-search input:focus-visible { outline: none; }
.picker-search:focus-within { outline: 2px solid #a45b20; outline-offset: 2px; }
.picker-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; min-width: 0; }
@media (max-width: 600px) {
  .picker-header { margin-top: 4px; }
  .picker-title-row { gap: 10px; }
  .picker-toolbar { flex-wrap: wrap; gap: 12px; margin-top: 16px; }
  .picker-search { width: 100%; }
  .picker-tools { width: 100%; justify-content: flex-start; }
  .picker-path { gap: 7px; font-size: .72rem; }
}

.picker-description { margin: 0; color: var(--hero-muted); font-size: .85rem; line-height: 1.6; }
.picker-upload, button.picker-upload { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 1px solid #c8b08b; border-radius: 12px; background: #fffaf0d9; color: #76542e; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.picker-upload:hover, button.picker-upload:hover { background: #fffaf0; border-color: #a45b20; }
/* Shared PGN import dialog. */

.info-panel .picker-header { color: var(--ink); margin-top: 0; }
.info-panel .picker-path { padding-right: 0; font-size: .72rem; color: var(--muted); gap: 7px; }
.info-panel .picker-path a:first-child { flex-shrink: 1; }
.info-panel .picker-title-row { margin: 14px 0 0; }
.info-panel .picker-title-row h1 { width: 100%; }
.info-panel .picker-header .metadata-tags { justify-content: flex-start; margin-top: 12px; }
.info-panel .picker-header [hidden] { display: none; }

.pgn-player [hidden] { display: none !important; }
.pgn-player[data-mode=question] .pgn-layout { grid-template-columns: minmax(0, 1fr); }


.pgn-browser[data-page="games"] .picker-metadata { display: grid; grid-template-columns: 1fr; gap: 3px; color: var(--hero-muted); font-size: .72rem; }
.file-mode-setting { display: inline-flex; align-items: center; gap: 8px; color: var(--hero-muted); font-size: .75rem; }
.file-mode-setting[hidden] { display: none; }
.file-mode-setting select { min-height: 34px; padding: 6px 10px; border-color: #d9d4c3; border-radius: 8px; background: #fffaf0a0; }

.picker-tools chess-button { display: inline-block; margin: 0; }
.picker-tools .icon-btn:focus-visible { outline: 3px solid #a45b20; outline-offset: 3px; }
.picker-title-row > .control-group { flex-direction: row; margin-left: auto; flex: 0 0 auto; }
.library-backup-settings { max-width: 620px; padding: 24px; border: 1px solid var(--panel-border); border-radius: 16px; background: var(--panel-bg); color: var(--ink); }
.library-backup-settings h2 { margin: 0 0 8px; font-size: 1.15rem; }
.library-backup-settings > p { line-height: 1.6; }
.library-backup-settings #settings-status { min-height: 1.5em; margin-bottom: 0; }
.library-backup-settings #settings-status[data-error=true] { color: #8c361a; }
.library-backup-settings .backup-controls { margin: 18px 0 0; }
.library-backup-settings .backup-controls button { min-height: 40px; }
.game-settings-dialog { box-sizing: border-box; width: min(420px, calc(100vw - 32px)); margin: auto; padding: 28px; border: 1px solid var(--panel-border); border-radius: 16px; background: var(--panel-bg); color: var(--ink); box-shadow: 0 18px 60px #241b1240; }
.game-settings-dialog::backdrop { background: #1c241acc; }
.game-settings-dialog h2 { margin: 0 34px 20px 0; font-size: 1.2rem; }
.game-settings-dialog label { display: grid; gap: 7px; margin: 14px 0; color: var(--muted); font-size: .8rem; font-weight: 600; }
.game-settings-dialog select { width: 100%; min-height: 42px; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--panel-border); border-radius: 9px; background: #fffdf8; color: var(--ink); font: inherit; }
.game-settings-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.game-settings-close:hover { background: #efe7d9; color: var(--ink); }
.game-settings-export { width: 100%; min-height: 42px; margin-top: 8px; border: 1px solid var(--panel-border); border-radius: 9px; background: #fffaf0; color: var(--ink); font: inherit; font-weight: 650; cursor: pointer; }
.game-settings-export:hover { border-color: var(--accent); color: var(--accent-dark); }

.pgn-player .pgn-layout { grid-template-columns: minmax(0, var(--chess-board-size, calc(100dvh - 48px))) 380px; justify-content: center; }
.pgn-player[data-mode=question] .pgn-layout { grid-template-columns: minmax(0, var(--chess-board-size, calc(100dvh - 48px))); }
.info-panel .playback-controls { justify-content: center; flex-wrap: nowrap; gap: 4px; margin: 0 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--panel-border); }
.info-panel .playback-controls button { width: 36px; height: 38px; min-height: 38px; flex: 1; }
@media (max-width: 1024px) { .pgn-player .pgn-layout { grid-template-columns: minmax(0, var(--chess-board-size, 100%)); } }

.opening-book { margin: 8px 0; padding: 8px 0; border-bottom: 1px solid var(--panel-border); }
.opening-book summary { font-size: .8rem; font-weight: 500; line-height: 1.5; padding: 0; color: var(--muted); }
.book-moves { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.book-moves button { min-height: 32px; padding: 3px 8px; font-family: "PGN Notation", Georgia, serif; font-size: 1.05rem; }

.favorite-badge { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #fffaf0; color: var(--favorite-accent, #ac6627); font-size: 23px; line-height: 1; box-shadow: 0 1px 6px #51452f20; pointer-events: none; }
[data-favorite=featured] > .favorite-badge { background: var(--favorite-accent, #ac6627); color: #fffaf0; }
.file-card [data-favorite]:not([data-favorite=none]) h2 { padding-right: 34px; }

.playback-controls #engine-toggle[aria-pressed=true] { background: #d4eacc; border-color: #7b9a6e; }

/* PGN collection cards and their compact list layout. */
.pgn-browser .pgn-cards { gap: 18px; align-items: stretch; }
.pgn-browser .pgn-card, .pgn-browser .file-card {
  border: 1px solid #ded5c5;
  border-radius: 18px;
  background: #fffdf7;
  box-shadow: 0 3px 10px #51452f08;
  transition: border-color .18s, box-shadow .18s, transform .18s;
}
.pgn-browser .pgn-card { padding: 22px; min-height: 174px; justify-content: flex-start; gap: 12px; text-align: left; }
.pgn-browser .pgn-card:hover, .pgn-browser .file-card:hover { transform: translateY(-2px); border-color: #c9ae86; box-shadow: 0 8px 22px #51452f12; }
.pgn-browser .pgn-card h2 { margin: 0; font-size: 1.12rem; line-height: 1.45; letter-spacing: -.02em; color: #4a3f2b; }
.pgn-browser .pgn-card p { font-size: .78rem; line-height: 1.65; color: #8b7d66; }
.pgn-card-kind { color: #a36c36; font-size: .65rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.pgn-browser .pgn-card .card-arrow { right: 18px; bottom: 18px; width: 26px; height: 26px; background: transparent; color: #aa8b61; }
.pgn-browser .pgn-card:not(.topic-card) { padding-right: 52px; }
.pgn-browser .file-card { display: flex; flex-direction: column; overflow: hidden; }
.pgn-browser .file-card .pgn-card { height: auto; flex: 1; min-height: 150px; border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 22px 50px 18px 22px; }
.pgn-browser .file-card .pgn-card:hover { transform: none; }
.pgn-browser .file-card .card-arrow { top: 20px; bottom: auto; }
.pgn-card-footer { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 12px; margin: 0 18px; padding: 12px 0; border-top: 1px solid #ece5d7; }
.pgn-card-count { font-size: .73rem; font-weight: 600; color: #8a7758; }
.pgn-card-actions { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.pgn-card-actions chess-button { position: static; flex-shrink: 0; margin: 0; }
.pgn-browser .pgn-card-actions .delete-file { position: static; }
.pgn-browser .file-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.pgn-browser .file-tag { border: 1px solid #e7dfd0; background: #f7f2e8; padding: 3px 8px; border-radius: 6px; color: #8b7657; font-size: .68rem; }
.pgn-browser .topic-card { padding: 12px; gap: 14px; }
.pgn-browser .topic-open { padding: 10px; border-radius: 10px; background: #f0e9da; box-shadow: none; }
.pgn-browser .topic-open:hover { background: #e9dec9; }
.pgn-browser .topic-preview { max-width: 220px; margin: auto; border-radius: 4px; box-shadow: 0 2px 8px #51452f12; }
.pgn-browser .topic-caption { padding: 0 5px; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.pgn-browser .topic-caption h2 { white-space: normal; overflow: visible; min-width: 120px; font-size: 1rem; line-height: 1.5; }
.pgn-browser .topic-caption .topic-count { background: #f4eddf; color: #9a7647; font-size: .68rem; padding: 4px 8px; }
.pgn-browser .lesson-card .topic-caption { flex-direction: column; }
.pgn-browser .lesson-card .topic-count { max-width: 100%; white-space: normal; background: transparent; padding: 0; }
.pgn-browser .topic-card .metadata-tags { padding: 0 5px; gap: 5px; }
.pgn-browser .favorite-badge { top: 20px; right: 20px; width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 2px 6px #51452f15; background: #fffdf7; }
.favorite-badge svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pgn-browser [data-favorite=featured] > .favorite-badge { background: #c9762f; color: #fffaf0; }
.pgn-browser .pgn-cards[data-layout=list] { grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (max-width: 600px) {
  .pgn-browser .pgn-cards { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .pgn-browser .pgn-card, .pgn-browser .file-card { transition: none; }
  .pgn-browser .pgn-card:hover, .pgn-browser .file-card:hover { transform: none; }
}

/* Game tiles: edge-to-edge square boards beside the game details. */
.pgn-browser .pgn-cards:has(.pgn-game-tile) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pgn-browser .pgn-game-tile { --game-preview-size: 200px; display: grid; grid-template-columns: var(--game-preview-size) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: var(--game-preview-size); min-height: 0; padding: 0; gap: 0; overflow: hidden; align-items: stretch; }
.pgn-browser .pgn-game-tile .topic-open { grid-row: 1; height: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.pgn-browser .pgn-game-tile .topic-open:hover { background: transparent; }
.pgn-browser .pgn-game-tile .topic-preview { width: 100%; height: 100%; min-height: 0; flex-shrink: 0; grid-template-rows: repeat(8, minmax(0, 1fr)); max-width: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.pgn-browser .pgn-game-tile .topic-caption { box-sizing: border-box; min-width: 0; min-height: 0; gap: 6px; padding: 14px 16px; align-items: stretch; flex-wrap: nowrap; }
.pgn-browser .pgn-game-tile .topic-caption > * { flex: none; }
.pgn-game-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pgn-game-result { font-size: .7rem; font-weight: 650; font-variant-numeric: tabular-nums; color: #846744; padding: 3px 8px; border: 1px solid #e6dbc8; border-radius: 6px; background: #f8f2e8; }
.pgn-browser .pgn-game-tile .topic-caption h2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 1rem; line-height: 1.45; }
.pgn-browser .pgn-game-tile .topic-count { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9c8a71; font-size: .71rem; line-height: 1.6; }
.pgn-game-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 9px; border-top: 1px solid #eee5d5; }
.pgn-game-actions chess-button { flex: none; margin: 0; }
@media (max-width: 1024px) {
  .pgn-browser .pgn-cards:has(.pgn-game-tile) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .pgn-browser .pgn-game-tile { --game-preview-size: 160px; }
  .pgn-browser .pgn-game-tile .topic-caption { padding: 12px; gap: 5px; }
  .pgn-browser .pgn-game-tile .topic-caption h2 { font-size: .88rem; }
}

.pgn-browser .pgn-game-tile .pgn-game-opening { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, monospace; font-size: .64rem; line-height: 1.6; color: #a38155; }
.pgn-game-tile .preview-last-move { box-shadow: inset 0 0 0 100px #dfb93655; }
@media (max-width: 600px) {
  .pgn-browser .pgn-cards[data-layout=cards] .pgn-game-tile .topic-caption { padding: 10px; gap: 3px; }
  .pgn-browser .pgn-cards[data-layout=cards] .pgn-game-tile .topic-caption h2 { line-height: 1.35; }
}

/* Topic lists emphasize names and counts, with no board preview. */
}

.pgn-shell { --board-side-reserve: 396px; } /* sidebar width (380px) + grid gap (1rem) */
@media (max-width: 1024px) { .pgn-shell { --board-side-reserve: 0px; } }

.pgn-variations { margin: 8px 0 14px; padding: 10px 0; border-bottom: 1px solid var(--panel-border); }
.pgn-variations > p { margin: 0 0 8px; font-size: .8rem; font-weight: 600; }
#variation-list { display: flex; flex-direction: column; gap: 5px; max-height: 180px; overflow-y: auto; margin-top: 8px; }
#variation-list button { text-align: left; min-height: 34px; padding: 6px 8px; font-family: "PGN Notation", Georgia, serif; line-height: 1.5; overflow-wrap: anywhere; }
#variation-list button[aria-pressed=true] { background: #d4eacc; border-color: #7b9a6e; }
#variation-list button:disabled { opacity: .65; }
#move-pages { align-items: center; gap: 6px; margin-bottom: 8px; font-size: .7rem; }
#move-pages button, .pgn-variations .controls button, #return-recorded-main { min-height: 32px; padding: 5px 8px; font-size: .72rem; }
#move-page-label { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Recorded PGN drawings are separate from temporary hints and manual annotations. */
.pgn-square--green { background: #32a85255; }
.pgn-square--red { background: #e1494955; }
.pgn-square--blue { background: #357bd955; }
.pgn-square--yellow { background: #e6bd2355; }
.move-row:has(.inline-variations) { display: grid; grid-template-columns: max-content max-content max-content; flex-basis: 100%; gap: 2px 4px; }
.inline-variations { grid-column: 1 / -1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; padding: 4px 0 5px 14px; border-left: 2px solid var(--panel-border); font-size: .72rem; color: var(--muted); }
.moves .inline-variations button { font-size: .9rem; padding: 3px 7px; border: 1px solid var(--panel-border); border-radius: 5px; }
.player-status { margin: 6px 0; padding: 8px 10px; border-radius: 10px; font-size: .82rem; color: #8c361a; background: #fffaf0; border: 1px solid #efd0be; }
.recorded-data { margin: 5px 0; font-size: .76rem; color: var(--muted); }
.study-settings, .backup-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin: 14px 0; font-size: .76rem; }
.study-settings label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.study-settings select, .study-settings button, .backup-controls button { min-height: 36px; padding: 6px 10px; font: inherit; }
.backup-controls span { color: var(--muted); }
.backup-upload { position: relative; display: inline-flex; align-items: center; padding: 8px 12px; min-height: 36px; box-sizing: border-box; border: 1px solid var(--panel-border); border-radius: 8px; cursor: pointer; background: #fffaf0; }
.backup-upload input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.backup-upload:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.study-badge { font-size: .62rem; color: #91744e; border: 1px solid #e6dbc8; padding: 3px 5px; border-radius: 5px; white-space: nowrap; }
.study-badge[data-state=solved] { background: #e2efdb; color: #416940; }
.study-badge[data-state=review] { background: #fff0cf; color: #926120; }
.pgn-game-meta { flex-wrap: wrap; }
.study-edit-controls { flex-wrap: wrap; justify-content: center; gap: 5px; margin: 10px 0; }
.study-edit-controls button { min-height: 32px; padding: 4px 7px; font-size: .72rem; }
#study-editor { box-sizing: border-box; width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; border: 1px solid var(--panel-border); border-radius: 14px; background: var(--panel, #fffaf0); color: var(--ink); padding: 20px; }
#study-editor::backdrop { background: #0007; }
#study-editor h2 { font-size: 1.1rem; margin: 0 0 15px; }
#study-editor label { display: block; font-size: .8rem; margin-bottom: 6px; }
#study-editor textarea { box-sizing: border-box; width: 100%; max-height: 50dvh; min-height: 160px; padding: 10px; border: 1px solid var(--panel-border); border-radius: 8px; font: .8rem/1.6 ui-monospace, monospace; resize: vertical; }
#study-editor-help, #study-editor-status { font-size: .76rem; line-height: 1.5; }
#study-editor-status { color: #9a442b; }
@media (max-width: 600px) { .study-settings label, .study-settings select { max-width: 100%; } }
/* Keep notation above decorative theme scenery on narrow screens. */
.pgn-player .info-panel { position: relative; z-index: 1; }

/* File and topic export controls stay outside their navigation links. */
@media(max-width:600px) { .pgn-card-actions { gap:4px; } }

.pgn-card-footer { flex-wrap:wrap; }

/* Game selection exists only in the list view of game rows. */
.selection-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; min-height: 40px; margin: 0 0 4px; padding: 0 14px; }
.selection-bar[hidden], .selection-actions[hidden] { display: none; }
.selection-bar .control-group { flex-direction: row; }
.selection-count { font-size: .8rem; color: #846744; }
.selection-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.selection-topic-assignment { display: flex; align-items: center; gap: 8px; }
.selection-topic-assignment[hidden] { display: none; }
.selection-topic { width: 200px; max-width: 100%; padding: 6px 10px; border: 1px solid #e0d4bd; border-radius: 8px; background: #fffdf8; font: inherit; font-size: .8rem; }
.pgn-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: .9rem; }
.pgn-table caption, .pgn-table-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pgn-table th { padding: 0 12px 2px; text-align: left; font-size: .7rem; font-weight: 650; letter-spacing: .03em; color: var(--hero-muted); white-space: nowrap; }
.pgn-table th button { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.pgn-table th button:hover, .pgn-table th button:focus-visible { color: var(--hero-ink); }
.pgn-table th[aria-sort=ascending], .pgn-table th[aria-sort=descending] { color: var(--hero-ink); }
.pgn-table .sort-mark { font-size: .55rem; }
.pgn-table td { padding: 8px 12px; background: #fffdf8; border-block: 1px solid #ece5d7; vertical-align: middle; }
.pgn-table td:first-child { border-left: 1px solid #ece5d7; border-radius: 10px 0 0 10px; }
.pgn-table td:last-child { border-right: 1px solid #ece5d7; border-radius: 0 10px 10px 0; }
.pgn-table tbody tr:hover td { background: #fff8ec; }
.pgn-table input[type=checkbox] { display: block; width: 18px; height: 18px; margin: 0; accent-color: #a45b20; cursor: pointer; }
.pgn-table .col-select { width: 18px; }
.pgn-table .col-number { width: 36px; color: #a3875f; font-variant-numeric: tabular-nums; }
.pgn-table .col-title, .pgn-table .col-name { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.pgn-table .col-title a, .pgn-table .col-name a { color: inherit; text-decoration: none; }
.pgn-table .col-title a:hover, .pgn-table .col-name a:hover { color: #a45b20; text-decoration: underline; }
.pgn-table .col-white, .pgn-table .col-black, .pgn-table .col-date { color: #6f5d45; white-space: nowrap; }
.pgn-table .pgn-game-result { white-space: nowrap; }
.pgn-table .row-sub { display: none; }
.pgn-table .row-note { display: block; font-size: .72rem; font-weight: 400; color: #9c8a71; }
.pgn-table .row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.pgn-table .row-tags:empty { display: none; }
.pgn-table .col-favorite { width: 36px; }
.pgn-table .col-count, .pgn-table .col-imported { color: #6f5d45; white-space: nowrap; }
.pgn-table .col-actions .pgn-game-actions, .pgn-table td .pgn-game-actions { display: flex; justify-content: flex-end; gap: 6px; margin: 0; padding: 0; border: 0; }
@media (max-width: 1024px) {
  .pgn-table .col-number, .pgn-table .col-white, .pgn-table .col-black, .pgn-table .col-date, .pgn-table .col-status,
  .pgn-table .position-edit-link { display: none; }
  .pgn-table th, .pgn-table td { padding-inline: 6px; }
  .pgn-table { font-size: .85rem; }
  .pgn-table .row-sub { display: block; font-weight: 400; font-size: .75rem; color: #9c8a71; overflow: hidden; text-overflow: ellipsis; }
  .pgn-table .col-title, .pgn-table .col-name { white-space: normal; }
  .pgn-table .col-count, .pgn-table .col-imported { display: none; }
  .selection-bar:not(:has(.selection-actions:not([hidden]))) { display: none; }
  .selection-actions { width: 100%; flex-wrap: nowrap; }
  .selection-actions .control-group { flex: none; }
  .selection-topic { flex: 1 1 0; min-width: 0; width: auto; }
}
.pgn-table chess-button { position: static; flex-shrink: 0; margin: 0; }
.pgn-table tbody tr[data-href] { cursor: pointer; }
.pgn-table .col-name h2 { margin: 0; font-size: .92rem; line-height: 1.35; }
.pgn-table .col-name .metadata-tags { margin: 0; padding: 0; min-height: 0; justify-content: flex-start; }
.pgn-table .col-count .pgn-game-result { text-decoration: none; }
.pgn-table .row-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.pgn-table .row-main:has(.row-favorite:empty) .row-favorite { display: none; }
.pgn-table .favorite-badge { position: static; width: 22px; height: 22px; }
.pgn-game-tile .metadata-tags { justify-content: flex-start; min-height: 0; padding: 0; margin: 0; }
.pgn-game-tile .pgn-game-meta .pgn-game-result { text-decoration: none; }
.pgn-table .add-tag { min-height: 0; width: auto; padding: 0 8px; line-height: 1.5; font-size: .75rem; }
.pgn-table .metadata-tag { font-size: .7rem; }

.question-analysis-panel { display: contents; }
.library-analysis-progress { position: fixed; z-index: 100; inset: 0 0 auto; background: #fffdf8f5; box-shadow: 0 2px 10px #263d2012; }
.library-analysis-progress[hidden] { display: none; }
.library-analysis-progress-content { display: flex; align-items: center; gap: 12px; min-height: 32px; padding: 2px 16px; }
.library-analysis-progress-content > span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .73rem; color: #657254; }
.library-analysis-progress-content button { flex: none; border: 0; background: transparent; color: #7c755f; padding: 5px 8px; font: inherit; font-size: .73rem; cursor: pointer; }
.library-analysis-progress progress { display: block; width: 100%; height: 3px; border: 0; appearance: none; background: #e9eedf; accent-color: #7a925a; }
.library-analysis-progress progress::-webkit-progress-bar { background: #e9eedf; }
.library-analysis-progress progress::-webkit-progress-value { background: #7a925a; transition: width .2s ease; }
.library-analysis-progress progress::-moz-progress-bar { background: #7a925a; }
.library-analysis-dialog { box-sizing: border-box; width: min(440px,calc(100vw - 32px)); max-height: 90dvh; overflow-y: auto; margin: auto; padding: 26px; border: 1px solid #e1dacd; border-radius: 18px; background: #fffdf8; color: #293a32; box-shadow: 0 24px 90px #17251d33; }
.library-analysis-dialog::backdrop { background: #19251f80; backdrop-filter: blur(4px); }
.library-analysis-dialog h2 { font-size: 1.2rem; margin: 0 0 14px; letter-spacing: -.025em; }
.library-analysis-dialog p { font-size: .85rem; line-height: 1.7; margin: 10px 0; }
.library-analysis-dialog .library-analysis-note { color: #8c806c; font-size: .78rem; }
.library-analysis-confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.library-analysis-dialog button:focus-visible, .library-analysis-progress button:focus-visible { outline: 2px solid #a97a3e; outline-offset: 2px; }
.question-analysis-panel .question-tag-dialog { box-sizing: border-box; width: min(720px,calc(100vw - 32px)); max-height: min(860px,90dvh); overflow: hidden; border: 1px solid #e1dacd; border-radius: 22px; padding: 0; background: #fffdf8; color: #293a32; box-shadow: 0 24px 90px #17251d33; }
.question-tag-dialog[open] { display: flex; flex-direction: column; }
.question-tag-dialog::backdrop { background: #19251f80; backdrop-filter: blur(4px); }
.tag-dialog-header { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 26px 28px 20px; border-bottom: 1px solid #ebe6db; }
.tag-dialog-eyebrow { font-size: .65rem; font-weight: 700; letter-spacing: .14em; color: #9a8260; }
.question-analysis-panel .tag-dialog-header h2 { margin: 5px 0; font-size: 1.6rem; letter-spacing: -.035em; }
.question-analysis-panel .tag-dialog-header p { margin: 0; color: #817769; font-size: .85rem; overflow-wrap: anywhere; }
.tag-dialog-close { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 8px; border: 1px solid #e9e2d5; border-radius: 50%; background: transparent; color: #807363; cursor: pointer; }
.tag-dialog-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.tag-dialog-close:hover { background: #f1ecdf; color: #293a32; }
.tag-dialog-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 28px 26px; }
.tag-analysis-summary { padding: 14px 16px; border: 1px solid #e4e9df; border-radius: 12px; background: #f3f6ef; }
.tag-analysis-state { display: inline-flex; align-items: center; gap: 7px; color: #4c6947; font-size: .76rem; font-weight: 700; }
.tag-analysis-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-analysis-state[data-state=stale], .tag-analysis-state[data-state=imported] { color: #9a6b2d; }
.tag-analysis-state[data-state=none] { color: #80786c; }
.question-analysis-panel .tag-analysis-summary p { margin: 6px 0 0; font-size: .8rem; line-height: 1.6; color: #72786a; }
.tag-dialog-section { margin-top: 24px; }
.tag-section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem; margin-bottom: 12px; }
.tag-section-heading h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .9rem; font-weight: 650; }
.tag-section-heading > span { font-size: .7rem; color: #948879; }
.tag-section-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding-inline: 3px; box-sizing: border-box; border-radius: 6px; background: #eee9de; color: #877358; font-size: .7rem; font-variant-numeric: tabular-nums; }
.tag-saved-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-saved-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 6px 6px 12px; border: 1px solid #dce5d7; border-radius: 9px; background: #eff4e9; color: #4b6342; font-size: .8rem; font-weight: 600; max-width: 100%; box-sizing: border-box; }
.tag-saved-chip > span { overflow-wrap: anywhere; min-width: 0; }
.tag-saved-chip.is-manual { background: #f7efe2; border-color: #eadbc3; color: #8c6537; }
.tag-chip-remove { display: grid; place-items: center; flex: none; width: 27px; height: 27px; border: 0; border-radius: 6px; padding: 0; background: transparent; color: inherit; font: inherit; font-size: 1.2rem; cursor: pointer; }
.tag-chip-remove:hover { background: #263c2112; }
.tag-suggestion-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.tag-suggestion { min-width: 0; display: flex; flex-direction: column; padding: 15px; border: 1px solid #e8e1d4; border-radius: 12px; background: #fffefa; }
.tag-suggestion-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.tag-suggestion h4 { font-size: .85rem; margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.tag-category { font-size: .65rem; color: #9c8b73; }
.question-analysis-panel .tag-suggestion p { font-size: .76rem; line-height: 1.65; color: #847968; margin: 8px 0 12px; overflow-wrap: anywhere; }
.tag-suggestion details { margin-bottom: 12px; font-size: .72rem; color: #89775d; }
.tag-suggestion summary { cursor: pointer; }
.tag-suggestion ul { padding-left: 18px; line-height: 1.8; overflow-wrap: anywhere; }
.tag-suggestion-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.tag-suggestion-actions button { padding: 7px 10px; border-radius: 7px; font: inherit; font-size: .73rem; font-weight: 600; cursor: pointer; }
.tag-accept { background: #f0f3e9; border: 1px solid #dce3ce; color: #53683f; }
.tag-accept:hover { background: #e5edd9; }
.tag-dismiss { background: transparent; border: 1px solid transparent; color: #9b8c77; }
.tag-dismiss:hover { background: #f3eee5; }
.question-analysis-panel .tag-empty { grid-column: 1 / -1; width: 100%; margin: 0; padding: 18px; box-sizing: border-box; border: 1px dashed #e3dbce; border-radius: 10px; color: #9b8d78; font-size: .78rem; line-height: 1.6; }
.tag-dialog-footer { flex: none; padding: 18px 28px; border-top: 1px solid #e9e1d4; background: #faf7ef; }
.tag-dialog-footer > label { display: block; margin-bottom: 8px; font-size: .78rem; font-weight: 650; }
.tag-input-row { display: flex; gap: 8px; }
.tag-input-row input { box-sizing: border-box; min-width: 0; flex: 1; width: auto; margin: 0; padding: 11px 13px; border: 1px solid #e0d6c5; border-radius: 9px; background: #fffdf8; font: inherit; font-size: .82rem; color: #4e493d; }
.question-analysis-panel .tag-add-button { flex: none; display: flex; align-items: center; gap: 6px; padding: 9px 17px; border: 1px solid #506343; border-radius: 9px; background: #506343; color: #fffdf8; font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer; }
.tag-add-button span { font-size: 1.2rem; font-weight: 400; }
.question-analysis-panel .tag-add-button:hover { background: #405436; }
.question-analysis-panel #question-tag-status { margin: 6px 0 0; min-height: 1em; font-size: .72rem; color: #7a806d; }
.question-tag-dialog :is(button,input,summary):focus-visible { outline: 2px solid #a97a3e; outline-offset: 3px; }
@media (max-width: 600px) {
  .question-analysis-panel .question-tag-dialog { width: calc(100vw - 20px); max-height: 94dvh; border-radius: 16px; }
  .tag-dialog-header, .tag-dialog-body, .tag-dialog-footer { padding: 18px; }
  .tag-suggestion-list { grid-template-columns: minmax(0,1fr); }
  .tag-section-heading { align-items: flex-start; flex-direction: column; }
}
.question-tag-badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.analysis-pending { color: #875b18; }

/* Breadcrumb links keep the 24px minimum on every pointer. */
.picker-path a { display: inline-flex; align-items: center; min-height: 24px; }
/* Touch targets (pointer: coarse): breadcrumb links, the player toolbars and the backup controls. */
@media (pointer: coarse) {
  .picker-path a { min-height: 44px; }
  .analysis-toggle, .analysis-toolbar button, .game-settings-close { width: 44px; height: 44px; min-height: 44px; }
  .info-panel .playback-controls button { min-width: 44px; height: 44px; min-height: 44px; }
  .study-edit-controls { gap: 0; }
  .library-backup-settings button, .library-backup-settings input[type=file], #export-backup, #restore-backup { min-height: 44px; }
}

/* Desktop: the sidebar is as tall as the board; the move list takes the free space and scrolls inside it. */
@media (min-width: 1025px) {
  .pgn-player:not([data-mode=question]) .info-panel { display: flex; flex-direction: column; box-sizing: border-box; height: var(--chess-board-size, calc(100dvh - 48px)); overflow-y: auto; }
  .pgn-player .info-panel > * { flex: none; }
  .pgn-player .info-panel > #moves { flex: 1 1 auto; min-height: 6rem; }
}
@media (max-width: 1024px) { .moves { max-height: 240px; } }
