/* Portal: accounts, library, collaborative proofreading, admin */

body.portal-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 18% 0%, rgba(255, 252, 244, 0.7), transparent 42%),
    var(--paper);
}

.portal-main {
  padding: 46px 0 90px;
}

.portal-header .header-inner {
  height: 68px;
}

.portal-header .main-nav {
  display: flex;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: 11px;
  white-space: nowrap;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cinnabar);
  color: #fff5e5;
  font-family: var(--serif);
  font-size: 12px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.25;
}

.user-meta small {
  color: var(--muted-2);
  font-size: 8px;
}

.portal-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 30px;
}

.portal-title-row h1 {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-size: clamp(38px, 4.4vw, 58px);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.01em;
}

.portal-title-row h1 em {
  color: var(--cinnabar);
  font-style: normal;
}

.portal-sub {
  max-width: 460px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.category-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.category-chip {
  height: 29px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 30px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-chip:hover {
  color: var(--ink);
  border-color: var(--line);
}

.category-chip.is-active {
  background: var(--ink);
  color: #f8f1e4;
  border-color: var(--ink);
}

.library-search {
  position: relative;
  width: min(260px, 34vw);
  flex: none;
}

.library-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255, 253, 247, 0.45);
  color: var(--ink);
  font-size: 11px;
  outline: none;
}

.library-search input:focus {
  border-color: var(--cinnabar);
}

.library-search svg {
  position: absolute;
  left: 10px;
  top: 9px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 22px;
  padding-top: 28px;
}

.book-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease),
    border-color 0.35s ease;
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: rgba(54, 46, 34, 0.28);
  box-shadow: 0 25px 42px -34px rgba(42, 33, 22, 0.5);
}

.book-cover {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background:
    linear-gradient(145deg, #e7dcc7, #d8c9b0);
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  transition: transform 0.7s var(--ease);
}

.book-card:hover .book-cover img {
  transform: scale(1.025);
}

.book-cover.is-empty {
  display: grid;
  place-items: center;
}

.book-cover.is-empty::after {
  content: "识古";
  color: rgba(95, 72, 43, 0.22);
  font-family: var(--serif);
  font-size: 44px;
  letter-spacing: 0.15em;
}

.book-status {
  position: absolute;
  left: 11px;
  top: 11px;
  padding: 4px 7px;
  background: rgba(250, 245, 234, 0.9);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  backdrop-filter: blur(4px);
}

.book-status.is-done {
  color: var(--jade);
}

.book-published {
  position: absolute;
  right: 11px;
  top: 11px;
  padding: 4px 7px;
  border: 1px solid rgba(164, 59, 43, 0.3);
  background: rgba(255, 249, 239, 0.92);
  color: var(--cinnabar);
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.book-publish {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  height: 25px;
  margin-top: 8px;
  padding: 0 9px;
  border: 1px solid rgba(164, 59, 43, 0.35);
  background: transparent;
  color: var(--cinnabar);
  font-family: var(--sans);
  font-size: 8px;
  cursor: pointer;
}

.book-publish:hover {
  background: rgba(164, 59, 43, 0.06);
}

.book-publish.is-live {
  border-color: var(--line);
  color: var(--muted);
}

.book-publish:disabled {
  opacity: 0.5;
}

.book-body {
  padding: 16px 16px 14px;
}

.book-cat {
  margin: 0 0 5px;
  color: var(--muted-2);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.book-body h3 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}

.book-author {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 9px;
}

.book-tag {
  padding: 2px 6px;
  border: 1px solid rgba(72, 96, 79, 0.22);
  border-radius: 20px;
  background: rgba(72, 96, 79, 0.045);
  color: #536b4d;
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.book-tag:hover {
  border-color: rgba(72, 96, 79, 0.5);
  background: rgba(72, 96, 79, 0.1);
}

.book-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 15px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.book-members {
  display: flex;
  align-items: center;
  padding-left: 3px;
}

.mini-avatar {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  margin-left: -4px;
  border: 2px solid var(--paper-soft);
  border-radius: 50%;
  color: #fff7e9;
  font-family: var(--sans);
  font-size: 8px;
}

.book-progress {
  flex: 1;
  min-width: 0;
  margin-left: 12px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.03em;
}

.progress-track-portal {
  height: 2px;
  margin-top: 5px;
  background: rgba(54, 46, 34, 0.12);
}

.progress-track-portal i {
  display: block;
  height: 100%;
  background: var(--jade);
}

.empty-library {
  grid-column: 1 / -1;
  padding: 80px 20px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}

.empty-library h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink-2);
}

.empty-library p {
  margin: 0;
  font-size: 11px;
}

/* auth */

.auth-page {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, 0.92fr);
  min-height: 100vh;
  background: var(--paper);
}

.auth-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 52px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 90% 10%, rgba(164, 59, 43, 0.2), transparent 45%),
    linear-gradient(150deg, #23201a, #171510);
  color: #eee5d4;
}

.auth-visual::after {
  content: "识古";
  position: absolute;
  right: -50px;
  bottom: -80px;
  color: rgba(255, 255, 255, 0.035);
  font-family: var(--serif);
  font-size: 390px;
  line-height: 1;
  writing-mode: vertical-rl;
  pointer-events: none;
}

.auth-visual .brand {
  color: #f0e7d7;
}

.auth-visual .brand-seal {
  color: #d98670;
  border-color: #d98670;
}

.auth-visual .brand-type small {
  color: #8d8371;
}

.auth-quote {
  position: relative;
  z-index: 1;
  max-width: 540px;
}

.auth-quote p {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-size: clamp(36px, 4.2vw, 58px);
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.auth-quote p em {
  color: #d9846b;
  font-style: normal;
}

.auth-quote cite {
  color: #8e8371;
  font-family: var(--sans);
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.2em;
}

.auth-note {
  position: relative;
  z-index: 1;
  color: #7d7362;
  font-size: 9px;
  letter-spacing: 0.05em;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 50px clamp(34px, 7vw, 96px);
}

.auth-panel h1 {
  margin: 18px 0 8px;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
}

.auth-panel .auth-hint {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

.auth-tabs {
  display: flex;
  gap: 23px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  padding: 0 0 11px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.auth-tab.is-active {
  color: var(--ink);
  border-bottom: 2px solid var(--cinnabar);
}

.category-picker {
  display: flex;
  align-items: center;
  gap: 7px;
}

.category-picker select {
  flex: 1;
  min-width: 0;
}

.category-picker .portal-small-btn {
  flex: none;
  white-space: nowrap;
}

.category-create {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.category-create[hidden] {
  display: none;
}

.category-create input {
  flex: 1;
  min-width: 0;
  height: 31px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 11px;
  outline: none;
}

.category-create input:focus {
  border-color: var(--cinnabar);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.draft-hint {
  margin: -10px 0 16px;
  padding: 7px 9px;
  border-left: 2px solid var(--jade);
  background: rgba(72, 96, 79, 0.07);
  color: var(--jade);
  font-size: 9px;
  line-height: 1.6;
}

.draft-hint[hidden] {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255, 253, 247, 0.42);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.7;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--cinnabar);
  box-shadow: 0 0 0 2px rgba(164, 59, 43, 0.08);
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-alt {
  margin: 22px 0 0;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.8;
}

.form-error {
  margin: 0;
  color: var(--cinnabar);
  font-size: 10px;
  line-height: 1.6;
}

/* modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(23, 19, 14, 0.72);
  backdrop-filter: blur(7px);
}

.modal-backdrop.is-open {
  display: grid;
}

.modal-card {
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 28px;
  background: var(--paper-soft);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.35);
}

.modal-card h2 {
  margin: 0 0 5px;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
}

.modal-card .modal-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

.modal-close {
  float: right;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.modal-close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
}

/* admin */

.admin-tabs {
  display: flex;
  gap: 22px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.admin-tab {
  padding: 0 0 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.admin-tab.is-active {
  color: var(--ink);
  border-bottom: 2px solid var(--cinnabar);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.stat-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.35);
}

.stat-card span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.stat-card b {
  display: block;
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.data-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-align: left;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 253, 247, 0.32);
}

.data-table select,
.data-table input {
  height: 29px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  font-size: 10px;
}

.row-actions {
  display: flex;
  gap: 9px;
}

.text-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--cinnabar);
  font-size: 10px;
  cursor: pointer;
}

.text-btn.muted {
  color: var(--muted);
}

/* collaborative editor */

.book-body-page {
  height: 100vh;
  overflow: hidden;
}

.book-topbar {
  height: 66px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: rgba(243, 237, 225, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.book-topbar .book-crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.book-topbar .book-crumb a {
  color: var(--muted);
  font-size: 10px;
  text-decoration: none;
}

.book-topbar .book-crumb b {
  overflow: hidden;
  max-width: 300px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-topbar .top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 224px minmax(360px, 1fr) minmax(470px, 0.92fr);
  height: calc(100vh - 66px);
  min-height: 0;
}

.page-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper-deep);
  border-right: 1px solid var(--line);
}

.page-rail-head {
  padding: 17px 16px 13px;
  border-bottom: 1px solid var(--line);
}

.page-rail-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}

.page-rail-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.page-list {
  flex: 1;
  overflow-y: auto;
  padding: 9px;
}

.page-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.page-item:hover {
  background: rgba(255, 253, 247, 0.4);
}

.page-item.is-active {
  background: var(--paper-soft);
  border-color: var(--line-strong);
}

.page-thumb {
  width: 36px;
  height: 48px;
  flex: none;
  overflow: hidden;
  background: #d8cab1;
}

.page-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-item-text {
  min-width: 0;
}

.page-item-text b {
  display: block;
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 500;
}

.page-item-text small {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7px;
}

.page-item .page-state {
  width: 5px;
  height: 5px;
  margin-left: auto;
  flex: none;
  border-radius: 50%;
  background: var(--muted-2);
}

.page-item .page-state.is-done {
  background: var(--jade);
}

.page-rail-foot {
  padding: 10px;
  border-top: 1px solid var(--line);
}

.book-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(90, 79, 62, 0.28), transparent 62%),
    var(--dark);
}

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(244, 234, 215, 0.1);
  color: #bdb29d;
  font-size: 9px;
}

.stage-bar .stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.region-preview {
  width: 132px;
  height: 132px;
  margin: 0 0 17px;
  border: 1px solid var(--line-strong);
  background-color: #f4eddc;
  background-repeat: no-repeat;
}

.stage-image-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 18px;
}

.stage-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.7);
}

.stage-image-box {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
}

.stage-image-box > img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 170px);
  object-fit: contain;
}

.page-seal {
  position: absolute;
  right: 5.5%;
  top: 7%;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border: 2px solid rgba(164, 59, 43, 0.82);
  border-radius: 3px;
  box-shadow: inset 0 0 0 3px rgba(164, 59, 43, 0.18);
  color: rgba(164, 59, 43, 0.86);
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.08em;
  line-height: 1;
  transform: rotate(-8deg);
  pointer-events: none;
  text-shadow: 0 0 1px rgba(164, 59, 43, 0.25);
}

.thumb-seal {
  position: absolute;
  right: 2px;
  bottom: 2px;
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border: 1px solid rgba(164, 59, 43, 0.85);
  border-radius: 2px;
  background: rgba(250, 244, 232, 0.65);
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 7px;
  line-height: 1;
  transform: rotate(-7deg);
}

.page-thumb {
  position: relative;
}

.region-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  cursor: pointer;
  touch-action: none;
}

.region-layer.is-selecting {
  cursor: crosshair;
}

.region-marquee {
  position: absolute;
  border: 1px solid #ef7d63;
  background: rgba(164, 59, 43, 0.16);
  box-shadow: 0 0 0 9999px rgba(20, 16, 12, 0.16);
  pointer-events: none;
}

.ignored-region {
  position: absolute;
  border: 1px dashed rgba(164, 59, 43, 0.8);
  background:
    repeating-linear-gradient(
      135deg,
      rgba(164, 59, 43, 0.08),
      rgba(164, 59, 43, 0.08) 5px,
      rgba(164, 59, 43, 0.16) 5px,
      rgba(164, 59, 43, 0.16) 7px
    );
  pointer-events: none;
}

.ignored-region::after {
  content: "不识别";
  position: absolute;
  left: 3px;
  top: 3px;
  padding: 1px 3px;
  background: rgba(164, 59, 43, 0.82);
  color: #fff4e4;
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.stage-empty {
  color: #8f8471;
  font-family: var(--serif);
  font-size: 16px;
  text-align: center;
}

.proof-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper-soft);
  border-left: 1px solid var(--line);
}

.proof-head {
  padding: 15px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.proof-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.proof-title-row h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}

.proof-title-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.book-tagline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 0;
}

.book-tagline .book-tag {
  font-size: 7px;
  padding: 1px 5px;
}

.proof-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.proof-badge {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  font-size: 8px;
}

.proof-badge.is-done {
  color: var(--jade);
  border-color: rgba(72, 96, 79, 0.3);
}

.member-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 10px;
}

.member-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 8px;
}

.member-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.proof-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 8px;
}

.proof-toolbar .sync-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.feedback-info {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 8px;
}

.proof-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.proof-tools .text-btn {
  font-size: 8px;
}

.proof-tools .text-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.proof-tools .text-btn.is-on {
  color: var(--cinnabar);
  font-weight: 600;
}

.sync-led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--jade);
}

.sync-led.is-saving {
  background: var(--amber);
}

.sync-led.is-alert {
  background: var(--cinnabar);
}

.proof-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 20px;
}

.portal-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: max-content;
}

.portal-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  width: max-content;
  padding: 2px 0;
}

.portal-row.is-located {
  background: rgba(164, 59, 43, 0.08);
  box-shadow: inset 2px 0 0 rgba(164, 59, 43, 0.55);
  animation: located-pulse 1.2s ease;
}

@keyframes located-pulse {
  0% { background: rgba(164, 59, 43, 0.22); }
  100% { background: rgba(164, 59, 43, 0.08); }
}

.portal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 38px;
  flex: none;
  padding: 3px 0;
  border-radius: 2px;
  cursor: text;
}

.portal-cell:hover {
  background: rgba(164, 59, 43, 0.06);
}

.portal-cell.is-active {
  background: rgba(164, 59, 43, 0.1);
}

.portal-cell.is-box-selected {
  background: rgba(164, 59, 43, 0.13);
  box-shadow: inset 0 0 0 1px rgba(164, 59, 43, 0.55);
}

.box-select-rect {
  position: fixed;
  z-index: 600;
  border: 1px solid var(--cinnabar);
  background: rgba(164, 59, 43, 0.12);
  pointer-events: none;
}

.cell-crop {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(54, 46, 34, 0.12);
  background-color: #f4eddc;
  background-repeat: no-repeat;
}

.portal-cell.is-active .cell-crop {
  border-color: var(--cinnabar);
  box-shadow: 0 0 0 2px rgba(164, 59, 43, 0.15);
}

.proof-scroll.is-drag-mode .portal-cell {
  cursor: grab;
  touch-action: none;
}

.proof-scroll.is-drag-mode .portal-cell:active {
  cursor: grabbing;
}

.portal-cell.is-dragging {
  opacity: 0.28;
}

.portal-cell.drop-before::before,
.portal-cell.drop-after::after {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  background: var(--cinnabar);
  box-shadow: 0 0 0 1px rgba(164, 59, 43, 0.16);
  z-index: 4;
}

.portal-cell.drop-before::before {
  left: -2px;
}

.portal-cell.drop-after::after {
  right: -2px;
}

.cell-drag-ghost {
  position: fixed;
  z-index: 300;
  margin: 0;
  pointer-events: none;
  opacity: 0.92;
  transform: translate(-50%, -50%) rotate(-2deg);
  box-shadow: 0 12px 28px -14px rgba(37, 29, 19, 0.55);
  background: var(--paper-soft);
}

.portal-cell.is-ignored {
  width: 48px;
  padding: 2px;
  background: rgba(164, 59, 43, 0.055);
  border: 1px dashed rgba(164, 59, 43, 0.3);
}

.portal-cell.is-ignored:hover {
  background: rgba(164, 59, 43, 0.09);
}

.portal-cell.is-ignored .cell-crop {
  width: 38px;
  height: 38px;
  border-style: dashed;
  background-color: #fff;
  background-size: contain;
}

.ignore-label {
  color: var(--cinnabar);
  font-family: var(--sans);
  font-size: 6px;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ignore-gallery {
  margin: 0 0 8px;
  padding: 7px 8px;
  border: 1px dashed rgba(164, 59, 43, 0.28);
  background: rgba(164, 59, 43, 0.035);
}

.ignore-gallery-title {
  display: block;
  margin-bottom: 5px;
  color: var(--cinnabar);
  font-size: 7px;
  letter-spacing: 0.04em;
}

.ignore-gallery-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ignore-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--cinnabar);
  font-size: 6px;
}

.ignore-card-image {
  width: 62px;
  height: 62px;
  border: 1px dashed rgba(164, 59, 43, 0.38);
  background-color: #fff;
  background-repeat: no-repeat;
}

.cell-crop.is-bw,
.portal-edit-preview.is-bw {
  background-color: #fff;
}

.cell-text {
  min-height: 1.1em;
  font-family: var(--serif);
  font-size: 10px;
  line-height: 1.15;
  color: var(--ink);
  white-space: nowrap;
}

.portal-cell.is-active .cell-text {
  color: var(--cinnabar);
}

.portal-cell.has-draft::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--amber);
}

.cell-editor-tag {
  position: absolute;
  right: -2px;
  top: -8px;
  z-index: 2;
  max-width: 54px;
  padding: 1px 4px;
  overflow: hidden;
  border-radius: 2px;
  color: #fff8eb;
  font-family: var(--sans);
  font-size: 7px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.portal-empty-proof {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  line-height: 1.9;
}

.portal-editbar {
  flex: none;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper-deep);
}

.portal-editbar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 8px;
}

.portal-editbar-head b {
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.portal-edit-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.portal-edit-preview {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  font-family: var(--serif);
  font-size: 18px;
}

.portal-edit-preview.is-crop {
  color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.portal-edit-input {
  width: 40px;
  height: 31px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: #fffdf7;
  font-family: var(--serif);
  font-size: 18px;
  text-align: center;
  outline: none;
}

.portal-edit-input:focus {
  border-color: var(--cinnabar);
}

.portal-small-btn {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--ink-2);
  font-size: 9px;
  cursor: pointer;
}

.portal-small-btn:hover {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.portal-small-btn.is-primary {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fbf6ea;
}

.portal-small-btn.is-on {
  background: rgba(164, 59, 43, 0.1);
  border-color: rgba(164, 59, 43, 0.4);
  color: var(--cinnabar);
}

.portal-small-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.proof-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: 9px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.4);
}

.proof-foot .proof-stats {
  color: var(--muted);
  font-size: 8px;
}

/* upload progress */

.upload-source-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.upload-source-actions .portal-small-btn {
  flex: 1;
  height: 29px;
  font-size: 8px;
}

.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  margin-top: 18px;
  overflow: auto;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.4);
  font-size: 10px;
}

.upload-item .upload-state {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
}

.upload-item.is-done .upload-state {
  color: var(--jade);
}

.upload-item.is-error .upload-state {
  color: var(--cinnabar);
}

.upload-progress-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 10px;
}

.upload-bar {
  flex: 1;
  height: 3px;
  margin-top: 0;
  background: var(--line);
}

.upload-percent {
  min-width: 40px;
  color: var(--cinnabar);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  text-align: right;
  letter-spacing: 0.02em;
}

.upload-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cinnabar);
  transition: width 0.25s ease;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 253, 247, 0.25);
  text-align: center;
  cursor: pointer;
}

.dropzone:hover {
  border-color: var(--cinnabar);
}

.dropzone b {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
}

.dropzone p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
}

/* toast */

.portal-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 900;
  padding: 10px 15px;
  background: rgba(27, 23, 18, 0.95);
  color: #eee4d2;
  border-left: 2px solid var(--cinnabar);
  font-size: 10px;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
}

.portal-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.portal-toast.is-error {
  border-left-color: #c6553f;
}

.mobile-view-switch {
  display: none;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 200px minmax(320px, 0.9fr) minmax(430px, 1.1fr);
  }

  .portal-header .main-nav {
    gap: 16px;
  }

  .user-meta {
    display: none;
  }
}

@media (max-width: 900px) {
  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none;
  }

  .auth-panel {
    min-height: 100vh;
  }

  .portal-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .library-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .library-search {
    width: 100%;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .workspace {
    grid-template-columns: 180px minmax(0, 1fr);
    grid-template-rows: minmax(360px, 48vh) minmax(0, 1fr);
  }

  .page-rail {
    grid-row: 1 / span 2;
  }

  .book-stage {
    grid-column: 2;
    grid-row: 1;
  }

  .proof-pane {
    grid-column: 2;
    grid-row: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .book-topbar .book-crumb b {
    max-width: 180px;
  }
}

@media (max-width: 620px) {
  .portal-main {
    padding-top: 28px;
  }

  .book-body-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .book-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
  }

  .portal-title-row h1 {
    font-size: 34px;
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  .portal-header .main-nav {
    display: none;
  }

  .portal-header .header-inner {
    gap: 8px;
  }

  .auth-panel {
    padding: 34px 24px;
  }

  .auth-panel h1 {
    font-size: 30px;
  }

  .modal-card {
    padding: 20px;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .data-table {
    font-size: 9px;
  }

  .book-topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .book-topbar .book-crumb a {
    display: none;
  }

  .book-topbar .book-crumb b {
    max-width: 130px;
    font-size: 15px;
  }

  .book-topbar .top-actions .btn {
    height: 32px;
    padding: 0 9px;
    font-size: 10px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 66px);
  }

  .page-rail {
    order: 2;
    height: 180px;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .page-list {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .page-item {
    width: 150px;
    flex: none;
    margin: 0;
  }

  .book-stage {
    order: 1;
    height: 42vh;
    min-height: 300px;
  }

  .proof-pane {
    order: 3;
    min-height: 560px;
  }

  .portal-row {
    gap: 2px;
  }

  .portal-cell {
    width: 34px;
  }

  .cell-crop {
    width: 25px;
    height: 25px;
  }

  .proof-head {
    padding: 12px 14px 9px;
  }

  .proof-toolbar,
  .proof-scroll,
  .portal-editbar,
  .proof-foot {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* Focused mobile proofreading layout */
@media (max-width: 620px) {
  .book-body-page {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .book-topbar {
    position: relative;
    height: 58px;
    min-height: 58px;
    padding: 0 9px;
    gap: 5px;
  }

  .book-topbar .brand {
    gap: 4px;
    flex: none;
  }

  .book-topbar .brand-type small {
    display: none;
  }

  .book-topbar .brand-type b {
    font-size: 15px;
  }

  .book-topbar .book-crumb {
    gap: 4px;
    flex: 1;
    min-width: 0;
  }

  .book-topbar .book-crumb b {
    max-width: 92px;
    font-size: 13px;
  }

  .book-topbar .top-actions {
    gap: 4px;
    flex: none;
  }

  .book-topbar .user-chip {
    display: none;
  }

  .book-topbar .top-actions .portal-small-btn,
  .book-topbar .top-actions .btn {
    display: grid;
    place-items: center;
    width: 32px;
    min-width: 32px;
    height: 30px;
    padding: 0;
    font-size: 0;
  }

  #exportBtn::after {
    content: "导出";
    font-size: 8px;
  }

  #manageBtn::after {
    content: "设置";
    font-size: 8px;
  }

  #addPageBtn::after {
    content: "＋";
    font-size: 16px;
  }

  .mobile-view-switch {
    display: flex;
    align-items: stretch;
    flex: none;
    height: 38px;
    padding: 3px 9px;
    background: var(--paper-deep);
    border-bottom: 1px solid var(--line);
    gap: 4px;
  }

  .mobile-view-switch button {
    flex: 1;
    border: 0;
    border-radius: 2px;
    background: transparent;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 10px;
    letter-spacing: 0.04em;
  }

  .mobile-view-switch button.is-active {
    background: var(--paper-soft);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(54, 46, 34, 0.12);
    font-weight: 600;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 96px);
    height: calc(100dvh - 96px);
    min-height: 0;
    overflow: hidden;
  }

  .page-rail {
    order: 1;
    width: 100%;
    height: 82px;
    min-height: 82px;
    flex: none;
    border-right: 0;
    border-top: 0;
    border-bottom: 1px solid var(--line);
  }

  .page-rail-head {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 4px 10px 0;
    border-bottom: 0;
  }

  .page-rail-head h2 {
    font-size: 13px;
  }

  .page-rail-head p {
    margin: 0;
    font-size: 7px;
  }

  .page-list {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 49px;
    padding: 3px 9px 5px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .page-item {
    width: 76px;
    min-width: 76px;
    height: 42px;
    padding: 3px 4px;
    gap: 5px;
    margin: 0;
  }

  .page-thumb {
    width: 23px;
    height: 31px;
  }

  .page-item-text b {
    font-size: 8px;
  }

  .page-item-text small {
    display: none;
  }

  .page-rail-foot {
    display: none;
  }

  .book-stage {
    order: 2;
    flex: 1;
    height: auto;
    min-height: 0;
  }

  .proof-pane {
    order: 2;
    flex: 1;
    min-height: 0;
    border-left: 0;
    border-top: 0;
  }

  .workspace.mobile-view-proof .book-stage {
    display: none;
  }

  .workspace.mobile-view-stage .proof-pane {
    display: none;
  }

  .workspace.mobile-view-stage .page-rail {
    order: 3;
    border-top: 1px solid var(--line);
    border-bottom: 0;
  }

  .stage-bar {
    min-height: 38px;
    padding: 0 8px;
    gap: 5px;
    overflow: hidden;
    font-size: 7px;
  }

  .stage-bar #pageLabel {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: none;
  }

  .stage-bar .stage-actions {
    flex: 1;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .stage-bar .portal-small-btn {
    flex: none;
    height: 25px;
    padding: 0 6px;
    border-color: rgba(244, 234, 215, 0.32);
    background: rgba(244, 234, 215, 0.12);
    color: #f1e3ca;
    font-size: 7.5px;
    font-weight: 500;
  }

  .stage-image-wrap {
    padding: 5px;
  }

  .stage-image-box > img {
    max-height: 100%;
  }

  .page-seal {
    width: 50px;
    height: 50px;
    font-size: 15px;
  }

  .proof-head {
    padding: 6px 11px 4px;
  }

  .proof-title-row h2 {
    font-size: 17px;
  }

  .proof-title-row p {
    margin-top: 2px;
    font-size: 7px;
  }

  .book-tagline {
    margin-top: 2px;
  }

  .member-legend {
    margin-top: 4px;
    gap: 3px 8px;
  }

  .member-legend-item {
    font-size: 7px;
  }

  .proof-toolbar {
    min-height: 27px;
    padding: 2px 11px;
    gap: 4px;
    overflow: hidden;
  }

  .feedback-info {
    display: none;
  }

  .sync-state {
    flex: none;
    font-size: 7px;
  }

  .proof-tools {
    flex: 1;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    margin-left: 0;
    padding-bottom: 1px;
  }

  .proof-tools .text-btn {
    flex: none;
    white-space: nowrap;
    font-size: 7.5px;
  }

  .proof-scroll {
    flex: 1;
    min-height: 0;
    padding: 4px 11px;
  }

  .portal-row {
    gap: 2px;
  }

  .portal-cell {
    width: 32px;
    gap: 2px;
  }

  .cell-crop {
    width: 23px;
    height: 23px;
  }

  .portal-cell.is-ignored {
    width: 43px;
  }

  .portal-cell.is-ignored .cell-crop {
    width: 32px;
    height: 32px;
  }

  .ignore-label {
    font-size: 5.5px;
  }

  .ignore-card-image {
    width: 48px;
    height: 48px;
  }

  .cell-text {
    font-size: 9px;
  }

  .portal-editbar {
    flex: none;
    padding: 5px 11px 7px;
    box-shadow: 0 -8px 22px -18px rgba(42, 33, 22, 0.55);
  }

  .portal-editbar-head {
    margin-bottom: 3px;
  }

  .portal-edit-controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
  }

  .portal-edit-controls > * {
    flex: none;
  }

  .portal-edit-preview {
    width: 27px;
    height: 27px;
  }

  .portal-edit-input {
    width: 31px;
    height: 27px;
    font-size: 16px;
  }

  .portal-edit-controls .portal-small-btn {
    height: 27px;
    padding: 0 6px;
    font-size: 8px;
  }

  .proof-foot {
    flex: none;
    padding: 3px 11px;
    min-height: 30px;
  }

  .proof-foot .proof-stats {
    font-size: 7px;
  }

  .proof-foot .portal-small-btn {
    height: 24px;
    padding: 0 6px;
    font-size: 7.5px;
  }
}

/* BOWEN global categories + app subnavigation */
.app-subnav {
  position: relative;
  z-index: 24;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
}

.app-subnav-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  width: min(1220px, calc(100% - 48px));
  min-height: 38px;
  margin: 0 auto;
  overflow-x: auto;
}

.app-subnav a {
  position: relative;
  flex: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}

.app-subnav a:hover {
  color: var(--cinnabar);
}

.app-subnav a.is-current {
  color: var(--ink);
  font-weight: 600;
}

.app-subnav a.is-current::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -12px;
  left: 0;
  height: 1px;
  background: var(--cinnabar);
}

@media (max-width: 640px) {
  .app-subnav-inner {
    width: calc(100% - 24px);
    gap: 18px;
    min-height: 34px;
  }

  .app-subnav a {
    font-size: 9px;
  }

  .app-subnav a.is-current::after {
    bottom: -9px;
  }
}

.main-nav a.is-current {
  color: var(--ink);
}

.main-nav a.is-current::after {
  right: 0;
}

/* Refined secondary navigation */
.app-subnav {
  background: linear-gradient(180deg, rgba(255, 252, 244, 0.72), rgba(244, 237, 224, 0.58));
  border-bottom: 1px solid rgba(54, 46, 34, 0.1);
}

.app-subnav-inner {
  width: min(calc(100% - 64px), 1400px);
  min-height: 44px;
  padding: 5px 0;
  gap: 2px;
  overflow: visible;
  scrollbar-width: none;
}

.app-subnav-inner::-webkit-scrollbar {
  display: none;
}

.app-subnav-inner::before {
  content: "识古";
  margin-right: 12px;
  padding-right: 13px;
  border-right: 1px solid rgba(54, 46, 34, 0.14);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.app-subnav a {
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.app-subnav a:hover {
  background: rgba(164, 59, 43, 0.05);
  color: var(--ink);
}

.app-subnav a.is-current {
  border-color: rgba(164, 59, 43, 0.22);
  background: rgba(164, 59, 43, 0.075);
  color: var(--cinnabar);
  font-weight: 500;
}

.app-subnav a.is-current::after {
  display: none;
}

@media (max-width: 640px) {
  .app-subnav-inner {
    width: calc(100% - 24px);
    min-height: 38px;
    gap: 1px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .app-subnav-inner::before {
    display: none;
  }

  .app-subnav a {
    padding: 5px 8px;
    font-size: 8px;
  }
}

.create-file-actions {
  display: flex;
  gap: 6px;
}

.create-file-actions .portal-small-btn {
  flex: 1;
  height: 29px;
  font-size: 8px;
}

.create-file-hint {
  margin: 5px 0 0;
  color: var(--muted-2);
  font-size: 8px;
  line-height: 1.6;
}


.create-file-hint a {
  color: var(--cinnabar);
  text-decoration: none;
}

.create-file-hint a:hover {
  text-decoration: underline;
}

.batch-file-list {
  display: grid;
  gap: 5px;
  margin-top: 9px;
  max-height: 190px;
  overflow: auto;
}

.batch-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.7);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 8px;
}

.batch-file-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-file-item b {
  flex: none;
  color: var(--muted-2);
  font-weight: 400;
}


.page-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.page-item:hover .page-item-actions,
.page-item.is-active .page-item-actions {
  opacity: 1;
}

.page-action {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.65);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
}

.page-action:hover {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.page-action.is-disabled {
  opacity: 0.22;
  pointer-events: none;
}

.page-action.is-danger:hover {
  background: rgba(164, 59, 43, 0.08);
}

.page-item .page-state {
  margin-left: 4px;
}

@media (hover: none) {
  .page-item-actions {
    opacity: 1;
  }
}

/* Page-management actions sit on their own row below the page text. */
.page-item {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 9px;
}

.page-item .page-thumb {
  margin-top: 1px;
}

.page-item .page-item-text {
  flex: 1 1 0;
}

.page-item .page-state {
  margin-left: auto;
  margin-top: 7px;
}

.page-item-actions {
  flex: 0 0 calc(100% - 45px);
  margin: 2px 0 0 45px;
  justify-content: flex-end;
  opacity: 1;
}

.page-item .page-action {
  width: 20px;
  height: 20px;
  font-size: 9px;
}

.portal-confirm-card {
  width: min(420px, 100%);
}

.portal-confirm-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
  white-space: pre-line;
}

.book-publish.book-delete {
  margin-left: 6px;
  border-color: var(--line);
  color: var(--muted-2);
}

.book-publish.book-delete:hover {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.fulltext-panel {
  margin: 0 0 18px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.55);
}

.fulltext-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.fulltext-head b {
  color: var(--cinnabar);
  font-weight: 400;
  letter-spacing: 0;
}

.fulltext-results {
  display: grid;
  gap: 9px;
}

.fulltext-group {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.5);
}

.fulltext-book {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.fulltext-book b {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fulltext-book span {
  flex: none;
  color: var(--cinnabar);
  font-family: var(--sans);
  font-size: 8px;
}

.fulltext-match {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 10px;
  line-height: 1.75;
  text-decoration: none;
}

.fulltext-match:hover {
  color: var(--ink);
}

.fulltext-match small {
  display: inline-block;
  margin-right: 7px;
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 7px;
}

.fulltext-match mark {
  padding: 0 1px;
  background: rgba(164, 59, 43, 0.16);
  color: var(--cinnabar);
}

.fulltext-empty {
  padding: 14px;
  color: var(--muted-2);
  font-size: 9px;
  text-align: center;
}

/* Larger, more legible library full-text results */
.fulltext-head {
  font-size: 9px;
}

.fulltext-book b {
  font-size: 17px;
}

.fulltext-book span {
  font-size: 9px;
}

.fulltext-match {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.85;
}

.fulltext-match small {
  margin-right: 8px;
  font-size: 9px;
}

.fulltext-empty {
  font-size: 10px;
}

.page-duplicate {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 4px;
  border: 1px solid rgba(164, 59, 43, 0.3);
  color: var(--cinnabar);
  font-family: var(--sans);
  font-size: 6px;
  font-style: normal;
  letter-spacing: 0.06em;
}

/* Stage toolbar buttons sit on the dark book stage, not on paper. */
.stage-bar .portal-small-btn {
  border-color: rgba(244, 234, 215, 0.34);
  background: rgba(244, 234, 215, 0.13);
  color: #f1e3ca;
}

.stage-bar .portal-small-btn:hover {
  border-color: rgba(244, 234, 215, 0.7);
  background: rgba(244, 234, 215, 0.22);
  color: #fffaf0;
}

.stage-bar .portal-small-btn.is-on {
  border-color: rgba(164, 59, 43, 0.8);
  background: rgba(164, 59, 43, 0.28);
  color: #fffaf0;
}

.stage-bar .portal-small-btn:disabled {
  color: rgba(241, 227, 202, 0.58);
  opacity: 1;
}

.wallet-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
  margin: 22px 0;
}

.wallet-balance,
.wallet-stat {
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
}

.wallet-balance span,
.wallet-stat span {
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.wallet-balance b {
  display: block;
  margin: 8px 0 4px;
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
}

.wallet-stat b {
  display: block;
  margin: 10px 0 4px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
}

.wallet-balance small,
.wallet-stat small {
  color: var(--muted);
  font-size: 8px;
}

.wallet-section {
  margin-top: 28px;
}

.wallet-section h2 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}

.wallet-packages {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-top: 14px;
}

.wallet-packages div {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.5);
}

.wallet-packages b,
.wallet-packages span {
  display: block;
}

.wallet-packages b {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
}

.wallet-packages span {
  margin-top: 5px;
  color: var(--cinnabar);
  font-size: 9px;
}

.wallet-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.wallet-ledger {
  display: grid;
  gap: 1px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--line);
}

.wallet-row {
  display: grid;
  grid-template-columns: 1fr 110px 100px;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper-soft);
  font-family: var(--sans);
  font-size: 9px;
}

.wallet-row b {
  color: var(--cinnabar);
  font-weight: 500;
  text-align: right;
}

.wallet-row small {
  color: var(--muted-2);
  text-align: right;
}

.wallet-empty {
  padding: 22px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

@media (max-width: 720px) {
  .wallet-grid,
  .wallet-packages {
    grid-template-columns: 1fr;
  }

  .wallet-row {
    grid-template-columns: 1fr 80px;
  }

  .wallet-row small {
    display: none;
  }
}

.library-scope {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.55);
}

.library-scope input {
  width: 15px;
  height: 15px;
  margin-top: 2px;
  accent-color: var(--cinnabar);
}

.library-scope b,
.library-scope small {
  display: block;
}

.library-scope b {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.library-scope small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
}

.book-personal {
  position: absolute;
  top: 11px;
  right: 11px;
  padding: 4px 7px;
  border: 1px solid rgba(39, 69, 54, 0.32);
  background: rgba(249, 246, 238, 0.94);
  color: #274536;
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: 0.08em;
}

/* AI proofreading adjustment */
.proof-ai {
  flex: none;
  padding: 9px 20px 10px;
  border-top: 1px solid var(--line);
  background: rgba(249, 245, 236, 0.92);
}

.proof-ai-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.proof-ai-head b {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.proof-ai-head span {
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 7px;
}

.proof-ai-quick {
  display: flex;
  gap: 5px;
  margin: 7px 0 6px;
  flex-wrap: wrap;
}

.proof-ai-quick button {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 7px;
}

.proof-ai-quick button:hover {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.proof-ai-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
}

.proof-ai-row textarea {
  flex: 1;
  min-height: 48px;
  max-height: 92px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 253, 247, 0.9);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 9px;
  line-height: 1.5;
  resize: vertical;
}

.proof-ai-row textarea:focus {
  outline: 0;
  border-color: var(--cinnabar);
}

.proof-ai-row .portal-small-btn {
  flex: none;
  min-width: 66px;
  height: auto;
  color: var(--cinnabar);
  border-color: rgba(164, 59, 43, 0.45);
  background: rgba(164, 59, 43, 0.06);
}

.proof-ai-row .portal-small-btn:disabled {
  opacity: 0.45;
}

.proof-ai-hint {
  margin: 5px 0 0;
  color: var(--muted-2);
  font-size: 7px;
  line-height: 1.45;
}

.proof-ai.is-unavailable .proof-ai-row,
.proof-ai.is-unavailable .proof-ai-quick {
  opacity: 0.5;
}

.book-credit {
  margin: 5px 0 0;
  color: var(--cinnabar);
  font-family: var(--sans);
  font-size: 7px;
}
