:root { --theory-header-height: 70px; }
.theory-sequence { min-width: 0; }
.theory-status { font-size: 13px; color: #111111; line-height: 1.6; }
.theory-toc {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: #f5f9f5;
}
.theory-toc summary, .theory-catalog > summary, .theory-note > summary {
  min-height: 42px;
  padding: 11px 12px;
  color: #111111;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.theory-toc-links {
  margin: 0;
  padding: 0 12px 10px 30px;
  max-height: min(295px, 48vh);
  overflow-y: auto;
}
.theory-toc-links button, .theory-entry {
  text-align: left;
  white-space: normal;
  min-height: 40px;
  line-height: 1.45;
}
.theory-unit {
  padding: 18px 0 8px;
  scroll-margin-top: calc(var(--theory-header-height) + 88px);
  min-width: 0;
}
.theory-unit + .theory-unit { border-top: 1px solid var(--line); margin-top: 16px; }
.theory-unit-title { margin: 0 0 10px; color: #111111; font-size: 20px; line-height: 1.45; }
.theory-unit-title:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; }
.theory-text { line-height: 1.76; font-size: 15px; color: #111111; overflow-wrap: anywhere; }
.theory-text h1, .theory-text h2, .theory-text h3, .theory-text h4 {
  line-height: 1.4;
  color: #111111;
  margin: 23px 0 8px;
}
.theory-text h1, .theory-text h2 { font-size: 18px; }
.theory-text p { margin: 6px 0; color: inherit; font-size: inherit; line-height: inherit; white-space: normal; }
.theory-text img { max-width: 100%; height: auto; }
.theory-text [data-indent="1"] { margin-inline-start: .7em; }
.theory-text [data-indent="2"] { margin-inline-start: 1.4em; }
.theory-text [data-indent="3"], .theory-text [data-indent="4"] { margin-inline-start: 2em; }
.theory-table-scroll { max-width: 100%; overflow: auto; margin: 14px 0; }
.theory-text table { border-collapse: collapse; min-width: 100%; font-size: 13px; }
.theory-text td, .theory-text th { padding: 5px 8px; border: 1px solid #dde6de; vertical-align: top; }
.theory-text td p { margin: 2px 0; }
.theory-note {
  margin-bottom: 13px;
  padding: 0 9px;
  background-color: #f5f9f5;
  border-radius: 8px;
}
.theory-note > summary { padding-inline: 2px; color: #111111; font-size: 13px; }
.theory-note textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 1px solid #dae7db;
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fcfdf9;
  font: inherit;
  font-size: 16px;
}
.theory-note-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  min-height: 36px;
}
.theory-note-status { font-size: 12px; color: #111111; }
.theory-note-controls button { min-height: 38px; }
.theory-catalog { margin-top: 16px; padding: 0 12px; }
.theory-catalog > summary { padding-inline: 0; }
.theory-catalog-search { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 9px; }
.theory-catalog-search label { font-size: 13px; font-weight: 700; }
.theory-catalog-search input {
  width: min(100%, 260px);
  border: 1px solid #dbe3dc;
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.theory-catalog-tree { max-height: 275px; overflow: auto; padding: 6px 0 10px; }
.theory-folder { margin: 3px 0; padding-left: 9px; }
.theory-folder summary { padding: 7px 0; font-size: 14px; font-weight: 650; cursor: pointer; }
.theory-entry { display: block; }
.theory-dialog { width: min(900px, calc(100vw - 24px)); max-height: 86dvh; }
.theory-dialog .theory-unit { scroll-margin-top: 10px; }
.theory-related-button { margin-top: 14px; }
.question-nav .theory-return {
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: #111111;
}
@media(max-width: 700px){
  :root { --theory-header-height: 62px; }
}

.wrong-shuffle{padding:20px}
.theory-nav>label{display:block;margin-bottom:8px;font-weight:700}
.theory-nav input[type=search]{width:100%;box-sizing:border-box;padding:9px 11px;border:1px solid #d0dcd1;border-radius:8px;background:#fcfdf9;color:#111111}
.theory-status,.theory-location{font-size:13px;color:#111111;line-height:1.6}
.theory-folder{margin:8px 0;padding-left:12px;border-left:1px solid #e1ece2}
.theory-folder summary{cursor:pointer;padding:5px 1px;font-weight:650;color:#111111}
.theory-entry{display:block;width:100%;text-align:left;padding:7px 9px;background:none;border:0;border-radius:6px;color:#111111;cursor:pointer;font:inherit;font-size:13px}
.theory-entry:hover,.theory-entry[aria-current=true]{background:#f5f9f5;color:#111111}
.theory-article-head{padding-bottom:14px;border-bottom:1px solid #e4eae4;margin-bottom:16px}
.theory-article-head h2{margin:0 0 12px;color:#111111;font-size:24px}
.theory-article-head h2:focus{outline:none}
.theory-text{line-height:1.75;font-size:15px;color:#111111;overflow-wrap:anywhere}
.theory-text h1,.theory-text h2,.theory-text h3,.theory-text h4{line-height:1.4;color:#111111;margin:23px 0 8px}
.theory-text h1,.theory-text h2{font-size:20px}
.theory-text p{margin:6px 0}
.theory-text img{max-width:100%;height:auto}
.theory-text [data-indent="1"]{margin-inline-start:.7em}
.theory-text [data-indent="2"]{margin-inline-start:1.4em}
.theory-text [data-indent="3"],.theory-text [data-indent="4"]{margin-inline-start:2em}
.theory-table-scroll{max-width:100%;overflow:auto;margin:14px 0}
.theory-text table{border-collapse:collapse;min-width:100%;font-size:13px}
.theory-text td,.theory-text th{padding:5px 8px;border:1px solid #dde6de;vertical-align:top}
.theory-text td p{margin:2px 0}
.theory-dialog{width:min(900px,calc(100vw - 24px));max-height:86dvh}
.theory-dialog-links{display:flex;flex-wrap:wrap;gap:6px;padding-bottom:14px}
.theory-dialog-links p{width:100%;margin:0}
.theory-dialog-links button[aria-pressed=true]{background:#f5f9f5;color:#111111}
.theory-related-button{margin-top:14px}
.wrong-shuffle{margin:0 0 16px}
.wrong-shuffle h2{margin:0;font-size:18px}
.wrong-shuffle p{margin:6px 0;color:#111111;font-size:13px}
.wrong-shuffle fieldset{min-width:0;border:1px solid #e4eae4;border-radius:8px;margin:12px 0;padding:8px 12px}
.wrong-shuffle legend{font-weight:650;padding:0 5px}
.wrong-filter-grid{display:flex;gap:7px 14px;flex-wrap:wrap;max-height:150px;overflow:auto}
.wrong-filter-choice{display:flex;align-items:center;gap:5px;font-size:13px;padding:4px 0;cursor:pointer}
.wrong-shuffle-controls{display:flex;flex-wrap:wrap;align-items:center;gap:10px 15px;font-size:13px}
.wrong-shuffle-controls input,.wrong-shuffle-controls select{padding:5px 8px;border:1px solid #d0dcd1;border-radius:6px;background:#fcfdf9;color:#111111}
.wrong-shuffle-controls input{width:6ch}
@media(max-width:760px){.wrong-shuffle{padding:14px}}

.theory-text {
  position: relative;
  display: flow-root;
  font-size: clamp(16px,2.25vw,19px);
}
.theory-unit-title { font-size: clamp(18px,2.5vw,25px); }
.theory-mark-toolbar {
  position: sticky;
  top: calc(var(--theory-header-height) + 60px);
  z-index: 3;
  min-width: 0;
  padding: 6px 0;
  background: #fcfdf9;
  border-bottom: 1px solid var(--line);
}
.theory-mark-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.theory-mark-controls button { min-height: 42px; padding: 5px 9px; font-size: 13px; }
.theory-mark-controls .mark-tool[aria-pressed="true"] { background: var(--soft); color: #111111; border-color: #d6e5d7; }
.theory-mark-controls .mark-history { min-width: 34px; padding-inline: 5px; font-size: 17px; line-height: 1; }
.theory-mark-feedback { display: flex; align-items: center; gap: 6px; height: 24px; }
.theory-mark-feedback button { flex: none; padding: 0 4px; font-size: 12px; }
.theory-mark-status {
  min-width: 0;
  overflow: hidden;
  color: #111111;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.theory-mark-layer, .theory-ink-layer, .theory-mark-boxes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.theory-mark-layer { z-index: 1; }
.theory-ink-layer { width: 100%; height: 100%; }
.theory-ink-stroke {
  stroke-linejoin: round;
  stroke-linecap: round;
}
.theory-text-mark {
  position: absolute;
  width: max-content;
  box-sizing: border-box;
  background: transparent;
  border-radius: 5px;
  color: #203783;
  font-size: 14px;
  line-height: 1.52;
}
.theory-mark-label, .theory-text-mark textarea {
  padding: 3px 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.theory-text-mark textarea { display: none; }
.theory-text-mark[data-box-style="outline"] { box-shadow: inset 0 0 0 1px #8792bd; }
[data-mark-tool="text"] .theory-text-mark { pointer-events: auto; }
[data-mark-tool="text"] .theory-text-mark[data-selected="true"] { outline: 2px solid #655bb8; }
[data-mark-tool="text"][data-text-moving] .theory-text-mark { cursor: grab; touch-action: none; user-select: none; }
[data-mark-tool="text"][data-text-moving] .theory-text-mark:active { cursor: grabbing; }
[data-mark-tool="text"]:not([data-text-moving]) .theory-text-mark textarea {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  margin: 0;
  outline-offset: 2px;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: max(16px,1em);
  text-align: inherit;
}
[data-mark-tool="text"]:not([data-text-moving]) .theory-mark-label {
  visibility: hidden;
  font-size: max(16px,1em);
}
[data-mark-tool="text"]:not([data-text-moving]) .theory-mark-label::after { content: '\200b'; }
[data-mark-tool="text"]:not([data-text-moving]) [data-empty="true"] .theory-mark-label::after { content: attr(data-placeholder); }
[data-mark-tool="text"] .theory-text { cursor: crosshair; }
:is([data-mark-tool="ink"],[data-mark-tool="erase"]) .theory-text {
  touch-action: none;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
:is([data-mark-tool="ink"],[data-mark-tool="erase"]) .theory-table-scroll { touch-action: none; }
.theory-eraser-cursor {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 1px solid #69956d;
  border-radius: 50%;
  background: #e2ede330;
  transform: translate(-50%,-50%);
}
.theory-pen-fields, .theory-pen-fields label, .theory-pen-colors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.theory-pen-fields {
  margin-top: 5px;
  padding: 4px 7px;
  background: #f5f9f5;
  border-radius: 8px;
  color: #111111;
  font-size: 12px;
}
.theory-pen-fields select { min-height: 36px; border: 1px solid var(--line); border-radius: 6px; background: #fcfdf9; color: inherit; }
.theory-pen-colors { gap: 4px; }
.theory-pen-colors .mark-color { width: 30px; height: 30px; padding: 0; border: 2px solid #fff; border-radius: 50%; }
.theory-pen-colors .mark-color[aria-pressed="true"] { outline: 2px solid #618b65; outline-offset: 0; }
.theory-pen-fields input[type="color"] { width: 34px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; }
.theory-text-fields :is(.mark-bold,.mark-text-action) { min-width: 34px; min-height: 34px; padding: 4px 7px; }
.theory-text-fields button[aria-pressed="true"] { background: var(--soft); color: #111111; border-color: #d6e5d7; }
.theory-pen-fields input[type="range"] { width: 90px; min-height: 36px; margin: 0; }
.mark-width-label output { min-width: 4ch; font-variant-numeric: tabular-nums; }
.mark-snap-label { min-height: 34px; }
.note-images { margin-top: 8px; padding: 5px 0 9px; }
.note-images summary { cursor: pointer; min-height: 33px; color: #111111; font-size: 13px; font-weight: 700; }
.note-images input[type="file"] { max-width: 100%; color: #111111; font-size: 13px; }
.note-image-status { font-size: 12px; color: #111111; margin: 4px 0; }
.note-image-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(95px,130px)); gap: 7px; }
.note-image { margin: 0; min-width: 0; }
.note-image img { display: block; width: 100%; max-height: 130px; object-fit: contain; border-radius: 5px; }
.theory-marks-hidden .theory-mark-layer { display: none; }
@media(max-width:700px){
  .theory-unit-title { font-size: 16px; }
  .theory-text {
    font-size: 14px;
    line-height: 1.65;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  .theory-text article h1 { font-size: 1.25em; margin: 1.2em 0 .45em; }
  .theory-text article h2 { font-size: 1.14em; margin: 1.2em 0 .45em; }
  .theory-text article [data-source-small] { font-size: .9em; }
  .theory-text td, .theory-text th { padding: 5px; }
  .theory-mark-toolbar { position: static; }
  [data-mark-tool]:not([data-mark-tool="read"]) > .theory-mark-toolbar { position: sticky; }
  .theory-mark-controls button { padding-inline: 7px; }
}
