/* Early Reader: mobile-first, plain, accessible. Media queries are at the bottom. */

/* OpenDyslexic, bundled for the "Easier to read" font (SIL Open Font License: fonts/OpenDyslexic-OFL.txt).
   Only downloaded when a reader picks that font. Bold italic is synthesised from bold. */
@font-face {
    font-family: "OpenDyslexic";
    src: url("fonts/OpenDyslexic-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "OpenDyslexic";
    src: url("fonts/OpenDyslexic-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "OpenDyslexic";
    src: url("fonts/OpenDyslexic-Italic.woff2") format("woff2");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

:root {
    --color-background: #faf8f5;
    --color-surface: #ffffff;
    --color-text: #1f1d1a;
    --color-muted: #5f5a53;
    --color-border: #d9d3ca;
    --color-accent: #7a3b2e;
    --color-accent-text: #ffffff;
    --color-success: #2f6b3a;
    --color-danger: #a12c22;
    --color-focus: #1f5fbf;
    --color-drive-doc: #1a73e8;
    --color-drive-folder: #5f6368;
    --color-drive-hover: #f1f3f4;
    --color-drive-selected: #e8f0fe;
    --radius: 10px;
    --tap-size: 44px;
    color-scheme: light dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1.0625rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-background);
}

h1,
h2 {
    line-height: 1.2;
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    font-weight: 600;
}

h1 {
    margin: 0.25rem 0 0.75rem;
    font-size: 1.75rem;
}

h2 {
    margin: 1.75rem 0 0.75rem;
    font-size: 1.25rem;
}

a {
    color: var(--color-accent);
}

:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
    vertical-align: -0.25em;
}

.skip-link {
    position: absolute;
    left: 0.5rem;
    top: -3rem;
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
}

.skip-link:focus {
    top: 0.5rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--tap-size);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.top-actions form {
    margin: 0;
}

/* Page */
.page {
    flex: 1;
    width: 100%;
    max-width: 44rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

.narrow {
    max-width: 32rem;
    margin: 0 auto;
}

.lead {
    font-size: 1.125rem;
    color: var(--color-text);
}

.muted {
    color: var(--color-muted);
}

.small {
    font-size: 0.9375rem;
}

.center {
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: var(--tap-size);
    color: var(--color-muted);
    text-decoration: none;
}

.big-icon {
    color: var(--color-accent);
}

.big-icon .icon {
    width: 3rem;
    height: 3rem;
}

.empty-state {
    padding-top: 2rem;
    text-align: center;
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--tap-size);
    padding: 0.625rem 1.125rem;
    font: inherit;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}

.button-primary {
    color: var(--color-accent-text);
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.button-danger {
    color: #ffffff;
    background: var(--color-danger);
    border-color: var(--color-danger);
}

.button-small {
    min-height: 36px;
    padding: 0.375rem 0.75rem;
    font-size: 0.9375rem;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tap-size);
    height: var(--tap-size);
    padding: 0;
    color: var(--color-text);
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}

.icon-button:hover {
    background: var(--color-background);
}

/* Forms */
.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

label,
.setting-label {
    font-weight: 600;
}

.optional {
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--color-muted);
}

input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    min-height: var(--tap-size);
    padding: 0.5rem 0.75rem;
    font: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

textarea {
    min-height: 6rem;
    resize: vertical;
}

.input-prefix {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.field-help {
    margin: 0.25rem 0 0;
    font-size: 0.9375rem;
    color: var(--color-muted);
}

.field-error {
    margin: 0.25rem 0 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-danger);
}

.has-error input,
.has-error textarea {
    border-color: var(--color-danger);
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

/* Settings */
.settings-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.settings-group > legend {
    float: left;
    width: 100%;
    margin-bottom: 0.75rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
    font-weight: 600;
}

.settings-group > legend + * {
    clear: both;
}

.settings-group .field + .field {
    margin-top: 1rem;
}

.setting {
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
}

.setting legend {
    margin-bottom: 0.25rem;
}

.setting-sublabel {
    margin: 1rem 0 0.25rem;
    font-weight: 600;
}

.choice,
.toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    min-height: var(--tap-size);
    padding: 0.5rem 0;
    font-weight: 400;
    cursor: pointer;
}

.toggle-label {
    font-weight: 600;
}

.choice input,
.toggle input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0.125rem 0 0;
    flex-shrink: 0;
    accent-color: var(--color-accent);
}

.question-list {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
}

.link-box {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.link-box input {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.875rem;
}

.sticky-save {
    position: sticky;
    bottom: 0;
    padding: 0.75rem 0;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    background: var(--color-background);
}

.sticky-save .button {
    width: 100%;
}

/* Cards and lists */
.card {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.card h2 {
    margin-top: 0;
}

.card p:last-child {
    margin-bottom: 0;
}

.card-danger {
    border-color: var(--color-danger);
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    border-radius: 999px;
}

.shelf + .shelf {
    margin-top: 1rem;
}

.shelf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.shelf-header h2 {
    margin: 0.75rem 0;
}

.book-list,
.people-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.book-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 0.625rem;
    padding: 0.875rem;
    color: var(--color-text);
    text-decoration: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.book-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 4rem;
    flex-shrink: 0;
    color: var(--color-accent);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.book-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
    min-width: 0;
}

.book-title {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.125rem;
    font-weight: 600;
}

.book-subtitle {
    font-size: 0.9375rem;
    color: var(--color-muted);
}

.action-list {
    margin: 1rem 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.action-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.25rem;
    padding: 0 1rem;
    color: var(--color-text);
    text-decoration: none;
}

.action-row + .action-row {
    border-top: 1px solid var(--color-border);
}

.action-row span {
    flex: 1;
}

.person {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
}

.person-icon {
    color: var(--color-muted);
}

.person-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.person-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.person-meta {
    font-size: 0.9375rem;
    color: var(--color-muted);
    overflow-wrap: anywhere;
}

.person-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
}

.person-actions form {
    margin: 0;
}

/* Notices */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left-width: 4px;
    border-radius: var(--radius);
}

.notice-success {
    border-left-color: var(--color-success);
}

.notice-error {
    border-left-color: var(--color-danger);
}

.notice-info {
    border-left-color: var(--color-focus);
}

/* Dev */
.dev-footer {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    text-align: center;
    color: var(--color-muted);
    border-top: 1px dashed var(--color-border);
}

.mail-entry {
    padding: 0.75rem;
    overflow-x: auto;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

/* Import and review */
.import-list,
.review-list,
.toc {
    margin: 0;
    padding: 0;
    list-style: none;
}

.import-fields {
    display: flex;
    gap: 0.75rem;
}

.import-fields .field {
    flex: 1;
}

.import-fields .field-narrow {
    flex: 0 0 5rem;
}

input[type="number"],
input[type="file"] {
    width: 100%;
    min-height: var(--tap-size);
    padding: 0.5rem 0.75rem;
    font: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.excerpt {
    margin: 0.25rem 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-style: italic;
    color: var(--color-muted);
}

.review-title {
    margin: 0;
}

.change {
    margin: 0.75rem 0;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--color-border);
}

.change-new {
    border-left-color: var(--color-success);
}

.change-changed {
    border-left-color: var(--color-focus);
}

.change-cut {
    border-left-color: var(--color-danger);
}

.change p {
    margin: 0.25rem 0 0;
}

.change-label {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}

ins {
    text-decoration: underline;
    text-decoration-color: var(--color-focus);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    background: transparent;
}

del {
    color: var(--color-danger);
}

details summary {
    min-height: var(--tap-size);
    padding: 0.5rem 0;
    font-weight: 600;
    cursor: pointer;
}

.note-editor {
    margin-top: 0.5rem;
    border-top: 1px solid var(--color-border);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.button-row form {
    margin: 0;
}

/* Book contents */
.continue-card .button-wide,
.button-wide {
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 0.5rem;
    margin-bottom: 0.75rem;
    accent-color: var(--color-accent);
}

.toc-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3rem;
    padding: 0.25rem 0;
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border);
}

.toc-number {
    width: 2rem;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    color: var(--color-muted);
}

.toc-title {
    flex: 1;
    font-family: Georgia, "Times New Roman", serif;
}

.toc-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--color-success);
}

.toc-length {
    display: block;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.toc-part {
    margin: 1.5rem 0 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
    border-bottom: 2px solid var(--color-border);
}

.toc-part:first-child {
    margin-top: 0;
}

.toc-in-progress {
    color: var(--color-accent);
}

.toc-new {
    color: var(--color-muted);
}

/* Reading screen */
.reader {
    max-width: 36rem;
    margin: 0 auto;
}

.reader-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chapter-header {
    margin: 1rem 0 1.5rem;
    text-align: center;
}

.part-title {
    margin: 0 0 1.5rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
    letter-spacing: 0.04em;
}

.chapter-number {
    margin: 0;
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.chapter-text {
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    font-size: 1.1875rem;
    line-height: 1.7;
}

.para {
    position: relative;
    margin: 0 0 1em;
    border-radius: 4px;
    scroll-margin-top: 5rem;
    transition: background-color 0.2s;
}

.para-new {
    padding-left: 0.75rem;
    border-left: 3px solid var(--color-success);
}

.para-changed {
    padding-left: 0.75rem;
    border-left: 3px solid var(--color-focus);
}

.scene-break {
    margin: 1.5em 0;
    text-align: center;
    letter-spacing: 0.5em;
    color: var(--color-muted);
}

.cut-marker {
    height: 0;
    margin: -0.5em 0 0.5em;
    border-top: 1px dashed var(--color-danger);
}

.changes-list {
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
}

.changes-list li {
    padding: 0.375rem 0;
}

.changes-list a {
    color: var(--color-text);
    text-decoration: none;
}

.watermark {
    margin: 2rem 0 0;
    font-size: 0.75rem;
    text-align: center;
    opacity: 0.35;
    user-select: none;
}

.chapter-footer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 2rem 0;
}

.chapter-footer .button .icon {
    margin-left: 0.25rem;
}

/* Notification bell */
.bell {
    position: relative;
}

.bell-count {
    position: absolute;
    top: 4px;
    right: 2px;
    min-width: 1.1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.1rem;
    text-align: center;
    color: var(--color-accent-text);
    background: var(--color-accent);
}

.is-unread .person-name {
    font-weight: 700;
}

/* Paragraph feedback markers and highlights */
.para-playing {
    background: color-mix(in srgb, var(--color-accent) 12%, transparent);
    box-shadow: 0 0 0 0.375rem color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.para-selected {
    background: color-mix(in srgb, var(--color-focus) 10%, transparent);
    box-shadow: 0 0 0 0.375rem color-mix(in srgb, var(--color-focus) 10%, transparent);
}

.para-feedback {
    display: inline-flex;
    align-items: center;
    gap: 0.125rem;
    margin-left: 0.375rem;
    padding: 0 0.25rem;
    border-radius: 6px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    vertical-align: middle;
    text-decoration: none;
    color: var(--color-muted);
    opacity: 0;
}

.para-feedback .icon {
    width: 1rem;
    height: 1rem;
}

.para-feedback.has-feedback,
.para-feedback:focus-visible,
.para:hover .para-feedback {
    opacity: 1;
}

.para-feedback.has-feedback {
    color: var(--color-accent);
}

/* Play bar */
body.has-play-bar {
    padding-bottom: 8.5rem;
}

.play-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    padding: 0.375rem 0.5rem calc(0.375rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.play-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 36rem;
    margin: 0 auto;
}

.play-button {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    color: var(--color-accent-text);
    background: var(--color-accent);
}

.play-button:hover {
    background: var(--color-accent);
}

.speed-button {
    min-width: 3.25rem;
    min-height: var(--tap-size);
    padding: 0 0.375rem;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    background: transparent;
    cursor: pointer;
}

.play-status {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 0.8125rem;
    color: var(--color-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.listen-panel,
.feedback-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    max-height: 80vh;
    overflow-y: auto;
    padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
    border-radius: 16px 16px 0 0;
    background: var(--color-surface);
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.15);
}

.listen-panel-header,
.feedback-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.listen-panel-header h2 {
    margin: 0;
}

.listen-group {
    margin-top: 1rem;
}

/* The listening panel sits above the play bar, so pause stays in reach */
.listen-panel {
    bottom: calc(7.5rem + env(safe-area-inset-bottom));
    max-height: 70vh;
    padding-bottom: 1rem;
}

.voice-list {
    margin-top: 0.5rem;
}

.voice-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Feedback on a paragraph */
.quoted-paragraph {
    margin: 0 0 1rem;
    padding: 0.5rem 0 0.5rem 0.75rem;
    border-left: 3px solid var(--color-border);
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    color: var(--color-muted);
}

.reaction-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.reaction {
    min-height: 38px;
    padding: 0 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--color-text);
    background: var(--color-surface);
    cursor: pointer;
}

.reaction.is-mine {
    border-color: var(--color-accent);
    color: var(--color-accent-text);
    background: var(--color-accent);
}

.reaction-count {
    font-weight: 700;
}

.comment-list,
.reply-list,
.inbox-list,
.answer-list,
.heat-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.comment {
    padding: 0.75rem 0;
    border-top: 1px solid var(--color-border);
}

.comment-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin: 0 0 0.25rem;
}

.comment-body {
    margin: 0;
    overflow-wrap: anywhere;
}

.comment-reply {
    margin: 0.5rem 0 0 1rem;
    padding: 0.5rem 0 0 0.75rem;
    border-top: 0;
    border-left: 3px solid var(--color-accent);
}

.reply-box {
    margin-top: 0.5rem;
}

.comment-form {
    margin-top: 1rem;
}

.inline-form {
    display: inline;
}

.link-button {
    padding: 0;
    border: 0;
    font: inherit;
    font-size: 0.875rem;
    color: var(--color-accent);
    background: none;
    text-decoration: underline;
    cursor: pointer;
}

/* End-of-chapter check-in */
.checkin {
    margin-bottom: 1rem;
}

.checkin-question {
    margin: 1rem 0;
}

.checkin-question legend {
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.scale-row {
    display: flex;
    gap: 0.5rem;
}

/* Author side: wider pages, filters, tables */
.wide {
    max-width: 60rem;
    margin: 0 auto;
}

.filter-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.filter-bar .field {
    margin: 0;
}

.table-scroll {
    overflow-x: auto;
}

.data-table {
    min-width: 34rem;
}

.data-table,
.result-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td,
.result-table th,
.result-table td {
    padding: 0.625rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.data-table thead th,
.result-table thead th {
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.data-table tbody th {
    font-weight: 600;
}

.data-table .person-meta {
    display: block;
    font-weight: 400;
}

.percent-cell {
    white-space: nowrap;
}

.percent-cell .progress-bar {
    width: 5rem;
    margin: 0;
    vertical-align: middle;
}

.result-table .progress-bar {
    width: 6rem;
    margin: 0;
    vertical-align: middle;
}

.result-question {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
}

.answer-list li {
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-border);
}

.answer-list p {
    margin: 0;
}

/* Reaction heat map: one cell per paragraph */
.heat-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.heat-cell {
    width: 14px;
    height: 22px;
    border-radius: 3px;
}

.heat-cell a {
    display: block;
    width: 100%;
    height: 100%;
}

.heat-0 {
    background: color-mix(in srgb, var(--color-border) 60%, transparent);
}

.heat-1 {
    background: color-mix(in srgb, var(--color-accent) 25%, transparent);
}

.heat-2 {
    background: color-mix(in srgb, var(--color-accent) 45%, transparent);
}

.heat-3 {
    background: color-mix(in srgb, var(--color-accent) 70%, transparent);
}

.heat-4 {
    background: var(--color-accent);
}

.heat-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-left: 6px solid transparent;
    border-radius: 6px;
    background: var(--color-background);
}

.heat-row.heat-1 {
    border-left-color: color-mix(in srgb, var(--color-accent) 25%, transparent);
}

.heat-row.heat-2 {
    border-left-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
}

.heat-row.heat-3 {
    border-left-color: color-mix(in srgb, var(--color-accent) 70%, transparent);
}

.heat-row.heat-4 {
    border-left-color: var(--color-accent);
}

.heat-excerpt {
    color: var(--color-text);
    text-decoration: none;
}

.heat-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* Feedback inbox */
.inbox-item {
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
}

.inbox-item.is-handled {
    opacity: 0.65;
}

.excerpt-link {
    display: block;
    margin: 0.25rem 0 0.5rem;
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    color: var(--color-muted);
    text-decoration: none;
}

.reaction-label {
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.checkin-answers {
    margin: 0.5rem 0;
}

.checkin-answers dt {
    font-size: 0.875rem;
    color: var(--color-muted);
}

.checkin-answers dd {
    margin: 0 0 0.5rem;
}

/* Readers funnel */
.funnel {
    margin: 0;
    padding: 0;
    list-style: none;
}

.funnel-row {
    padding: 0.875rem 0;
    border-top: 1px solid var(--color-border);
}

.funnel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.funnel-bars {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.funnel-bar {
    display: grid;
    grid-template-columns: 7rem 1fr;
    align-items: center;
    font-size: 0.875rem;
}

.funnel-bar .progress-bar {
    width: 100%;
    max-width: 24rem;
    margin: 0;
}

.progress-finished {
    accent-color: var(--color-success);
}

.funnel-stopped {
    margin: 0.5rem 0 0.25rem;
}

/* Reading screen tools: display, notes, glossary, progress and time left */
.reader-tools {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.chapter-progress {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 -0.25rem;
    padding: 0.25rem;
    background: var(--color-background);
}

.chapter-progress-bar {
    display: block;
    width: 100%;
    height: 3px;
    margin: 0;
    border: 0;
    appearance: none;
    accent-color: var(--color-accent);
    background: var(--color-border);
}

.chapter-progress-bar::-webkit-progress-bar {
    background: var(--color-border);
}

.chapter-progress-bar::-webkit-progress-value {
    background: var(--color-accent);
}

.chapter-progress-bar::-moz-progress-bar {
    background: var(--color-accent);
}

.time-left {
    margin: 0.25rem 0 0;
    text-align: center;
}

.recap-card summary {
    font-weight: 600;
    cursor: pointer;
}

.recap-card p {
    margin: 0.5rem 0 0;
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

.jump-notice {
    margin: 0.75rem 0;
}

/* The phone's own long-press menu (select, look up) stays available on the text */
.chapter-text {
    -webkit-touch-callout: default;
    user-select: text;
}

/* Markers are never part of a selection or a highlight */
.para-feedback,
.para-bookmark {
    user-select: none;
    -webkit-user-select: none;
}

.para-bookmark {
    display: inline-flex;
    margin-right: 0.25rem;
    vertical-align: middle;
    color: var(--color-accent);
    cursor: pointer;
}

.para-bookmark .icon {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.personal-highlight {
    border-radius: 2px;
    color: inherit;
    background: color-mix(in srgb, #f2c94c 45%, transparent);
    cursor: pointer;
}

.para-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: -0.5em 0 1em;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.4;
    background: var(--color-surface);
}

.button-quiet {
    border-color: transparent;
    background: transparent;
}

.choice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Play bar rows: scrubber and quick actions on top, transport below */
.play-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.play-bar-top,
.play-bar-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.play-bar-controls {
    justify-content: space-between;
}

.play-bar .play-status {
    flex: none;
    min-height: 0;
    text-align: center;
}

.play-bar .play-status:empty {
    display: none;
}

.scrubber {
    flex: 1;
    min-width: 0;
    margin: 0 0.25rem;
    accent-color: var(--color-accent);
}

/* Speed slider, opened by holding the speed button */
.speed-popover {
    position: fixed;
    right: 0.5rem;
    bottom: calc(7.75rem + env(safe-area-inset-bottom));
    left: 0.5rem;
    z-index: 35;
    max-width: 34rem;
    margin: 0 auto;
    padding: 0.75rem 1rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-surface);
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.15);
}

.speed-popover h2 {
    margin: 0;
    font-size: 1.125rem;
}

.speed-popover input[type="range"],
#speed-slider {
    width: 100%;
    accent-color: var(--color-accent);
}

.speed-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-muted);
}

.speed-value {
    margin-left: 0.375rem;
    font-weight: 700;
    color: var(--color-accent);
}

.speed-presets-label {
    display: block;
    margin-top: 0.75rem;
}

/* Text display panel */
.display-panel .listen-group legend,
.display-panel .listen-group label {
    font-weight: 600;
}

.segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.segment {
    position: relative;
    display: inline-flex;
}

.segment input {
    position: absolute;
    opacity: 0;
}

.segment span {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-surface);
    cursor: pointer;
}

.segment input:checked + span {
    border-color: var(--color-accent);
    box-shadow: inset 0 0 0 1px var(--color-accent);
}

.segment input:focus-visible + span {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.segment-theme-light span {
    color: #1f1d1a;
    background: #ffffff;
}

.segment-theme-sepia span {
    color: #4a3b28;
    background: #f4ecd8;
}

.segment-theme-dark span {
    color: #ece7e0;
    background: #24211e;
}

.segment-font-serif span {
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

.segment-font-dyslexic span {
    font-family: "OpenDyslexic", "Atkinson Hyperlegible", Lexend, Verdana, Tahoma, sans-serif;
}

.display-panel input[type="range"] {
    width: 100%;
    accent-color: var(--color-accent);
}

/* Bookmark dialog */
.bookmark-dialog {
    width: min(30rem, calc(100vw - 2rem));
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    color: var(--color-text);
    background: var(--color-surface);
}

.bookmark-dialog::backdrop {
    background: rgb(0 0 0 / 0.4);
}

.bookmark-dialog h2 {
    margin: 0;
}

/* Bookmarks and highlights page */
.notes-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.note-item {
    margin-bottom: 0.75rem;
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
}

.note-meta .badge .icon {
    width: 0.875rem;
    height: 0.875rem;
    margin-right: 0.25rem;
}

.note-quote,
.note-preview {
    margin: 0 0 0.75rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--color-border);
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

.note-quote {
    border-left-color: #d9a520;
}

/* Glossary */
.glossary-list {
    margin: 0;
}

.glossary-entry {
    padding: 0.75rem 0;
    border-top: 1px solid var(--color-border);
}

.glossary-entry dt {
    font-weight: 700;
}

.glossary-entry dd {
    margin: 0.25rem 0 0;
}

.glossary-entry dd p {
    margin: 0 0 0.5rem;
}

.glossary-form {
    margin-top: 0.75rem;
}

/* Reader display choices (body classes from ReaderPrefs) */
body.theme-light {
    --color-background: #faf8f5;
    --color-surface: #ffffff;
    --color-text: #1f1d1a;
    --color-muted: #5f5a53;
    --color-border: #d9d3ca;
    --color-accent: #7a3b2e;
    --color-accent-text: #ffffff;
    --color-success: #2f6b3a;
    --color-danger: #a12c22;
    --color-focus: #1f5fbf;
    color-scheme: light;
}

body.theme-sepia {
    --color-background: #f4ecd8;
    --color-surface: #fbf5e6;
    --color-text: #4a3b28;
    --color-muted: #75644c;
    --color-border: #dccfb2;
    --color-accent: #8a4a2a;
    --color-accent-text: #fbf5e6;
    --color-success: #4d6b2f;
    --color-danger: #a12c22;
    --color-focus: #2e5aa8;
    color-scheme: light;
}

body.theme-dark {
    --color-background: #1a1816;
    --color-surface: #24211e;
    --color-text: #ece7e0;
    --color-muted: #aaa298;
    --color-border: #3d3833;
    --color-accent: #e0a08f;
    --color-accent-text: #1a1816;
    --color-success: #7cc48a;
    --color-danger: #f08a80;
    --color-focus: #7fb0ff;
    color-scheme: dark;
}

body.font-sans .chapter-text {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Bundled OpenDyslexic first, then common installed alternatives, with wider spacing */
body.font-dyslexic .chapter-text {
    font-family: "OpenDyslexic", "Atkinson Hyperlegible", Lexend, Verdana, Tahoma, sans-serif;
    letter-spacing: 0.03em;
    word-spacing: 0.12em;
}

body.text-size-1 .chapter-text {
    font-size: 1rem;
}

body.text-size-2 .chapter-text {
    font-size: 1.09375rem;
}

body.text-size-4 .chapter-text {
    font-size: 1.3125rem;
}

body.text-size-5 .chapter-text {
    font-size: 1.5rem;
}

body.text-size-6 .chapter-text {
    font-size: 1.75rem;
}

body.line-spacing-1 .chapter-text {
    line-height: 1.45;
}

body.line-spacing-3 .chapter-text {
    line-height: 2;
}

body.margins-1 .reader {
    max-width: 42rem;
}

body.margins-3 .reader {
    max-width: 32rem;
    padding: 0 1rem;
}

/* Google Drive import */
.search-row {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.search-row input {
    flex: 1;
    min-width: 0;
}

.drive-places {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}

.drive-places a[aria-current="page"] {
    font-weight: 700;
    text-decoration: none;
    color: var(--color-text);
}

.import-preview {
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
}

.import-preview h2 {
    margin-top: 0;
}

.import-preview-part {
    margin: 1rem 0 0.25rem;
    font-size: 1rem;
}

.import-preview-list {
    margin: 0 0 1rem;
    padding-left: 2rem;
}

.import-preview-list li + li {
    margin-top: 0.375rem;
}

.import-preview-title {
    display: block;
    font-weight: 600;
}

.drive-list {
    margin: 0.5rem 0;
    padding: 0;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.drive-list li + li {
    border-top: 1px solid var(--color-border);
}

.drive-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
}

.drive-item span .small {
    display: block;
}

.drive-account {
    margin-top: 2rem;
}

/* Check-in form builder */
.question-builder {
    margin: 0.75rem 0;
    padding: 0;
    list-style: none;
}

.question-row {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.question-row-new {
    border-style: dashed;
}

.question-row-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 0.75rem;
}

.question-row textarea {
    width: 100%;
}

/* Per-chapter voices */
.chapter-voices {
    margin: 0.75rem 0;
}

.chapter-voices summary {
    cursor: pointer;
    font-weight: 600;
}

.chapter-voice-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
    margin: 0.5rem 0;
}

/* Pronunciation page and publish-screen word checks */
.flag-list,
.name-list {
    display: grid;
    gap: 0.75rem;
    margin: 0.5rem 0 1.5rem;
    padding: 0;
    list-style: none;
}

.flag-list p {
    margin: 0;
}

.flag-entry {
    display: grid;
    gap: 0.25rem;
    margin: 0.75rem 0;
    padding-left: 0.75rem;
    border-left: 3px solid var(--color-border);
}

.flag-entry form {
    margin: 0;
}

.name-list {
    gap: 0.5rem;
    margin: 0;
}

.name-list li {
    display: grid;
    gap: 0.125rem;
}

.reading-choice {
    display: grid;
    gap: 0.25rem;
    margin: 0;
    padding: 0.75rem 0 0;
    border: 0;
    border-top: 1px solid var(--color-border);
}

.reading-choice legend {
    padding: 0;
    margin-bottom: 0.25rem;
    font-style: italic;
}

.reading-choice mark {
    padding: 0 0.125rem;
    font-style: normal;
    font-weight: 600;
    color: inherit;
    background: color-mix(in srgb, var(--color-accent) 18%, transparent);
    border-radius: 3px;
}

.preview-player {
    display: grid;
    gap: 0.25rem;
}

.preview-player audio {
    width: 100%;
}

/* Voice notes */
/* The recorder shows and hides its parts with the hidden attribute, which display rules would override */
.voice-note-form [hidden] {
    display: none;
}

.voice-note-form {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.voice-note-form h3 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}

.voice-recorder {
    align-items: center;
}

.voice-timer {
    font-variant-numeric: tabular-nums;
    color: var(--color-muted);
}

.voice-note-player {
    display: block;
    width: 100%;
    max-width: 28rem;
    margin: 0.25rem 0;
}

/* Media queries */
/* Cover, jacket and files */
.book-cover-image {
    object-fit: cover;
    padding: 0;
}

.book-heading {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.book-heading-text {
    flex: 1;
    min-width: 0;
}

.book-heading-cover {
    flex-shrink: 0;
    width: 5.5rem;
    margin-top: 0.5rem;
}

.book-heading-cover img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.cover-pair {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
}

.cover-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
    margin: 0;
}

.cover-card h2 {
    margin: 0;
}

.cover-link {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: inherit;
    text-decoration: none;
}

.cover-image {
    display: block;
    max-width: 100%;
    max-height: 22rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.file-tile {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--color-accent);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.jacket-copy-excerpt {
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    color: var(--color-muted);
}

.upload-box summary {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-weight: 600;
    cursor: pointer;
}

.upload-box[open] summary {
    margin-bottom: 1rem;
}

.file-view {
    margin: 1rem 0;
}

.file-image {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.jacket-copy,
.file-note {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.jacket-copy {
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    font-size: 1.05rem;
    line-height: 1.6;
}

.jacket-copy p:first-child,
.file-note p:first-child {
    margin-top: 0;
}

.jacket-copy p:last-child,
.file-note p:last-child {
    margin-bottom: 0;
}

.earlier-versions {
    margin: 1rem 0;
}

.earlier-versions summary {
    color: var(--color-accent);
    cursor: pointer;
}

/* Files from Google Docs */
.drive-source {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

.drive-doc {
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    font-size: 1.05rem;
    line-height: 1.6;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.drive-doc h2,
.drive-doc h3,
.drive-doc h4,
.drive-doc h5,
.drive-doc h6 {
    margin: 1.5rem 0 0.5rem;
    font-family: inherit;
}

.drive-doc > :first-child {
    margin-top: 0;
}

.drive-doc > :last-child {
    margin-bottom: 0;
}

.tab-depth-1 {
    padding-left: 1.75rem;
}

.tab-depth-2 {
    padding-left: 3.5rem;
}

.tab-depth-3 {
    padding-left: 5.25rem;
}

/* Google Drive picker, laid out like Drive itself */
.drive-link-form textarea {
    font-size: 0.9rem;
}

.drive-or {
    margin: 1.5rem 0 0.75rem;
    font-size: 0.875rem;
    text-align: center;
    color: var(--color-muted);
}

.gdrive {
    overflow: hidden;
    font-family: "Google Sans", Roboto, Arial, system-ui, sans-serif;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.gdrive-search {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin: 0.75rem;
    padding: 0 1rem;
    color: var(--color-muted);
    background: var(--color-drive-hover);
    border-radius: 999px;
}

.gdrive-search input {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0;
    background: transparent;
    border: 0;
}

.gdrive-search input:focus {
    outline: none;
}

.gdrive-search:focus-within {
    background: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.gdrive-places {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 0.75rem;
}

.gdrive-places a {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
    padding: 0.35rem 0.9rem;
    font-size: 0.875rem;
    color: var(--color-text);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: 999px;
}

.gdrive-places a[aria-current="page"] {
    font-weight: 600;
    background: var(--color-drive-selected);
    border-color: transparent;
}

.gdrive-path {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin: 1rem 0.75rem 0.5rem;
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 400;
}

.gdrive-path a {
    color: var(--color-muted);
    text-decoration: none;
}

.gdrive-path a:hover {
    text-decoration: underline;
}

.gdrive-path-separator {
    color: var(--color-muted);
}

.gdrive-header,
.gdrive-row {
    display: grid;
    grid-template-columns: 1.75rem 1.75rem minmax(0, 1fr) 6.5rem;
    gap: 0.5rem;
    align-items: center;
    padding: 0 0.75rem;
}

.gdrive-header {
    padding-bottom: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
}

.gdrive-header span:first-child {
    grid-column: 3;
}

.gdrive-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gdrive-list li + li {
    border-top: 1px solid var(--color-border);
}

.gdrive-row {
    min-height: 3rem;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
}

.gdrive-row:hover {
    background: var(--color-drive-hover);
}

.gdrive-row:has(input:checked) {
    background: var(--color-drive-selected);
}

.gdrive-check input {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    accent-color: var(--color-drive-doc);
}

.gdrive-icon {
    display: flex;
}

.gdrive-folder {
    color: var(--color-drive-folder);
}

.gdrive-doc {
    color: var(--color-drive-doc);
}

.gdrive-name {
    overflow: hidden;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.gdrive-modified {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.gdrive-empty {
    margin: 0.75rem;
}

.gdrive-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.gdrive .field-help {
    margin: 0.5rem 0.75rem 0.75rem;
}

/* Confirm chapters: moving rows and chapters left out */
.import-row-top {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    justify-content: space-between;
}

.move-buttons {
    display: flex;
    gap: 0.25rem;
}

.move-buttons[hidden] {
    display: none;
}

.unlikely-note {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.import-row:has(.include-toggle:not(:checked)) .import-fields,
.import-row:has(.include-toggle:not(:checked)) .excerpt {
    opacity: 0.55;
}

.import-preview-unlikely .import-preview-title {
    color: var(--color-muted);
    text-decoration: line-through;
}

.import-preview-unlikely .badge {
    margin: 0.2rem 0;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-background: #1a1816;
        --color-surface: #24211e;
        --color-text: #ece7e0;
        --color-muted: #aaa298;
        --color-border: #3d3833;
        --color-accent: #e0a08f;
        --color-accent-text: #1a1816;
        --color-success: #7cc48a;
        --color-danger: #f08a80;
        --color-focus: #7fb0ff;
        --color-drive-doc: #8ab4f8;
        --color-drive-folder: #bdc1c6;
        --color-drive-hover: #2d2a27;
        --color-drive-selected: #253246;
    }
}

@media (min-width: 48rem) {
    .page {
        padding-top: 2rem;
    }

    .question-row-fields {
        grid-template-columns: 1fr 1fr 6rem;
    }

    h1 {
        font-size: 2rem;
    }

    .sticky-save .button {
        width: auto;
    }

    .filter-bar {
        grid-template-columns: repeat(4, 1fr) auto;
    }

    .cover-pair {
        grid-template-columns: 1fr 1fr;
    }

    .book-heading-cover {
        width: 7rem;
    }

    .listen-panel,
    .feedback-sheet {
        right: auto;
        left: 50%;
        width: 34rem;
        transform: translateX(-50%);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto;
        transition: none;
    }
}

@media (hover: none) {
    /* No hover on touch screens: show the faint comment marker on every paragraph */
    .para-feedback {
        opacity: 0.35;
    }
}
