/* Codril: a plain HTML page. Browser defaults wherever they do the job; every colour is a token,
   light in :root and dark under [data-theme=dark] (set before paint by index.html). */
@font-face{font-family:Plex;src:url('/vendor/fonts/sans.woff2') format('woff2');font-weight:100 900;font-display:swap}
:root{
  color-scheme:light;
  --bg:#fff;--code-bg:#fff;--panel:#eee;--soft:#f4f4f4;--soft-line:#ddd;
  --fg:#000;--dim:#555;--line:#999;--gutter:#6e7681;
  --link:#00e;--visited:#551a8b;--accent:#00e;--ok:green;--warn:#a07800;--bad:#c00;--next:#ffff99;--hover:#eee;
  --ok-soft:#e3f4e3;--bad-soft:#fbe3e3;
  --sel:#b4d5fe;--sel-strong:#b4d5fe;--active-line:transparent;
  --heat-0:#ddd;--heat-1:#c6e48b;--heat-2:#7bc96f;--heat-3:#239a3b;--heat-4:#196127;
  /* Code: VS Code Light Modern */
  --tok-text:#3b3b3b;--tok-control:#af00db;--tok-keyword:#0000ff;--tok-function:#795e26;--tok-variable:#001080;
  --tok-type:#267f99;--tok-string:#a31515;--tok-number:#098658;--tok-comment:#008000;
  --mono:Consolas,'Courier New',monospace
}
:root[data-theme=dark]{
  color-scheme:dark;
  --bg:#161616;--panel:#242424;--soft:#1e1e1e;--soft-line:#333;
  --fg:#e2e2e2;--dim:#9a9a9a;--line:#4a4a4a;
  --link:#8ab4f8;--visited:#c58af9;--accent:#8ab4f8;--ok:#6fcf7f;--warn:#e3b341;--bad:#f28b82;--next:#3b3a1c;--hover:#222;
  --ok-soft:#1c3320;--bad-soft:#3a1f1d;
  --sel:#264f78;--sel-strong:#264f78;
  --heat-0:#2a2a2a;--heat-1:#0e4429;--heat-2:#006d32;--heat-3:#26a641;--heat-4:#39d353;
  /* Code: VS Code Dark Modern */
  --code-bg:#1f1f1f;--gutter:#6e7681;
  --tok-text:#cccccc;--tok-control:#c586c0;--tok-keyword:#569cd6;--tok-function:#dcdcaa;--tok-variable:#9cdcfe;
  --tok-type:#4ec9b0;--tok-string:#ce9178;--tok-number:#b5cea8;--tok-comment:#6a9955
}

*{box-sizing:border-box}
/* Room for the scrollbar is always kept, so the page never shifts sideways when it appears. */
html{scrollbar-gutter:stable}
body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.6 Plex,'Segoe UI',system-ui,sans-serif}
#top,#page{width:760px;max-width:calc(100% - 32px);margin:0 auto}
#top{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:40px 0 10px;border-bottom:1px solid var(--line)}
#page{padding:8px 0 64px}
h1{font-size:1.5em;font-weight:600;margin:.67em 0 .5em}
h2{font-size:1.17em;font-weight:600;margin:1em 0 .5em}
p{margin:.5em 0}
a,.link{color:var(--link)}
a:visited{color:var(--visited)}
.link{background:none;border:0;padding:0;font:inherit;text-decoration:underline;cursor:pointer}
/* Breadcrumb links read as plain text until hovered. */
#top nav a{color:var(--fg);text-decoration:none}
#top nav a:hover{color:var(--link);text-decoration:underline}
button:disabled{cursor:wait}
button[hidden]{display:none}
.dim{color:var(--dim)}
.accent{color:var(--ok)}
.bad{color:var(--bad)}
pre,code{font-family:var(--mono);white-space:pre-wrap;overflow-wrap:anywhere}
.skip-link{position:absolute;left:-9999px}
.skip-link:focus{left:8px;top:8px;background:var(--bg)}

/* The last seven days, in the top bar. */
#top .theme{margin-left:auto}
.theme{display:inline-flex;padding:2px;border:0;background:none;color:var(--dim);cursor:pointer}
.theme:hover{color:var(--link)}
/* The month row: right to left, one line, the days that do not fit wrap out of sight. */
.week{display:flex;flex-wrap:wrap;direction:rtl;gap:0 2px;height:10px;overflow:hidden}
#top .week{flex:1 1 0;min-width:120px}
.cell{display:inline-block;flex-shrink:0;width:10px;height:10px;background:var(--heat-0)}
.heat-1{background:var(--heat-1)}.heat-2{background:var(--heat-2)}.heat-3{background:var(--heat-3)}.heat-4{background:var(--heat-4)}

/* Lists: a plain bordered table, for subjects and problems alike. */
.list{width:100%;border-collapse:collapse;margin-top:16px}
.list th,.list td{border:1px solid var(--line);padding:4px 8px;text-align:left}
.list th{background:var(--panel);font-weight:600}
.list .n{width:40px;text-align:center}
.list .small{width:110px}
.list .right{text-align:right}
.list .when{width:130px;white-space:nowrap}
.list .wide{width:220px}.list td.when{color:var(--dim);font-size:.9em}
.list tbody tr:hover{background:var(--hover)}
.list tr.next{background:var(--next)}
.list tr.training td{border-bottom-width:3px;border-bottom-style:double}
.list td .tag{font-size:1em;margin:0}

/* Problem */
/* Level and state, small and coloured, right after the title. */
.tag{font-size:.6em;font-weight:normal;vertical-align:middle;margin-left:.4em}
.tag.easy,.tag.solved{color:var(--ok)}
.tag.medium{color:var(--warn)}
.tag.hard{color:var(--bad)}
.tag.unsolved{color:var(--dim)}
.statement code{font-size:.95em}
/* Code inside a sentence: a small grey box, so it never reads as prose. */
:not(pre)>code{padding:1px 4px;background:var(--soft);border:1px solid var(--soft-line);border-radius:3px;color:var(--tok-text)}
.statement ul,.statement ol{padding-left:24px}
.code-block{position:relative;margin:.5em 0;padding:4px 8px;background:var(--soft);border:1px solid var(--soft-line)}
/* Copy, top right of an example: the browser's own button, small. */
.code-block .copy{position:absolute;top:4px;right:4px;font:12px Plex,sans-serif}
.editor{border:1px solid var(--line);margin-top:12px}
.editor-bar{display:flex;justify-content:space-between;gap:16px;padding:2px 6px;background:var(--panel);border-bottom:1px solid var(--soft-line);font-family:var(--mono);font-size:13px}
.editor-host{display:flex;min-height:120px;overflow:hidden}
.cm-editor{width:100%;height:100%;font:14px/19px var(--mono)}
.cm-editor.cm-focused{outline:none}
.cm-scroller{font-family:var(--mono)!important;overflow:auto}
.cm-gutters{background:var(--soft)!important;border-right:1px solid var(--soft-line)!important;color:var(--gutter)!important}
.cm-activeLineGutter{background:transparent!important;color:var(--fg)}
.resize{height:10px;border-top:1px solid var(--soft-line);background:var(--panel);cursor:ns-resize;touch-action:none}
/* Check, then the next problem on the right: the browser's own buttons. */
.actions{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin:12px 0}
.hint{font:12px var(--mono)}
.next-problem{margin-left:auto;padding:4px 14px;font-size:15px}
/* Hidden, it still holds its place, so the line does not move when it appears. */
.next-problem[hidden]{display:block;visibility:hidden}
/* The result: a box, green when every test passes, red when one fails. */
.result{margin-top:16px;padding:6px 12px;border:1px solid var(--line)}
.result:empty{display:none}
/* Chedril: the result is plain text on the line under the board. */
.actions .result,.actions .result[data-verdict]{margin:0;padding:0;border:0;background:none}
.actions .result p{margin:0}
.result[data-verdict=pass]{border-color:var(--ok);background:var(--ok-soft)}
.result[data-verdict=fail]{border-color:var(--bad);background:var(--bad-soft)}
.case{border-collapse:collapse;width:100%;margin:6px 0}
.case td{background:var(--bg)}
.case th,.case td{border:1px solid var(--line);padding:4px 8px;text-align:left;vertical-align:top}
.case th{width:90px;background:var(--panel);font-weight:600}
.case pre{margin:0}
.message{white-space:pre-wrap}
.message code{font-size:.95em}

/* Syntax: VS Code's colours. code.js names every token's tags; later rules win. */
.cm-content,.code-block code{color:var(--tok-text)}
.tok-variableName,.tok-propertyName{color:var(--tok-variable)}
.tok-function{color:var(--tok-function)}
.tok-className,.tok-typeName{color:var(--tok-type)}
.tok-keyword,.tok-bool,.tok-null{color:var(--tok-keyword)}
.tok-controlKeyword,.tok-moduleKeyword{color:var(--tok-control)}
.tok-string{color:var(--tok-string)}
.tok-number{color:var(--tok-number)}
.tok-comment{color:var(--tok-comment)}

/* Login */
.login-page{width:360px;max-width:calc(100% - 32px);margin:15vh auto 0}
.login-page form{display:flex;flex-direction:column;align-items:flex-start;gap:6px}
.login-page .err{color:var(--bad)}

@media(max-width:700px){
  .list .small{width:auto}
}

/* Chedril: the day's count and « Nouvelle série », on the right under the list; a locked level's topics. */
.actions.series{justify-content:flex-end}
/* A level's title folds its table: plain bold text, a click opens or folds it. */
.fold{all:unset;cursor:pointer;font-weight:600}
.fold:focus-visible{outline:2px solid var(--accent)}
.list tr.locked td{color:var(--dim)}
/* The board and one line of feedback under it. */
/* The board starts as far under the top bar's line as the breadcrumb sits above it (10px, with
   the page's 8px and the line). */
.board-area{margin-top:3px;--board:100%}
/* A puzzle page fits the window: no deep bottom margin, and no empty notice line. */
#page.chess{padding-bottom:12px}
.notice:empty{display:none}
.board-area .editor-host{display:block;overflow:visible}
/* As wide as the page, aligned with the text on both sides. */
.board{width:var(--board);aspect-ratio:1/1}
/* Warm brown squares, a1 dark, drawn without the SVG of chessground.brown.css. */
.board cg-board{background:repeating-conic-gradient(#b88762 0 25%,#edd6b0 0 50%) 0 0/25% 25%}
/* Coordinates inside the edge squares (`.cg-wrap` too, to win over chessground's own sheet, loaded later): ranks top left of the left file, files bottom right of the
   bottom rank, each in the colour of the other kind of square. */
.board.cg-wrap coords{opacity:1;font:600 12px Plex,sans-serif}
.board.cg-wrap coords.ranks{left:4px;top:3px;width:auto}
.board.cg-wrap coords.ranks coord{transform:none}
.board.cg-wrap coords.files{left:0;bottom:2px;height:auto;text-transform:none}
.board.cg-wrap coords.files coord{text-align:right;padding-right:4px}
.board.orientation-white .ranks :nth-child(odd),.board.orientation-black .ranks :nth-child(even),
.board.orientation-white .files :nth-child(odd),.board.orientation-black .files :nth-child(even){color:#edd6b0}
.board.orientation-white .ranks :nth-child(even),.board.orientation-black .ranks :nth-child(odd),
.board.orientation-white .files :nth-child(even),.board.orientation-black .files :nth-child(odd){color:#b88762}
.board-line{display:flex;justify-content:space-between;align-items:baseline;gap:12px;width:var(--board);margin-top:10px}
.board-say{margin:0}
/* The typed move: two squares, in the code font. */
.move-input{width:9em;padding:4px 8px;font:15px var(--mono);color:var(--fg);background:var(--code-bg);border:1px solid var(--line)}
.move-input:focus{outline:none;border-color:var(--accent)}
/* Under the board only the solution button, when it shows; what the board says sits beside the field. */
.board-line:has(button[hidden]){display:none}
.board-say.bad{color:var(--bad);font-weight:600}
.board-area .save-line{width:var(--board)}

/* Madril: the answers are one grid. Labels sit on the right of their column, against their
   field; a field starts short and grows with its answer, its mark just after it, the reason under. */
.answers{margin:16px 0 20px}
.answers .editor-host{display:grid;grid-template-columns:max-content minmax(0,1fr);align-items:center;gap:10px 12px;min-height:0;overflow:visible}
.answer{display:contents}
.answer-label{justify-self:end;font-size:1.1em}
.answer-input{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;min-width:0}
.answer[data-verdict=pass] .answer-slot{border-color:var(--ok)}
.answer[data-verdict=fail] .answer-slot{border-color:var(--bad)}
.answer .mark{font-weight:600}
.answer[data-verdict=pass] .mark{color:var(--ok)}
.answer[data-verdict=fail] .mark{color:var(--bad)}
.answer .note{grid-column:2;margin-top:-6px;font-size:.9em;color:var(--dim)}
.answer .note:empty,.answer[data-verdict=''] .note{display:none}
/* Math in a statement or a label: room above and below for fractions, and long formulas scroll
   sideways on their own instead of the page. */
.math{display:inline-block;max-width:100%;overflow-x:auto;overflow-y:hidden;vertical-align:middle;padding:.3em 0}
.statement .math{font-size:1.08em}
.statement p:has(> .math:only-child){margin:.8em 0}
@media (max-width:600px){
  .answers .editor-host{grid-template-columns:minmax(0,1fr)}
  .answer-label{justify-self:start;margin-bottom:-6px}
  .answer .note{grid-column:1}
}
/* A drawn answer or label never scrolls: a root sign pokes a pixel past its box, and that was
   enough to show a scrollbar. Only the statement's long formulas may scroll. */
.answer-label .math,.popup-title .math{overflow:visible;max-width:none}
/* A long answer scrolls inside its box; the padding leaves room for a root sign, so a short one
   never shows a scrollbar for a pixel. */
.answer-slot .math{max-width:100%;overflow-x:auto;overflow-y:hidden;padding:.3em 4px;scrollbar-width:thin}

/* An answer box shows only the drawn math; clicking it opens the editor window. */
.answer-slot{display:inline-flex;align-items:center;flex:0 1 auto;min-width:min(9em,100%);min-height:2.6em;max-width:100%;overflow:hidden;padding:0 10px;font:inherit;font-size:1.2em;
  text-align:left;color:var(--fg);background:var(--code-bg);border:1px solid var(--line);border-radius:0;cursor:text}
.answer-slot:hover{border-color:var(--dim)}
.answer-slot[aria-expanded=true],.answer-slot:focus-visible{border-color:var(--accent);outline:none}
.slot-empty{color:var(--dim);font-size:.75em}
/* The editor window: a title bar to drag it by, the code line, a reminder of the keys. */
.math-popup{position:fixed;z-index:50;left:0;top:0;min-width:300px;max-width:calc(100vw - 8px);background:var(--panel);
  border:1px solid var(--line);box-shadow:0 10px 30px rgba(0,0,0,.4)}
.math-popup[hidden]{display:none}
.popup-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:2px 4px 2px 10px;cursor:grab;user-select:none;
  touch-action:none;border-bottom:1px solid var(--soft-line);font-size:.9em}
.popup-bar:active{cursor:grabbing}
.popup-close{width:26px;height:26px;padding:0;border:0;background:none;color:var(--dim);font-size:18px;cursor:pointer}
.popup-close:hover{color:var(--fg);background:var(--hover)}
.math-popup .answer-code{font-size:1.2em}
.math-popup .answer-code .cm-editor{background:var(--code-bg)}
.math-popup .answer-code .cm-editor.cm-focused{outline:none}
.math-popup .answer-code .cm-scroller{font-family:var(--mono);line-height:1.6;overflow-y:auto}
.math-popup .answer-code .cm-editor{height:100%}
