:root {
  color-scheme: light;
  --paper: #f4efe7;
  --paper-deep: #e9dfd2;
  --ink: #28231f;
  --muted: #7b7067;
  --line: rgba(65, 51, 39, 0.15);
  --accent: #a14d35;
  --accent-dark: #733b2b;
  --card: rgba(255, 252, 247, 0.84);
  --shadow: 0 24px 70px rgba(65, 46, 29, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  background: radial-gradient(circle at 8% 0%, rgba(181, 126, 78, 0.13), transparent 32rem), var(--paper);
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.site-shell { display: flex; width: min(1180px, calc(100% - 28px)); min-height: 100vh; margin: 0 auto; flex-direction: column; }
main { flex: 1; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 78px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; flex-direction: column; gap: 3px; color: var(--ink); text-decoration: none; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; letter-spacing: 0.03em; }
.brand span { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; }
.site-nav { display: flex; align-items: center; gap: 14px; }
.site-nav a, .text-button { color: var(--muted); font-size: 0.9rem; text-decoration: none; }
.site-nav a:hover, .text-button:hover { color: var(--accent-dark); }
.admin-nav-title { display: none; color: var(--accent-dark); font-size: 0.84rem; font-weight: 700; }
.text-button { padding: 0; border: 0; background: none; cursor: pointer; }
.user-menu { display: inline-flex; align-items: center; gap: 10px; }
.user-name { max-width: 120px; overflow: hidden; color: var(--ink); font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }

h1, h2, h3, .story-body { font-family: Georgia, "Times New Roman", serif; }
.hero { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: start; min-height: auto; padding: 52px 0 54px; }
.eyebrow { margin: 0 0 18px; color: var(--accent); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.hero h1 { max-width: 720px; margin: 0; font-size: clamp(2.35rem, 7vw, 3.8rem); font-weight: 500; letter-spacing: -0.055em; line-height: 1.02; }
.hero-copy { max-width: 520px; margin: 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; line-height: 1.8; }
.hero-rule { width: 76px; height: 1px; margin: 20px 0 16px; background: var(--accent); }
.hero-note { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.6; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 0 0 18px; flex-direction: column; }
.section-heading h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 500; letter-spacing: -0.04em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.book-index { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 34px; }
.book-index a { padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 252, 247, 0.56); color: var(--accent-dark); font-size: 0.82rem; text-decoration: none; }
.book-index a:hover { border-color: var(--accent); background: var(--card); }
.book-grid { display: grid; grid-template-columns: 1fr; gap: 16px; padding-bottom: 80px; }
.book-card { display: flex; align-items: stretch; min-height: 230px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease; }
.book-card:hover { border-color: rgba(161, 77, 53, 0.45); box-shadow: var(--shadow); transform: translateY(-5px); }
.book-card-cover { display: grid; flex: 0 0 115px; place-items: center; background: var(--accent); color: var(--paper); font-family: Georgia, "Times New Roman", serif; font-size: 3rem; }
.book-card-content { display: flex; min-width: 0; flex: 1; flex-direction: column; padding: 25px; }
.book-card-content .eyebrow { margin-bottom: 12px; }
.book-card-title { margin: 0 0 12px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 500; line-height: 1.15; }
.book-card-description { margin: 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; line-height: 1.75; }
.book-card-meta { display: flex; gap: 10px; margin-top: auto; padding-top: 22px; color: var(--accent-dark); font-size: 0.78rem; font-weight: 700; }
.catalog-page { max-width: 900px; margin: 0 auto; padding: 62px 0 110px; }
.catalog-page > .section-heading { margin-bottom: 28px; }
.admin-publish-area { margin-bottom: 26px; padding: 22px 24px; border: 1px solid rgba(161, 77, 53, 0.34); background: rgba(255, 252, 247, 0.76); }
.admin-publish-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 0; margin-bottom: 14px; padding: 0; border: 0; background: none; }
.admin-publish-bar .primary-button { min-height: 36px; }
.admin-publish-result { color: var(--muted); font-size: 0.76rem; white-space: normal; }
.admin-publish-main { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.admin-publish-main .eyebrow { margin-bottom: 8px; }
.admin-publish-main h2 { margin: 0 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.35rem, 3vw, 1.9rem); font-weight: 500; }
.admin-publish-main .admin-note { max-width: 650px; }
.admin-upload-panel { display: grid; gap: 20px; margin-top: 20px; }
.admin-upload-panel > .admin-note strong { color: var(--ink); }
.admin-upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 12px; margin: 14px 0; }
.admin-upload-grid input[type=file] { min-height: 44px; padding: 10px 0; border: 0; background: transparent; font-size: 0.8rem; }
.admin-upload-panel .primary-button { justify-self: start; margin-top: 2px; }
.admin-delete-panel { display: grid; gap: 20px; margin-top: 20px; }
.admin-delete-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.admin-danger-zone { display: grid; align-content: start; gap: 14px; padding: 20px; border: 1px solid rgba(161, 77, 53, 0.34); background: rgba(255, 248, 242, 0.62); }
.admin-danger-zone .eyebrow { margin-bottom: 0; }
.admin-danger-zone h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; font-weight: 500; }
.danger-button { justify-self: start; min-height: 42px; padding: 0 17px; border: 1px solid #963f2d; border-radius: 3px; background: transparent; color: #963f2d; cursor: pointer; font-weight: 700; }
.danger-button:hover:not(:disabled) { background: #963f2d; color: white; }
.danger-button:disabled { cursor: wait; opacity: 0.45; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 24px; padding: 5px; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.48); }
.admin-tab { min-height: 42px; padding: 0 18px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.88rem; font-weight: 700; }
.admin-tab:hover { color: var(--accent-dark); }
.admin-tab.active { border-bottom-color: var(--accent); background: var(--card); color: var(--accent-dark); }
.admin-view-intro { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin: 0 0 14px; }
.admin-view-intro .eyebrow { margin: 0; }
.admin-view-intro p:last-child { margin: 0; color: var(--muted); font-size: 0.84rem; }
.admin-panel { padding: 26px; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.56); }
.admin-screen-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.admin-screen-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 500; }
.admin-screen-heading .eyebrow { margin: 14px 0 8px; }
.admin-screen-heading .admin-note { max-width: 620px; }
.admin-screen[hidden] { display: none; }
.back-button { padding: 0; border: 0; background: none; color: var(--accent-dark); cursor: pointer; font-size: 0.84rem; font-weight: 700; }
.back-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.secondary-button { min-height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 3px; background: rgba(255, 252, 247, 0.72); color: var(--accent-dark); cursor: pointer; font-weight: 700; }
.secondary-button:hover:not(:disabled) { border-color: var(--accent); background: var(--card); }
.secondary-button:disabled, .primary-button:disabled { cursor: wait; opacity: 0.55; }
.compact-button { min-height: 34px; padding: 0 10px; font-size: 0.76rem; }
.compact-actions { align-items: center; margin: 0; }
.admin-page-form { width: min(760px, 100%); margin: 0; }
.admin-book-list { display: grid; gap: 14px; }
.admin-book-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border: 1px solid var(--line); background: var(--card); }
.admin-book-card-info { min-width: 0; }
.admin-book-card-info h3 { margin: 0 0 5px; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 500; }
.admin-book-card-info p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.admin-book-card-description { margin-top: 8px !important; font-family: Georgia, "Times New Roman", serif; font-size: 0.9rem !important; line-height: 1.5; }
.admin-book-card-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; flex: 0 0 auto; }
.icon-button { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 252, 247, 0.72); color: var(--accent-dark); cursor: pointer; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; line-height: 1; }
.icon-button.compact-button { width: 28px; height: 28px; min-height: 28px; padding: 0; }
.icon-button:hover:not(:disabled) { border-color: var(--accent); background: var(--card); transform: translateY(-1px); }
.icon-button.edit-icon { color: var(--accent-dark); }
.icon-button.catalog-icon { color: #4f7556; font-size: 0.9rem; }
.icon-button.delete-icon { border-color: rgba(150, 63, 45, 0.35); color: #963f2d; font-size: 1.2rem; }
.icon-button:disabled { cursor: wait; opacity: 0.5; }
.admin-status-toggle { min-height: 28px; min-width: 46px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 0.68rem; font-weight: 700; }
.admin-status-toggle.status-published { border-color: rgba(79, 117, 86, 0.35); background: rgba(79, 117, 86, 0.1); color: #4f7556; }
.admin-status-toggle.status-draft { border-color: rgba(161, 77, 53, 0.35); background: rgba(161, 77, 53, 0.09); color: var(--accent-dark); }
.admin-status-toggle.status-private { border-color: rgba(65, 51, 39, 0.25); background: rgba(65, 51, 39, 0.08); color: var(--muted); }
.admin-status-toggle:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.admin-status-toggle:disabled { cursor: wait; opacity: 0.55; }
.catalog-status-line { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; color: var(--muted); font-size: 0.82rem; }
.admin-directory-list { padding: 0; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.46); }
.admin-directory-tree { display: grid; gap: 2px; padding: 10px 0; }
.admin-directory-children { margin: 0 0 0 25px; padding-left: 14px; border-left: 1px solid rgba(161, 77, 53, 0.34); }
.admin-directory-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(95px, auto) 95px auto auto; align-items: center; gap: 6px; min-height: 38px; margin: 1px 8px; padding: 0; }
.admin-directory-row:last-child { border-bottom: 0; }
.admin-directory-title { min-width: 0; padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; text-align: left; }
.admin-directory-title:hover { color: var(--accent-dark); text-decoration: none; }
.admin-directory-title small { display: inline-block; margin-left: 9px; color: var(--muted); font-family: Inter, ui-sans-serif, sans-serif; font-size: 0.7rem; }
.admin-effective-status { color: var(--muted); font-size: 0.75rem; text-align: right; white-space: nowrap; }
.admin-effective-status.is-public { color: #4f7556; }
.admin-effective-status.is-hidden { color: var(--accent-dark); }
.admin-book-editor-panel { display: grid; gap: 20px; margin-bottom: 20px; }
.admin-editor-panel { display: grid; gap: 20px; margin-top: 20px; }
.admin-status-panel { display: grid; gap: 20px; margin-top: 20px; }
.status-overview-list { display: grid; gap: 18px; }
.status-book-card { overflow: hidden; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.5); }
.status-book-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: rgba(233, 223, 210, 0.42); }
.status-item-title { min-width: 0; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; font-weight: 500; }
.status-item-title small { display: block; margin-top: 4px; color: var(--muted); font-family: var(--font-sans, Inter, ui-sans-serif, sans-serif); font-size: 0.72rem; font-weight: 400; }
.status-item-control { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.status-tree { display: grid; gap: 1px; padding: 8px 0; }
.status-node-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, auto) 110px; align-items: center; gap: 14px; padding: 10px 20px 10px calc(20px + var(--status-depth) * 22px); border-bottom: 1px solid rgba(65, 51, 39, 0.08); }
.status-node-row:last-child { border-bottom: 0; }
.status-node-title { font-size: 0.98rem; }
.status-node-title small { display: inline-block; margin: 0 0 0 9px; }
.status-visibility { color: var(--muted); font-size: 0.76rem; text-align: right; white-space: nowrap; }
.status-visibility.is-public { color: #4f7556; }
.status-visibility.is-hidden { color: var(--accent-dark); }
.status-select { min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 3px; background: rgba(255, 255, 255, 0.58); color: var(--ink); }
.status-select:disabled { cursor: wait; opacity: 0.6; }
.admin-editor-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding-bottom: 4px; }
.admin-editor-heading .eyebrow { margin-bottom: 8px; }
.admin-editor-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0; }
.admin-note { margin: 0; color: var(--muted); line-height: 1.75; }
.admin-log { min-height: 90px; margin: 20px 0 0; padding: 15px; background: #302b27; color: #f6eee5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; line-height: 1.65; white-space: pre-wrap; }
.admin-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 14px; }
.admin-field { display: grid; gap: 8px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.admin-field input, .admin-field select, .admin-field textarea { width: 100%; border: 1px solid var(--line); border-radius: 3px; background: rgba(255, 255, 255, 0.55); color: var(--ink); outline: none; }
.admin-field input, .admin-field select { min-height: 44px; padding: 0 12px; }
.admin-field textarea { min-height: 270px; padding: 12px; resize: vertical; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; font-weight: 400; line-height: 1.75; }
.admin-field input:focus, .admin-field select:focus, .admin-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(161, 77, 53, 0.12); }
.admin-field input:disabled, .admin-field select:disabled, .admin-field textarea:disabled { cursor: wait; opacity: 0.6; }
.admin-editor-status { min-height: 1.4em; margin: -8px 0 0; color: var(--muted); font-size: 0.82rem; }
.admin-create-panel { display: grid; gap: 20px; margin-top: 20px; }
.admin-create-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.admin-create-panel > .admin-form { max-width: 760px; }
.admin-form { display: grid; align-content: start; gap: 14px; padding: 20px; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.45); }
.admin-form h3 { margin: 0 0 4px; font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; font-weight: 500; }
.admin-form .primary-button { justify-self: start; margin-top: 4px; }
.book-directory { margin: 0 0 38px; padding: 27px; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.54); }
.book-directory-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.book-directory-header h3 { margin: 0 0 8px; font-size: clamp(1.55rem, 3vw, 2.35rem); font-weight: 500; line-height: 1.15; }
.book-directory-header p { max-width: 680px; margin: 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; line-height: 1.75; }
.book-directory-count { flex: 0 0 auto; color: var(--muted); font-size: 0.78rem; }
.directory-tree, .directory-tree ul { margin: 0; padding: 0; list-style: none; }
.directory-tree { padding-top: 18px; }
.directory-tree ul { margin-left: 19px; border-left: 1px solid var(--line); }
.directory-tree li { margin: 2px 0; }
.directory-link { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; width: 100%; padding: 9px 10px; border-left: 2px solid transparent; color: var(--ink); font-family: Georgia, "Times New Roman", serif; line-height: 1.45; text-decoration: none; }
.directory-link:hover { border-left-color: var(--accent); background: rgba(233, 223, 210, 0.55); color: var(--accent-dark); }
.directory-link.section { color: var(--accent-dark); font-weight: 700; }
.directory-link small { flex: 0 0 auto; color: var(--muted); font-family: inherit; font-size: 0.72rem; font-weight: 400; }
.admin-directory-row { display: flex; align-items: center; gap: 6px; min-height: 0; margin: 2px 8px; padding: 0; }
.admin-directory-title { flex: 1 1 auto; width: auto; min-width: 0; }
.admin-directory-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; width: 114px; min-width: 114px; flex: 0 0 114px; }
.empty-state { padding: 60px 28px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }

.reader-page { max-width: 900px; margin: 0 auto; padding: 62px 0 110px; }
.reader-topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 52px; color: var(--muted); font-size: 0.84rem; }
.reader-back { color: var(--accent-dark); text-decoration: none; }
.reader-back:hover { text-decoration: underline; text-underline-offset: 4px; }
.reader-book-name { max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-header { padding-bottom: 35px; border-bottom: 1px solid var(--line); }
.reader-header h1 { max-width: 800px; margin: 0; font-size: clamp(2.7rem, 7vw, 5.8rem); font-weight: 500; line-height: 0.98; }
.story-meta { display: flex; flex-wrap: wrap; gap: 9px 20px; margin-top: 24px; color: var(--muted); font-size: 0.83rem; }
.story-meta strong { color: var(--accent-dark); font-weight: 600; }
.story-body { padding: 48px 0 58px; font-size: 1.2rem; line-height: 1.95; }
.story-body h1, .story-body h2, .story-body h3 { margin: 1.8em 0 0.55em; font-weight: 500; letter-spacing: -0.03em; line-height: 1.15; }
.story-body h1 { font-size: 2.1rem; }
.story-body h2 { font-size: 1.75rem; }
.story-body h3 { font-size: 1.4rem; }
.story-body p { margin: 0 0 1.25em; }
.story-body a { color: var(--accent-dark); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.story-body blockquote { margin: 1.5em 0; padding: 0 0 0 24px; border-left: 2px solid var(--accent); color: var(--accent-dark); }
.story-body ul { padding-left: 1.2em; }
.story-body code { padding: 0.12em 0.35em; border-radius: 4px; background: var(--paper-deep); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78em; }
.story-body pre { overflow-x: auto; padding: 18px; border-radius: 6px; background: #302b27; color: #f6eee5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78em; line-height: 1.6; }
.story-body pre code { padding: 0; background: none; }
.story-image { display: block; max-width: 100%; margin: 30px auto; border-radius: 4px; }
.story-footer { display: flex; flex-wrap: wrap; gap: 10px 22px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }
.reader-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 26px 0 0; }
.reader-nav-button { display: flex; min-height: 72px; flex-direction: column; justify-content: center; padding: 12px 15px; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.55); color: var(--ink); cursor: pointer; text-align: left; }
.reader-nav-button.next { align-items: end; text-align: right; }
.reader-nav-button:hover:not(:disabled) { border-color: rgba(161, 77, 53, 0.55); background: var(--card); }
.reader-nav-button:disabled { cursor: default; opacity: 0.35; }
.reader-nav-label { margin-bottom: 4px; color: var(--muted); font-size: 0.72rem; }
.reader-nav-title { font-family: Georgia, "Times New Roman", serif; font-size: 1rem; }

.comments { padding-top: 70px; }
.comments h2 { margin: 0 0 8px; font-size: 2rem; font-weight: 500; }
.comments-intro { margin: 0 0 24px; color: var(--muted); font-size: 0.88rem; }
.comment-form { display: grid; gap: 12px; margin-bottom: 38px; padding: 20px; border: 1px solid var(--line); background: rgba(255, 252, 247, 0.55); }
.comment-form label { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.comment-form input, .comment-form textarea, .auth-form input { width: 100%; border: 1px solid var(--line); border-radius: 3px; background: rgba(255, 255, 255, 0.55); color: var(--ink); outline: none; }
.comment-form input, .auth-form input { min-height: 44px; padding: 0 12px; }
.comment-form textarea { min-height: 110px; padding: 12px; resize: vertical; }
.comment-form input:focus, .comment-form textarea:focus, .auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(161, 77, 53, 0.12); }
.comment-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.check-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; }
.check-label input { width: auto; min-height: auto; }
.primary-button { min-height: 42px; padding: 0 17px; border: 0; border-radius: 3px; background: var(--accent); color: white; cursor: pointer; font-weight: 700; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { cursor: wait; opacity: 0.6; }
.comment-status, .auth-status { min-height: 1.4em; margin: 0; color: var(--muted); font-size: 0.82rem; }
.comment-list { display: grid; gap: 18px; }
.comment { padding: 0 0 18px; border-bottom: 1px solid var(--line); }
.comment-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.comment-author { font-size: 0.9rem; font-weight: 700; }
.comment-date { color: var(--muted); font-size: 0.75rem; }
.comment-body { margin: 0; color: #5a5048; line-height: 1.75; white-space: pre-wrap; }
.comments-empty { color: var(--muted); font-family: Georgia, "Times New Roman", serif; }

dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(37, 29, 23, 0.45); backdrop-filter: blur(3px); }
.dialog-content { padding: 28px; }
.dialog-top { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.dialog-top h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; }
.close-button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.4rem; line-height: 1; }
.auth-tabs { display: flex; gap: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.auth-tab { padding: 0 0 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); cursor: pointer; font-weight: 700; }
.auth-tab.active { border-color: var(--accent); color: var(--accent-dark); }
.auth-form { display: grid; gap: 12px; }
.auth-form label { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.auth-form .primary-button { margin-top: 5px; }
.site-footer { display: flex; justify-content: space-between; gap: 18px; padding: 24px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.75rem; }

@media (min-width: 700px) {
  .site-shell { width: min(1180px, calc(100% - 40px)); }
  .section-heading { align-items: end; flex-direction: row; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
}
@media (min-width: 1040px) {
  .site-header { min-height: 92px; }
  .hero { grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: end; min-height: 430px; padding: 86px 0 74px; }
  .hero h1 { font-size: clamp(3.1rem, 9vw, 7.2rem); letter-spacing: -0.065em; line-height: 0.93; }
  .hero-copy { margin: 0 0 6px auto; font-size: 1.18rem; }
  .hero-rule { margin: 24px 0 20px auto; }
  .hero-note { margin: 0 0 0 auto; text-align: right; }
  .book-directory { padding: 34px; }
}
@media (max-width: 699px) {
  .site-header { min-height: 76px; }
  .site-nav { gap: 10px; }
  .site-nav > a { display: none; }
  .admin-page-heading { display: none; }
  .admin-nav-title { display: inline-flex; }
  .book-directory { padding: 20px 16px; }
  .book-card { min-height: 190px; }
  .book-card-cover { flex-basis: 82px; font-size: 2.3rem; }
  .book-card-content { padding: 20px 17px; }
  .catalog-page { padding-top: 44px; }
  .book-directory-header { align-items: flex-start; flex-direction: column; gap: 10px; }
  .reader-page { padding-top: 44px; }
  .reader-topbar { align-items: flex-start; flex-direction: column; gap: 8px; margin-bottom: 38px; }
  .reader-book-name { max-width: 100%; }
  .story-body { font-size: 1.1rem; }
  .comment-actions, .site-footer { align-items: flex-start; flex-direction: column; }
  .admin-editor-heading { align-items: flex-start; flex-direction: column; }
  .admin-screen-heading { align-items: flex-start; flex-direction: column; }
  .admin-screen-heading .compact-actions { width: 100%; }
  .admin-screen-heading .compact-actions > * { flex: 1 1 0; }
  .admin-book-card { align-items: flex-start; flex-direction: column; padding: 18px; }
  .admin-book-card-controls { justify-content: flex-start; width: 100%; }
  .admin-book-card-controls > .admin-status-toggle { flex: 0 0 auto; }
  .admin-book-card-controls > .icon-button { flex: 0 0 34px; }
  .admin-directory-children { margin-left: 14px; margin-right: 0; padding-left: 8px; }
  .admin-directory-row { display: flex; gap: 4px; margin-left: 4px; margin-right: 4px; }
  .admin-directory-actions { width: 110px; min-width: 110px; flex-basis: 110px; gap: 4px; }
  .admin-editor-grid { grid-template-columns: 1fr; }
  .admin-create-grid { grid-template-columns: 1fr; }
  .admin-upload-grid { grid-template-columns: 1fr; }
  .admin-delete-grid { grid-template-columns: 1fr; }
  .status-book-header { align-items: flex-start; flex-direction: column; }
  .status-item-control { width: 100%; justify-content: space-between; }
  .status-node-row { grid-template-columns: minmax(0, 1fr) 100px; gap: 8px 12px; padding-left: calc(14px + var(--status-depth) * 16px); padding-right: 14px; }
  .status-node-row .status-visibility { grid-column: 1; grid-row: 2; text-align: left; }
  .status-node-row .status-select { grid-column: 2; grid-row: 1 / span 2; }
  .admin-publish-main { align-items: flex-start; flex-direction: column; }
  .admin-publish-main .primary-button { width: 100%; }
  .admin-publish-bar { justify-content: flex-end; flex-wrap: wrap; }
  .admin-publish-bar .primary-button { flex: 0 0 auto; }
  .admin-publish-result { flex-basis: 100%; text-align: right; }
  .admin-tabs { margin-right: -4px; margin-left: -4px; }
  .admin-tab { flex: 1 1 0; padding: 0 10px; }
  .admin-view-intro { align-items: flex-start; flex-direction: column; gap: 5px; }
}
@media (max-width: 420px) {
  .user-name { max-width: 88px; }
  .reader-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .reader-nav-button { min-width: 0; padding: 12px 10px; }
  .reader-nav-button.next { align-items: end; text-align: right; }
}

/* Some Android browsers expose a desktop-sized CSS viewport in mobile mode. */
@media (pointer: coarse), (hover: none) {
  .site-shell { width: min(100% - 28px, 1180px); }
  .site-header { min-height: 76px; }
  .site-nav > a { display: none; }
  .admin-page-heading { display: none; }
  .admin-nav-title { display: inline-flex; }
  .hero { grid-template-columns: 1fr; gap: 28px; min-height: auto; padding: 52px 0 54px; }
  .hero h1 { font-size: clamp(2.35rem, 7vw, 3.8rem); letter-spacing: -0.055em; line-height: 1.02; }
  .hero-copy { margin: 0; font-size: 1.08rem; }
  .hero-rule { margin: 20px 0 16px; }
  .hero-note { margin: 0; text-align: left; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .book-directory { padding: 20px 16px; }
  .book-grid { gap: 14px; }
  .book-card-cover { flex-basis: 76px; }
}
