/*
 * Workspace (app.html) and login (login.html). Tokens and shared controls
 * are in base.css. App proportions: a 248px sidebar and fluid content up to
 * 1440 wide; on phones the sidebar becomes a bar of four tabs at the bottom.
 */

/* ------------------------------------------------------------- Shell */

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.side {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 20px 12px 16px;
    border-right: 1px solid var(--line);
    background: var(--surface);
    overflow-y: auto;
}
.side__brand { align-self: flex-start; }
.side__nav { display: grid; gap: 2px; }
.side__nav a, .side__recent a {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-2);
    text-decoration: none;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.side__nav a:hover, .side__recent a:hover { background: var(--raised); color: var(--text); }
.side__nav a.is-on { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
.side__nav a.is-on .icon { color: var(--text); }
.side__count { font-size: 12px; color: var(--text-3); }
.side__label { padding: 0 10px 8px; font-size: 12px; color: var(--text-3); }
.side__recent { min-height: 0; }
.side__recent a { grid-template-columns: 8px minmax(0, 1fr); height: 32px; font-size: 13px; }
.side__recent a span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__recent .mark { width: 8px; height: 8px; border-radius: 2px; background: var(--mark); opacity: 0.8; }
.side__recent li.is-empty { padding: 0 10px; font-size: 13px; color: var(--text-3); }
.side__theme { margin-top: auto; padding: 0 2px; }
.theme-fab { display: none; }
.side__user {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--page);
}
.avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--raised-2);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    object-fit: cover;
    overflow: hidden;
}
.side__who { min-width: 0; }
.side__who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.side__who span { display: block; font-size: 12px; color: var(--text-3); }

.main { min-width: 0; padding: 32px 40px 80px; }
.view { max-width: 1600px; margin-inline: auto; }
@media (prefers-reduced-motion: no-preference) {
    .view.is-entering { animation: rise var(--mid) var(--ease); }
}
.view__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.view__head h1 { font-family: var(--serif); font-size: 36px; font-weight: 400; line-height: 1.1; letter-spacing: -0.015em; }
.view__head p { margin-top: 8px; color: var(--text-2); }
.back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 24px; font-size: 14px; color: var(--text-2); text-decoration: none; }
.back:hover { color: var(--text); }

.tabbar { display: none; }

/* ------------------------------------------------------------- Maker */

.maker { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
.maker__steps { display: grid; gap: 16px; }
.block { padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.block__title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; font-size: 17px; font-weight: 600; line-height: 24px; }
.block__n { width: 12px; font-size: 14px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.block__note { margin-top: 12px; font-size: 14px; color: var(--text-3); }
.block__chips { margin-top: 12px; }

/* Paper cards */
.papers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 16px; }
.paper {
    position: relative;
    display: grid;
    gap: 2px;
    min-height: 96px;
    padding: 14px 14px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--raised);
    text-align: left;
    transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.paper:hover:not(:disabled) { border-color: var(--line-strong); background: var(--raised-2); }
.paper:active:not(:disabled) { transform: scale(0.99); }
.paper.is-on { border-color: var(--text); background: var(--raised-2); box-shadow: inset 0 0 0 1px var(--text); }
.paper:disabled { opacity: 0.5; cursor: not-allowed; }
.paper__subject { font-weight: 600; }
.paper__part { font-size: 13px; color: var(--text-2); }
.paper__meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.paper__meta .is-ms { color: var(--text-2); }
.paper__check {
    position: absolute;
    right: 10px;
    top: 10px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--btn);
    color: var(--btn-text);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity var(--fast) var(--ease), transform var(--mid) var(--ease);
}
.paper__check .icon { width: 13px; height: 13px; stroke-width: 2; }
.paper.is-on .paper__check { opacity: 1; transform: none; }

/* Topic box */
.adder { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.combo { position: relative; min-width: 0; }
.combo__icon { position: absolute; left: 14px; top: 13px; color: var(--text-3); pointer-events: none; }
.combo .input { padding-left: 42px; }
.suggest {
    position: absolute;
    z-index: 10;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    padding: 4px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--raised);
    box-shadow: var(--pop-shadow);
}
.suggest__item { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-height: 36px; padding: 8px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.suggest__item.is-active, .suggest__item:hover { background: var(--raised-2); }
.suggest__name--words { color: var(--text-2); }
.suggest__n { flex: none; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.suggest__item + .suggest__item:last-child { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
@media (prefers-reduced-motion: no-preference) { .suggest { animation: rise var(--fast) var(--ease); } }

.browse { margin-top: 16px; }
.browse__title { font-size: 14px; color: var(--text-2); }
.browse summary::-webkit-details-marker { display: none; }
.browse summary:hover { color: var(--text); }
.browse summary .icon { width: 16px; height: 16px; transition: transform var(--mid) var(--ease); }
.browse[open] summary .icon { transform: rotate(90deg); }
.browse__list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.topic {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--raised);
    font-size: 14px;
    text-align: left;
    transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.topic:hover { border-color: var(--line-strong); background: var(--raised-2); }
.topic:active { transform: scale(0.98); }
.topic.is-on { border-color: var(--mark); background: var(--mark); color: var(--mark-ink); }
.topic__n { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.topic.is-on .topic__n { color: rgba(26, 22, 8, 0.65); }

/* Option groups */
.opt + .opt { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.opt__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.opt__head h3 { font-size: 15px; font-weight: 500; }
.opt__note { font-size: 13px; color: var(--text-3); }
.opt--row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* Placement choices: each with a small diagram that acts out where the
   answers go, on hover, focus and when chosen. */
.choices { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.choice {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--raised);
    cursor: pointer;
    transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:hover { border-color: var(--line-strong); background: var(--raised-2); }
.choice:has(input:checked) { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); background: var(--raised-2); }
.choice:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; }
.choice:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.choice__text { display: grid; gap: 2px; }
.choice__text b { font-size: 14px; font-weight: 500; }
.choice__text span { font-size: 12px; line-height: 16px; color: var(--text-3); }

.diagram {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    height: 52px;
    padding: 8px 6px;
    border-radius: 8px;
    background: var(--page);
}
.diagram i { display: block; flex: none; border-radius: 2px; }
.diagram .q { width: 14px; height: 18px; background: var(--sheet); box-shadow: inset 0 3px 0 -1px #d8d8d8, inset 0 7px 0 -5px #d8d8d8; }
.diagram .a { width: 14px; height: 5px; background: #8f8a80; }
.diagram .col { display: flex; flex-direction: column; gap: 3px; }
.diagram .col--answers { padding-left: 2px; }
.diagram .bar { width: 1px; height: 30px; margin: 0 2px; background: var(--line-strong); }
.d-side .spread { display: flex; gap: 4px; padding: 4px; border-radius: 3px; background: color-mix(in srgb, var(--sheet) 12%, transparent); box-shadow: inset 0 0 0 1px var(--line-strong); }
.d-side .a { width: 16px; }
.d-whole { width: 120px; height: 36px; align-items: center; gap: 12px; font-size: 12px; color: var(--text-2); }
.d-whole span { padding: 1px 4px; border-radius: 3px; }
.d-whole .w1 { background: var(--mark); color: var(--mark-ink); }
.d-whole b { font-weight: 400; border-radius: 2px; background: var(--mark); color: var(--mark-ink); transition: background-color var(--mid) var(--ease), color var(--mid) var(--ease); }
#whole-row:has(input:checked) + .d-whole b { background: transparent; color: var(--text-2); }

@media (prefers-reduced-motion: no-preference) {
    .choice:hover .a, .choice:has(input:focus-visible) .a, .choice:has(input:checked) .a { animation: answer-in 420ms var(--ease) both; }
    .choice .col:nth-child(2) .a, .choice .col--answers .a:nth-child(2) { animation-delay: 120ms !important; }
    .choice .col:nth-child(3) .a, .choice .col--answers .a:nth-child(3) { animation-delay: 240ms !important; }
    .choice[data-place="none"]:hover .q, .choice[data-place="none"]:has(input:checked) .q { animation: page-in 360ms var(--ease) both; }
    .choice[data-place="none"] .q:nth-child(2) { animation-delay: 90ms !important; }
    .choice[data-place="none"] .q:nth-child(3) { animation-delay: 180ms !important; }
    .choice[data-place="side"]:hover .spread, .choice[data-place="side"]:has(input:checked) .spread { animation: spread-in 420ms var(--ease) both; }
}
@keyframes answer-in { from { opacity: 0; transform: translateY(-6px) scaleX(0.4); } }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes spread-in { from { transform: scaleX(0.7); opacity: 0.4; } }

/* Years */
.years { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.years__range { display: flex; align-items: center; gap: 8px; }
.select--sm select { height: 36px; padding: 0 34px 0 12px; font-size: 14px; border-radius: 8px; }
.select--sm::after { top: 13px; right: 14px; }
.sessions { display: flex; gap: 6px; }
.toggle {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--raised);
    font-size: 14px;
    color: var(--text-3);
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.toggle:hover { color: var(--text); }
.toggle[aria-pressed="true"] { border-color: var(--line-strong); background: var(--raised-2); color: var(--text); }
.timeline { display: flex; align-items: center; gap: 4px; margin-top: 16px; height: 24px; }
.timeline span { position: relative; flex: 1; height: 4px; border-radius: 2px; background: var(--text-2); transition: background-color var(--mid) var(--ease), opacity var(--mid) var(--ease); }
.timeline span.is-out { background: var(--raised-2); }
.timeline span b { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 400; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The cover of the topical being made */
.maker__cover { position: sticky; top: 24px; display: grid; gap: 12px; }
.result {
    position: relative;
    min-height: 360px;
    padding: 28px 24px 20px;
    overflow: hidden;
    clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 28px, 100% 100%, 0 100%);
}
.result__fold { position: absolute; right: 0; top: 0; width: 28px; height: 28px; background: linear-gradient(225deg, transparent 50%, #d6d6d6 50%); }
.result__title { font-size: 30px; font-weight: 700; line-height: 1; }
.result__source { margin-top: 8px; font-size: 13px; line-height: 18px; color: #555; }
.result__topics { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 18px; font-size: 16px; font-weight: 700; line-height: 1.5; }
.result__topics:empty { display: none; }
.result__empty { margin-top: 24px; font-size: 14px; color: #666; }
.result__count { margin-top: 20px; font-size: 15px; }
.result__count span:first-child { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result__detail { margin-top: 4px; font-size: 13px; color: #555; font-variant-numeric: tabular-nums; }
.result__detail.is-warn { color: #a3402f; }
.result__list { max-height: 220px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #ddd; overflow: auto; }
.result__list li { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; line-height: 22px; font-variant-numeric: tabular-nums; }
.result__list li span:first-child { font-weight: 700; white-space: nowrap; }
.result__list li span:last-child { color: #555; text-align: right; }

.maker__actions { display: grid; gap: 10px; }
.maker__estimate { min-height: 18px; font-size: 13px; color: var(--text-3); text-align: center; }
.maker__error { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); font-size: 14px; }
.done { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.run { display: grid; gap: 8px; }
.run__stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.run__stages li { font-size: 12px; color: var(--text-3); text-align: center; transition: color var(--mid) var(--ease); }
.run__stages li.is-on { color: var(--text); }
.run__stages li.is-done { color: var(--text-2); }
.run__bar { height: 4px; overflow: hidden; border-radius: 2px; background: var(--raised-2); }
.run__bar span { display: block; height: 100%; background: var(--mark); transform-origin: left; transform: scaleX(0.02); transition: transform var(--mid) var(--ease); }
.run__label { font-size: 13px; color: var(--text-2); text-align: center; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- My topicals */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.toolbar__search { flex: 1 1 260px; max-width: 420px; }
.toolbar__search .input { height: 36px; font-size: 14px; border-radius: 8px; }
.toolbar__search .combo__icon { top: 9px; }

.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 20px; }
.tcard { position: relative; display: grid; gap: 12px; }
.tcard__open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    border-radius: 6px;
}
.thumb {
    position: relative;
    display: block;
    aspect-ratio: 210 / 297;
    padding: 18px 16px;
    overflow: hidden;
    clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%);
    transition: transform var(--mid) var(--ease);
}
.thumb::after { content: ""; position: absolute; right: 0; top: 0; width: 22px; height: 22px; background: linear-gradient(225deg, transparent 50%, #d6d6d6 50%); }
.tcard__open:hover .thumb, .tcard__open:focus-visible .thumb { transform: translateY(-4px); }
.thumb__title { display: block; font-size: 20px; font-weight: 700; line-height: 1; }
.thumb__source { display: block; margin-top: 6px; font-size: 10px; line-height: 13px; color: #555; }
.thumb__topics { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 14px; font-size: 12px; font-weight: 700; line-height: 1.5; }
.thumb__count { display: block; margin-top: 12px; font-size: 11px; font-variant-numeric: tabular-nums; }
.thumb__count b { font-size: 16px; }
.thumb__lines { position: absolute; left: 16px; right: 16px; bottom: 18px; display: grid; gap: 6px; }
.thumb__lines i { display: block; height: 3px; border-radius: 2px; background: #e3e3e3; }
.thumb__lines i:nth-child(2n) { width: 70%; }
.thumb__pin { position: absolute; right: 28px; top: 8px; padding: 2px 8px; border-radius: 4px; background: #1c1c1e; color: #fff; font-family: var(--sans); font-size: 10px; font-weight: 600; }
.tcard__meta { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: start; }
.tcard__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.tcard__sub { grid-column: 1; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tcard__more { grid-row: span 2; }
.tcard.is-opening .thumb { opacity: 0.6; }

.empty { display: grid; justify-items: center; gap: 12px; max-width: 420px; margin: 48px auto; text-align: center; }
.empty h2 { font-family: var(--serif); font-size: 26px; font-weight: 400; }
.empty p { color: var(--text-2); margin-bottom: 8px; }
.empty__art { position: relative; width: 120px; height: 150px; margin-bottom: 16px; }
.empty__art .sheet { position: absolute; inset: 0; }
.empty__art .sheet:nth-child(1) { transform: rotate(-6deg) translate(-8px, 4px); background: #d9d9d9; }
.empty__art .sheet:nth-child(2) { transform: rotate(4deg) translate(8px, 2px); background: #ececec; }
.empty__top { display: grid; align-content: start; gap: 8px; padding: 16px 14px; }
.empty__top b { font-size: 16px; }
.empty__top i { display: block; height: 4px; border-radius: 2px; background: #e3e3e3; }
.empty__top i:first-of-type { width: 80%; background: var(--mark); height: 8px; }
.empty__top i.s { width: 55%; }
@media (prefers-reduced-motion: no-preference) {
    .empty__art { animation: drift 6s ease-in-out infinite alternate; }
}
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-6px); } }

/* ------------------------------------------------------- One topical */

.detail { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; align-items: start; }
.detail__thumb { position: sticky; top: 24px; }
.detail__thumb .thumb { padding: 26px 22px; }
.detail__thumb .thumb__title { font-size: 28px; }
.detail__thumb .thumb__source { font-size: 12px; line-height: 16px; }
.detail__thumb .thumb__topics { font-size: 15px; }
.detail__thumb .thumb__count { font-size: 13px; }
.detail__thumb .thumb__count b { font-size: 22px; }
.detail__title { display: flex; align-items: center; gap: 8px; }
.detail__title h1 { font-family: var(--serif); font-size: 34px; font-weight: 400; line-height: 1.15; letter-spacing: -0.015em; }
.detail__title input { font-family: var(--serif); font-size: 30px; height: 52px; }
.detail__made { margin-top: 8px; color: var(--text-3); }
.detail__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.facts { display: grid; grid-template-columns: 160px minmax(0, 1fr); margin-top: 32px; border-top: 1px solid var(--line); }
.facts dt, .facts dd { padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--text-3); font-size: 14px; }
.facts dd { font-size: 14px; font-variant-numeric: tabular-nums; }
.facts dd .hl { color: var(--mark-ink); }
.qlist { margin-top: 32px; }
.qlist h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; font-family: var(--sans); }
.qlist__row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; font-variant-numeric: tabular-nums; }
.qlist__row span:first-child { color: var(--text-2); }
.notice { display: flex; align-items: flex-start; gap: 10px; margin-top: 20px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--raised); font-size: 14px; color: var(--text-2); }
.notice .icon { margin-top: 2px; color: var(--text-3); }

/* ---------------------------------------------------------- Progress */

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.figure { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.figure dt { font-size: 13px; color: var(--text-3); }
.figure dd { margin-top: 6px; font-size: 32px; font-weight: 500; line-height: 36px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.figure dd.is-key { color: var(--text); }
.figure p { margin-top: 6px; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.figure p.is-up { color: var(--ok); }
.panels { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.panel { padding: 20px 24px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel__head h2 { font-size: 15px; font-weight: 500; font-family: var(--sans); }
.panel__head p { font-size: 13px; color: var(--text-3); }
.chart { width: 100%; height: 220px; display: block; }
.chart .grid line { stroke: var(--line); }
.chart .label { fill: var(--text-3); font-size: 11px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--raised-2); }
.chart .bar.is-now { fill: var(--mark); }
@media (prefers-reduced-motion: no-preference) {
    .chart .bar { transform-box: fill-box; transform-origin: bottom; animation: grow 520ms var(--ease) both; }
}
@keyframes grow { from { transform: scaleY(0); } }
.ranked li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; font-size: 14px; }
.ranked li + li { border-top: 1px solid var(--line); }
.ranked .meter { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--raised-2); overflow: hidden; }
.ranked .meter span { display: block; height: 100%; background: var(--text-2); border-radius: 2px; }
.ranked li:first-child .meter span { background: var(--mark); }
.ranked .n { color: var(--text-3); font-variant-numeric: tabular-nums; }
.coverage { margin-top: 12px; }
.cov { padding: 16px 0; }
.cov + .cov { border-top: 1px solid var(--line); }
.cov__head { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.cov__head b { font-weight: 500; }
.cov__head span { color: var(--text-3); font-variant-numeric: tabular-nums; }
.cov__bar { display: flex; gap: 2px; height: 8px; margin-top: 10px; }
.cov__bar i { flex: 1; border-radius: 2px; background: var(--raised-2); }
.cov__bar i.is-done { background: var(--mark); }
.cov__topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cov__topics span { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 6px; background: var(--raised); font-size: 12px; color: var(--text-3); }
.cov__topics span.is-done { color: var(--text); }
.cov__topics span.is-done::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: var(--mark); }
.cov__topics button { height: 26px; padding: 0 10px; border: 1px dashed var(--line-strong); border-radius: 6px; background: none; font-size: 12px; color: var(--text-2); }
.cov__topics button:hover { color: var(--text); border-style: solid; }

/* ----------------------------------------------------------- Account */

.settings { display: grid; gap: 12px; max-width: 880px; }
.card { padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.card h2 { font-size: 16px; font-weight: 600; font-family: var(--sans); }
.card > p { margin-top: 6px; color: var(--text-2); font-size: 14px; }
.who { display: flex; align-items: center; gap: 16px; }
.who .avatar { width: 56px; height: 56px; border-radius: 14px; font-size: 18px; }
.who b { display: block; font-size: 17px; font-weight: 600; }
.who span { color: var(--text-3); font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row b { display: block; font-weight: 500; }
.row span { display: block; margin-top: 2px; font-size: 13px; color: var(--text-3); }
.card .row:first-of-type { margin-top: 8px; }
.records { width: 100%; margin-top: 16px; border-collapse: collapse; font-size: 14px; }
.records th, .records td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.records th { font-size: 12px; font-weight: 500; color: var(--text-3); }
.records td:first-child { color: var(--text); white-space: nowrap; }
.records td { color: var(--text-2); }
.yes { color: var(--text); }
.no { color: var(--text-3); }

/* -------------------------------------------------------------- Login */

.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth__stage .brand { justify-self: start; }
.auth__stage {
    position: relative;
    display: grid;
    align-content: space-between;
    gap: 40px;
    padding: 32px 48px 48px;
    border-right: 1px solid var(--line);
    background: var(--surface);
    overflow: hidden;
}
.auth__copy h2 { font-family: var(--serif); font-size: clamp(30px, 3vw, 42px); font-weight: 400; line-height: 1.12; letter-spacing: -0.015em; max-width: 26rem; }
.auth__points { display: grid; gap: 12px; margin-top: 24px; }
.auth__points li { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.auth__points .icon { color: var(--ok); }
.stack { position: relative; width: 220px; height: 290px; margin: 0 auto; }
.stack .sheet { position: absolute; inset: 0; }
.stack .sheet:nth-child(1) { transform: rotate(-5deg) translate(-14px, 8px); background: #d9d9d9; }
.stack .sheet:nth-child(2) { transform: rotate(3deg) translate(10px, 4px); background: #ececec; }
.stack__top { padding: 22px 20px; display: grid; align-content: start; gap: 8px; clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 26px, 100% 100%, 0 100%); }
.stack__top b { font-size: 26px; line-height: 1; }
.stack__top small { font-size: 11px; color: #555; }
.stack__top .hl { justify-self: start; margin-top: 10px; font-weight: 700; font-size: 15px; }
.stack__top i { display: block; height: 4px; border-radius: 2px; background: #e3e3e3; }
.stack__top i.s { width: 60%; }
@media (prefers-reduced-motion: no-preference) {
    .stack { animation: drift 6s ease-in-out infinite alternate; }
}

.auth__theme { position: absolute; top: 24px; right: 24px; }
.auth__form { position: relative; display: grid; align-content: center; justify-items: center; padding: 48px 24px; }
.form { display: grid; gap: 16px; width: min(440px, 100%); padding: 36px 36px 32px; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--surface); box-shadow: var(--card-shadow); }
.form h1 { font-family: var(--serif); font-size: 32px; font-weight: 400; line-height: 1.15; letter-spacing: -0.015em; }
.form > p { color: var(--text-2); }
.btn--google { gap: 10px; }
.or { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; font-size: 13px; color: var(--text-3); }
.or::before, .or::after { content: ""; height: 1px; background: var(--line); }
.field-row { display: grid; gap: 6px; }
.field-row__top { display: flex; justify-content: space-between; align-items: baseline; }
.form__error { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); font-size: 14px; }
.form__ok { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); font-size: 14px; }
.form__alt { font-size: 14px; color: var(--text-2); text-align: center; }
.form__guest { font-size: 14px; color: var(--text-3); text-align: center; }
.form__notice { display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--raised); font-size: 14px; color: var(--text-2); }
.form__notice .icon { margin-top: 2px; flex: none; }
.spin { width: 16px; height: 16px; border-radius: 8px; border: 2px solid currentColor; border-right-color: transparent; }
@media (prefers-reduced-motion: no-preference) { .spin { animation: spin 0.8s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- Opening */

.opening { display: grid; justify-items: center; align-content: center; gap: 16px; min-height: 100%; padding: 48px 16px; }
.opening__pages { position: relative; width: 150px; height: 200px; }
.opening__pages .sheet { position: absolute; inset: 0; }
.opening__pages .sheet:nth-child(1) { transform: rotate(-4deg); background: #d9d9d9; }
.opening__pages .sheet:nth-child(2) { transform: rotate(3deg); background: #ececec; }
@media (prefers-reduced-motion: no-preference) {
    .opening__pages .sheet:nth-child(3) { animation: page-flip 1.4s var(--ease) infinite; }
}
@keyframes page-flip { 0% { transform: translateY(0); } 40% { transform: translate(18px, -10px) rotate(6deg); opacity: 0.5; } 41% { opacity: 0; } 70% { transform: translate(-6px, 6px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.opening__label { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.opening__bar { width: 240px; }

/* Text never sits loose on the background lines: every block of words lives
   in a rounded box, like the Topic field on the landing page. */
.view__head > div, .empty, .auth__copy {
    padding: 20px 24px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--card-shadow);
    width: fit-content;
    max-width: 100%;
}
.auth__stage .auth__copy { background: var(--raised); }
.view > .back {
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--card-shadow);
}
.empty { justify-items: center; }

/* ----------------------------------------------------------- Responsive */

@media (max-width: 1240px) {
    .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .maker { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 1080px) {
    .maker { grid-template-columns: 1fr; }
    .maker__cover { position: static; }
    .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panels { grid-template-columns: 1fr; }
    .detail { grid-template-columns: 1fr; }
    .detail__thumb { position: static; max-width: 260px; }
}
@media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; }
    .auth__stage { display: none; }
}
@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .side { display: none; }
    .theme-fab { position: fixed; top: 16px; right: 16px; z-index: 45; display: block; }
    .view__head { padding-right: 84px; }
    .main { padding: 20px 16px 96px; }
    .view__head { flex-direction: column; align-items: flex-start; }
    .view__head h1 { font-size: 30px; }
    .block { padding: 18px 16px; }
    .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .opt--row { flex-direction: column; align-items: flex-start; }
    .tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        backdrop-filter: blur(10px);
    }
    .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: 8px; font-size: 11px; color: var(--text-3); text-decoration: none; }
    .tabbar a.is-on { color: var(--text); }
    .tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .figures { grid-template-columns: 1fr 1fr; }
    .facts { grid-template-columns: 120px minmax(0, 1fr); }
    .qlist__row { grid-template-columns: 1fr; gap: 2px; }
    .row { flex-direction: column; align-items: flex-start; gap: 12px; }
    .records { font-size: 13px; }
}

/* Show / hide password (login page). */
.pw { position: relative; }
.pw .input { padding-right: 48px; }
.pw__toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 44px;
    height: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 0 10px 10px 0;
    background: none;
    color: var(--text-3);
    cursor: pointer;
}
.pw__toggle:hover, .pw__toggle:focus-visible { color: var(--text); }

.tgrid__none { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }

/* Card captions and topical details: boxed like the rest, so the words never
   sit loose on the dotted page. */
.tcard__meta,
.detail__head,
.facts,
.qlist {
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--card-shadow);
}
.tcard__meta { padding: 10px 12px 10px 14px; align-content: center; }
.tcard__name { color: var(--text); }
.tcard__more { margin: -2px -4px 0 0; }
.detail__head { padding: 16px 20px; width: fit-content; max-width: 100%; }
.detail__head .detail__made { margin-top: 6px; }
.facts { margin-top: 24px; padding: 4px 20px; border-top: 1px solid var(--line-strong); }
.facts dt, .facts dd { padding: 12px 0; }
.facts dt:nth-last-of-type(1), .facts dd:last-of-type { border-bottom: 0; }
.qlist { margin-top: 24px; padding: 18px 20px 8px; }
.qlist__row:last-child { border-bottom: 0; }
.done #done-ms { grid-column: 1 / -1; }

/* The four states of the Make the PDF panel. One shows at a time, each in its own box. */
.mstate { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); box-shadow: var(--card-shadow); }
.mstate__head { display: flex; align-items: center; gap: 12px; }
.mstate__title { font-weight: 600; font-size: 15px; color: var(--text); }
.mstate__sub { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.mstate__badge { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; color: #fff; }
.mstate__badge .icon { width: 18px; height: 18px; }
.mstate--done { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.mstate--done .mstate__badge { background: var(--ok); }
.mstate--error { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.mstate--error .mstate__badge { background: var(--bad); }
.mstate--error .mstate__title { color: var(--bad); }
.mstate--run { border-color: var(--text); }
.mstate .maker__estimate { margin-top: 0; }
.done__buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.done__buttons #done-ms { grid-column: 1 / -1; }
.run__stages { gap: 6px; }
.run__stages li { padding: 6px 4px; border: 1px solid var(--line); border-radius: 8px; color: var(--text-3); font-weight: 500; }
.run__stages li.is-done { color: var(--ok); border-color: var(--ok); }
.run__stages li.is-done::before { content: "\2713  "; }
.run__stages li.is-on { color: var(--mark-ink); background: var(--mark); border-color: var(--mark); font-weight: 600; }
.run__bar { height: 8px; border-radius: 4px; background: var(--raised-2); }
.run__label { color: var(--text); font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .run__bar span, .run__stages li { transition: none; } }

/* Phone-only parts (shown by mobile.css). */
.papers__change { display: none; }
.mbar { display: none; }
.appbar { display: none; }
