/* Shared desktop / H5 novel workspace. Existing Noctis theme tokens remain authoritative. */
:root {
  color-scheme: dark;
}
body {
  font-size: 14px;
}
button,
a,
input,
select,
summary {
  touch-action: manipulation;
}
button,
input,
select,
textarea {
  -webkit-tap-highlight-color: rgba(var(--accent-rgb), 0.16);
}
button:enabled:hover {
  filter: brightness(1.12);
}
button:disabled {
  cursor: not-allowed;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  transform: translateY(-180%);
  z-index: 100;
  padding: 12px 18px;
  background: var(--lime);
  color: var(--ink);
}
.skip-link:focus {
  transform: translateY(0);
}
#novelMain {
  padding-bottom: 32px;
  outline: none;
}
#novelMain :is(h1, h2, h3, input, textarea, select, button) {
  scroll-margin-block: 100px 150px;
}
#novelMain h1,
#novelMain h2 {
  text-wrap: balance;
}
.novel-toolbar {
  margin-block: 24px 4px;
}
.novel-feedback {
  width: calc(100% - 48px);
  max-width: 1440px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#novelStatus {
  width: auto;
  max-width: none;
  margin: 8px 0;
  flex: 1;
  overflow-wrap: anywhere;
  min-height: 1.8em;
}
.novel-gate {
  padding: clamp(24px, 7vw, 72px);
  border: 1px solid var(--line);
  background: var(--surface);
  max-width: 860px;
}
.novel-gate h1 {
  font-size: clamp(24px, 4vw, 36px);
  margin: 0 0 16px;
}
.novel-gate input[type="checkbox"] {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}
.board {
  grid-template-columns: minmax(250px, 0.9fr) minmax(320px, 1.8fr) minmax(
      200px,
      0.7fr
    );
  gap: 24px;
  min-height: 0;
}
.board > .col {
  min-width: 0;
  padding: 24px 0;
  overflow-wrap: anywhere;
}
#worldSummary {
  color: var(--muted);
}
#buyPrivilege {
  width: 100%;
  margin-bottom: 10px;
  min-height: 44px;
}
#toWrite {
  min-height: 44px;
}
#worldAccessHint {
  font-size: 12px;
  line-height: 1.7;
}
.cast-details {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 24px;
}
summary {
  cursor: pointer;
  min-height: 44px;
}
#castCount,
#chapterCount {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#cast {
  margin-top: 12px;
}
#cast li {
  margin: 0 0 16px;
}
#cast li > div {
  min-width: 0;
}
.list-head {
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}
.list-head h2 {
  font-size: 20px;
}
.sorts {
  gap: 8px;
  flex-wrap: wrap;
}
.sorts button {
  padding: 8px;
  min-height: 44px;
  border-radius: 6px;
}
.sorts button[aria-pressed="true"] {
  color: var(--lime);
  background: rgba(var(--accent-rgb), 0.08);
}
.chapter-search {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 16px;
}
#chapterSearch {
  width: 100%;
  display: block;
  min-height: 44px;
  margin: 6px 0 16px;
  border-radius: 8px;
  font-size: 16px;
}
.novel-chapter {
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}
.novel-chapter .title-btn {
  display: block;
  font-size: 20px;
  line-height: 1.6;
  min-height: 44px;
  overflow-wrap: anywhere;
}
.chapter-excerpt {
  margin: 8px 0 12px;
}
.novel-empty {
  padding: 32px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}
.col-draw {
  border-left: 1px solid var(--line);
  padding-left: 20px !important;
}
.col-draw h2 {
  font-size: 18px;
}
#myCards {
  overflow-wrap: anywhere;
}
.pool-card {
  width: 100%;
}
.novel-account {
  margin-block: 40px 0;
  padding-top: 24px;
}
.novel-balances {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.draft-row > span {
  flex: 1;
  min-width: 100px;
  overflow-wrap: anywhere;
}
.stage-page {
  width: calc(100% - 48px);
  max-width: 980px;
  margin: 24px auto;
  padding: 0;
}
.studio-heading {
  margin: 24px 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}
.stage-page .studio-heading h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.4;
  margin: 0 0 10px;
}
.studio-heading p {
  color: var(--muted);
  margin: 0;
}
.context-details {
  margin-block: 20px;
}
.latest-chapter {
  margin: 0;
  padding: 12px 0;
  border-top: 0;
}
.studio {
  max-width: none;
}
.studio-settings {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.studio h2 {
  font-size: 20px;
  margin: 0 0 12px;
}
.studio label,
.studio legend {
  font-size: 14px;
}
.studio :is(input, textarea, select) {
  font-size: 16px;
}
.studio fieldset {
  min-width: 0;
  margin: 20px 0 12px;
  padding: 0;
  border: 0;
}
#castPicker {
  margin: 12px 0 0;
  gap: 8px;
}
#castPicker .cast-pick {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 8px 12px;
  margin: 0;
}
#castPicker .cast-pick:has(input:checked) {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: var(--lime);
}
#castPicker input {
  width: 18px !important;
  height: 18px;
  accent-color: var(--lime);
}
#protagonistChoice {
  padding: 8px 0;
}
#prompt {
  min-height: 150px;
  border-radius: 8px;
  background: var(--ink);
  line-height: 1.8;
}
#chapterTitle {
  border-radius: 8px;
  background: var(--ink);
}
#promptHint {
  font-size: 12px;
  margin: 8px 0 20px;
}
.studio .price-field {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
}
.studio .price-field span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
#novelPrice {
  width: 120px;
  border-radius: 6px;
}
[aria-invalid="true"] {
  border-color: var(--amber) !important;
}
.field-error,
#draftReason,
#readStatus.is-error {
  color: var(--amber);
  overflow-wrap: anywhere;
}
.field-error {
  padding: 12px 0;
}
.conflict-actions {
  padding: 16px;
  border: 1px solid var(--amber);
  border-radius: 8px;
}
.conflict-actions .btn {
  margin: 4px 8px 4px 0;
}
.editor-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
#wordCount {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#draftState {
  color: var(--muted);
  margin: 0 0 12px;
}
.novel-editor {
  min-height: 480px;
  border-radius: 8px;
  padding: 24px;
  line-height: 2;
}
.studio-actions-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 calc(16px + env(safe-area-inset-bottom));
  background: var(--ink);
  border-top: 1px solid var(--line);
}
.studio-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.studio-buttons .btn {
  min-height: 44px;
  white-space: nowrap;
}
.studio-progress {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  min-width: 0;
}
#saveState {
  color: var(--lime);
}
#generationInfo {
  color: var(--muted);
}
#readStatus {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0 20px;
  background: var(--surface);
  color: var(--lime);
  overflow-wrap: anywhere;
}
#readStatus:empty {
  display: none;
}
.read-modal {
  padding-block: max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-bottom));
}
.letter-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: min(860px, calc(100vw - 48px));
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.letter-frame::before,
.letter-frame::after {
  display: none;
}
.letter-close {
  position: relative;
  display: block;
  top: auto;
  right: auto;
  margin: 12px 16px 12px auto;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.letter-scroll {
  height: auto;
  max-height: min(76vh, calc(100dvh - 180px));
  overscroll-behavior: contain;
}
.letter {
  background: var(--surface);
  background-image: none;
  clip-path: none;
  padding: 8px clamp(20px, 6vw, 72px) 40px;
}
.letter::before,
.letter::after {
  display: none;
}
.letter h1 {
  overflow-wrap: anywhere;
  font-size: clamp(24px, 4vw, 32px);
}
.novel-prose {
  font-family: Georgia, "Songti TC", "Noto Serif CJK TC", serif;
  font-size: 18px;
  line-height: 2;
  overflow-wrap: anywhere;
}
#readMount > input {
  max-width: 120px;
  min-height: 44px;
  margin: 20px 12px 8px 0;
  font-size: 16px;
}
#readMount > .btn {
  min-height: 44px;
}
@media (min-width: 1100px) {
  .cast-details {
    max-height: 580px;
    overflow: auto;
    scrollbar-width: thin;
  }
}
@media (max-width: 1099px) {
  .board {
    grid-template-columns: minmax(220px, 0.8fr) minmax(300px, 1.5fr);
  }
  .col-draw {
    grid-column: 1/-1;
    border: 0;
    border-top: 1px solid var(--line);
  }
}
@media (max-width: 700px) {
  .novel-toolbar,
  .novel-feedback,
  .novel-gate,
  .novel-account,
  .stage-page {
    width: calc(100% - 32px);
  }
  .novel-toolbar {
    gap: 12px;
    font-size: 13px;
  }
  .novel-toolbar > label {
    flex: 1;
    min-width: 0;
  }
  #worldSelect {
    max-width: 64vw;
  }
  .board {
    display: flex;
    flex-direction: column;
    width: calc(100% - 32px);
    gap: 0;
    margin-inline: auto;
  }
  .board > .col {
    width: 100%;
    padding: 20px 0;
  }
  .world-overview {
    border-bottom: 1px solid var(--line);
  }
  #worldTitle {
    font-size: 28px;
    margin-bottom: 8px;
  }
  #worldSummary {
    margin: 8px 0 16px;
  }
  .cast-details {
    margin-top: 16px;
    padding-top: 8px;
  }
  .col-draw {
    padding-left: 0 !important;
  }
  .novel-balances {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .studio-settings {
    padding: 16px;
  }
  .studio-heading {
    margin-top: 20px;
  }
  #castPicker .cast-pick {
    padding-inline: 10px;
  }
  .novel-editor {
    min-height: 46dvh;
    padding: 16px;
  }
  .studio-actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 12px;
  }
  .studio-progress {
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
  }
  .studio-buttons {
    flex-wrap: nowrap;
  }
  .studio-buttons .btn {
    flex: 1;
    min-width: 0;
    padding-inline: 8px;
    white-space: normal;
    border-radius: 8px;
    font-size: 13px;
  }
  .letter-frame {
    width: calc(100vw - 24px);
  }
  .letter {
    padding-inline: 20px;
  }
  .novel-prose {
    font-size: 17px;
  }
  .letter-scroll {
    max-height: calc(100dvh - 170px);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

.card-reward-disclosure {
  padding: 10px 12px;
  border-left: 2px solid var(--lime);
  background: var(--surface);
  line-height: 1.65;
  overflow-wrap: anywhere;
}
#pinRights {
  line-height: 1.7;
  overflow-wrap: anywhere;
}
#pinRights button {
  display: block;
  margin: 8px 0;
  text-align: left;
  max-width: 100%;
}
