:root {
  --bg0: #e8efe6;
  --bg1: #f4f7f2;
  --ink: #1c2a22;
  --muted: #5d6f64;
  --line: #c5d2c8;
  --panel: rgba(255, 252, 246, 0.92);
  --accent: #2f6b4f;
  --accent-2: #c45c26;
  --danger: #9b2c2c;
  --shadow: 0 12px 40px rgba(28, 42, 34, 0.08);
  --font-display: "Fraunces", "Palatino Linotype", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --sidebar-w: 250px;
  --content-pad: 1rem;
  --touch: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d7e8d8 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #f0dcc8 0%, transparent 50%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

body.nav-open {
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-frame {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100%;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: calc(1.25rem + var(--safe-top)) 1rem calc(1.25rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.96), rgba(236, 243, 236, 0.94));
  overflow: hidden;
}

.sidebar-brand {
  flex-shrink: 0;
}

.sidebar-dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  position: relative;
  z-index: 8;
  background: linear-gradient(180deg, rgba(236, 243, 236, 0.96), rgba(236, 243, 236, 0.98));
}

.sidebar-brand .brand {
  display: inline-block;
  text-decoration: none;
  color: inherit;
}

.sidebar-brand .brand:hover {
  text-decoration: none;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
}

.brand span {
  color: var(--accent-2);
}

.brand--compact {
  font-size: 1.15rem;
  text-decoration: none;
  color: inherit;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-section {
  margin: 0.85rem 0 0.35rem;
  padding: 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-section:first-child {
  margin-top: 0.2rem;
}

.nav-link {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: var(--touch);
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(47, 107, 79, 0.08);
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(47, 107, 79, 0.12);
  border-left-color: var(--accent);
  color: var(--accent);
}

.nav-link--danger {
  color: var(--danger);
}

.nav-link--upgrade {
  flex-shrink: 0;
  margin-top: 0;
  border: 1px solid rgba(47, 107, 79, 0.35);
  border-left: 3px solid var(--accent);
  background: rgba(47, 107, 79, 0.07);
  color: var(--accent);
}

.nav-link--upgrade:hover,
.nav-link--upgrade.is-active {
  background: rgba(47, 107, 79, 0.14);
  color: var(--accent);
}

.sidebar-foot {
  flex-shrink: 0;
  margin-top: 0;
  padding: 0.75rem 0.65rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  position: relative;
  z-index: 6;
  overflow: visible;
}

.sidebar-foot p {
  margin: 0;
}

.app-main {
  min-width: 0;
}

.mobile-bar {
  display: none;
  align-items: center;
  gap: 0.65rem;
  padding: calc(0.65rem + var(--safe-top)) calc(0.85rem + var(--safe-right)) 0.65rem calc(0.85rem + var(--safe-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.94);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.mobile-bar__menu {
  flex: 0 0 auto;
}

.mobile-bar .brand--compact {
  flex: 1 1 auto;
  min-width: 0;
}

.mobile-bar__actions {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mobile-bar__actions .btn {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
}

.app-content {
  width: min(1120px, calc(100% - 2 * var(--content-pad)));
  margin: 0 auto;
  padding: 1.35rem 0 calc(3rem + var(--safe-bottom));
}

.sidebar-backdrop {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  border-radius: 2px;
}

.panel + .panel { margin-top: 1rem; }

.panel h2 {
  font-family: var(--font-display);
  margin: 0 0 0.85rem;
  font-size: 1.35rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  --btn-fg: #fff;
  --btn-spinner: #fff;
  appearance: none;
  position: relative;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--btn-fg);
  min-height: 2.5rem;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  touch-action: manipulation;
  transition: filter 0.12s ease, opacity 0.12s ease;
}

.btn:hover { filter: brightness(1.05); text-decoration: none; }

.btn.is-loading,
.btn[aria-busy="true"] {
  pointer-events: none;
  cursor: wait;
  filter: none;
}

.btn.is-loading::before,
.btn[aria-busy="true"]::before {
  content: "";
  box-sizing: border-box;
  width: 0.95em;
  height: 0.95em;
  border: 2px solid color-mix(in srgb, var(--btn-spinner) 30%, transparent);
  border-top-color: var(--btn-spinner);
  border-radius: 50%;
  flex-shrink: 0;
  animation: btn-spin 0.55s linear infinite;
}

@keyframes btn-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::before,
  .btn[aria-busy="true"]::before {
    animation: btn-spin 1.4s linear infinite;
  }
}

.btn.secondary {
  --btn-fg: var(--accent);
  --btn-spinner: var(--accent);
  background: transparent;
  color: var(--btn-fg);
}

.btn.ghost {
  --btn-fg: var(--ink);
  --btn-spinner: var(--ink);
  background: transparent;
  border-color: var(--line);
  color: var(--btn-fg);
}

.btn.danger {
  --btn-fg: var(--danger);
  --btn-spinner: var(--danger);
  background: transparent;
  border-color: var(--danger);
  color: var(--btn-fg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1rem;
}

.form-grid .full { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 2.5rem;
  padding: 0.55rem 0.65rem;
  font: inherit;
  width: 100%;
  max-width: 100%;
  border-radius: 2px;
}

input:focus-visible,
select:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.sheet-tab:focus-visible,
.clue-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  color: var(--ink);
}

.checks label {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

.field-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field-live {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}

.field-error {
  margin: 0.5rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

.precedence-note {
  padding: 0.65rem 0.75rem;
  border: 1px dashed var(--line);
  background: #fffef9;
  font-size: 0.88rem;
  color: var(--muted);
}

.precedence-note strong {
  color: var(--ink);
}

.input-row {
  display: flex;
  gap: 0.45rem;
}

.input-row input {
  flex: 1;
}

.preset-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.summary-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffef9, #f3f7f2);
  padding: 0.9rem 1rem;
}

.summary-card h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.summary-card pre {
  margin: 0;
  font: 600 0.98rem/1.55 var(--font-body);
  white-space: pre-wrap;
  color: var(--ink);
}

.zoom-label {
  min-width: 3.5rem;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sheet-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
}

.sheet-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.sheet-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.export-sub {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-family: var(--font-display);
}

.confirm-modal {
  border: 1px solid var(--line);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2rem);
  background: #fffef9;
  color: var(--ink);
  box-shadow: var(--shadow);
  border-radius: 2px;
}

.confirm-modal::backdrop {
  background: rgba(28, 42, 34, 0.45);
}

.confirm-modal__body {
  padding: 1.15rem 1.25rem 1.25rem;
}

.confirm-modal__body h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
}

.confirm-modal__body p {
  margin: 0 0 1rem;
  color: var(--muted);
  white-space: pre-wrap;
}

.confirm-modal.is-alert #confirm-cancel {
  display: none;
}

.app-toasts {
  position: fixed;
  right: max(1rem, var(--safe-right));
  bottom: max(1rem, var(--safe-bottom));
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.9rem;
  background: #fffef9;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.35;
  animation: toast-in 0.22s ease-out;
}

.app-toast.is-leaving {
  animation: toast-out 0.18s ease-in forwards;
}

.app-toast__msg {
  flex: 1;
  min-width: 0;
}

.app-toast__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  padding: 0.1rem;
  margin: -0.1rem -0.15rem 0 0;
}

.app-toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  background: #fff8f6;
}

.app-toast.is-warning {
  border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line));
  background: #fffaf4;
}

.app-toast.is-success {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: #f5faf6;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(0.4rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(0.25rem); }
}

@media (prefers-reduced-motion: reduce) {
  .app-toast,
  .app-toast.is-leaving {
    animation: none;
  }
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.15rem;
  padding: 0 0.15rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

.table th,
.table td {
  text-align: left;
  padding: 0.7rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.95rem;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table .col-check {
  width: 2.25rem;
}

.actions--row {
  gap: 0.4rem;
}

.meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.72fr);
  gap: 1rem;
  align-items: start;
}

.preview-main__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.preview-main__title {
  margin: 0;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0.75rem;
  max-height: calc(100dvh - 1.5rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.side-panel {
  padding: 1rem 1.1rem 1.1rem;
}

.side-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.side-panel__title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

.side-panel__id {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  flex: 0 0 auto;
}

.meta-chips {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.meta-chips li {
  margin: 0;
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--line);
  background: #f7faf6;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.meta-chips code {
  font-size: 0.8rem;
}

.side-section {
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.side-section__label {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-grid--compact {
  gap: 0.55rem 0.65rem;
  margin-bottom: 0.75rem;
}

.form-grid--compact label {
  font-size: 0.82rem;
  gap: 0.25rem;
}

.form-grid--compact input,
.form-grid--compact select {
  min-height: 2.25rem;
  padding: 0.4rem 0.5rem;
}

.actions--tight {
  gap: 0.4rem;
}

.actions--tight .btn,
.actions--tight form {
  margin: 0;
}

.actions--tight form {
  display: inline-flex;
}

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.export-actions__primary {
  width: 100%;
  justify-content: center;
}

.side-panel__hint {
  margin-top: 0.65rem;
  font-size: 0.78rem;
  line-height: 1.4;
}

.preview-stage {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(45deg, #ece7de 25%, transparent 25%),
    linear-gradient(-45deg, #ece7de 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ece7de 75%),
    linear-gradient(-45deg, transparent 75%, #ece7de 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border: 1px solid var(--line);
  padding: 1rem;
  min-height: min(420px, 70vw);
}

.preview-stage .sheet {
  background: #fffef9;
  border: 1px solid #d7d0c4;
  margin: 0 auto 1rem;
  padding: 0.5rem;
  width: fit-content;
  transform-origin: top center;
  transition: transform 0.15s ease;
}

.paper-frame {
  --paper-aspect: 0.77;
  --mx: 5.9%;
  --my: 4.5%;
  position: relative;
  width: min(100%, 460px);
  max-width: 100%;
  aspect-ratio: var(--paper-aspect);
  margin: 0 auto 1rem;
  background: #fff;
  border: 1px solid #b7c0b8;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 14px 30px rgba(28, 42, 34, 0.12);
  transform-origin: top center;
  transition: transform 0.15s ease;
}

.paper-inner {
  position: absolute;
  left: var(--mx);
  right: var(--mx);
  top: var(--my);
  bottom: var(--my);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: visible;
  background: #ffffff;
}

.paper-inner svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  overflow: visible;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.92rem;
}

.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.empty {
  padding: 1.5rem 0;
  color: var(--muted);
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  background: #fffef9;
  align-items: end;
  margin-bottom: 0.85rem;
}

.batch-bar label {
  min-width: min(140px, 100%);
  flex: 1 1 140px;
}

.batch-bar .btn {
  flex: 1 1 auto;
  min-width: min(100%, 200px);
}

.batch-bar .checks {
  flex: 1 1 100%;
}

.book-form .radio-row,
.radio-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.radio-row--inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.book-order__label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
}

.is-hidden,
[hidden] {
  display: none !important;
}

.book-page__head {
  margin-bottom: 1.1rem;
}

.quota-pill {
  margin: 0.65rem 0 0;
  font-size: 0.92rem;
}

.book-presets {
  margin: 0 0 1.35rem;
  padding: 1rem 1.05rem 1.1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.book-presets__title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.book-presets__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.book-preset-form {
  margin: 0;
  min-width: 0;
}

.book-preset-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  min-height: 100%;
  text-align: left;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.book-preset-card:hover:not(:disabled):not(.is-loading) {
  border-color: var(--accent, #2f6b4f);
  transform: translateY(-1px);
}

.book-preset-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.book-preset-card.is-loading,
.book-preset-card[aria-busy="true"] {
  pointer-events: none;
  cursor: wait;
  opacity: 1;
  border-color: var(--accent);
  background: rgba(255, 252, 246, 0.98);
}

.book-preset-card.is-loading::after,
.book-preset-card[aria-busy="true"]::after {
  content: "";
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 1.05rem;
  height: 1.05rem;
  box-sizing: border-box;
  border: 2px solid rgba(47, 107, 79, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
}

.book-preset-card.is-loading .book-preset-card__label::after {
  content: " \00B7 Generating...";
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0;
}

.book-preset-card__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.25;
  padding-right: 1.5rem;
}

.book-preset-card__blurb,
.book-preset-card__meta {
  font-size: 0.82rem;
  color: var(--muted, #5c675f);
  line-height: 1.35;
}

.book-preset-card__meta {
  margin-top: auto;
  padding-top: 0.35rem;
}

@media (prefers-reduced-motion: reduce) {
  .book-preset-card.is-loading::after,
  .book-preset-card[aria-busy="true"]::after {
    animation-duration: 1.4s;
  }
}

/* -- Members login (hosted access) -- */
body.is-auth {
  min-height: 100%;
  min-height: 100dvh;
  background: #dfe8e1;
}

.auth-stage {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding:
    calc(1.5rem + var(--safe-top))
    calc(1.25rem + var(--safe-right))
    calc(1.5rem + var(--safe-bottom))
    calc(1.25rem + var(--safe-left));
  overflow: hidden;
}

.auth-stage__atmosphere {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 12% 8%, rgba(47, 107, 79, 0.22), transparent 58%),
    radial-gradient(700px 480px at 92% 88%, rgba(196, 92, 38, 0.14), transparent 55%),
    linear-gradient(155deg, #eef3ec 0%, #e2ebe4 42%, #d5e0d8 100%);
}

.auth-stage__atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(28, 42, 34, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 42, 34, 0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000 20%, transparent 75%);
}

.auth-stage__atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 70% 22%, rgba(255, 255, 255, 0.45), transparent 28%),
    radial-gradient(circle at 18% 78%, rgba(255, 252, 246, 0.35), transparent 32%);
  pointer-events: none;
}

.auth-stage__frame {
  width: min(440px, 100%);
  animation: auth-rise 0.55s ease-out both;
}

@keyframes auth-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-stage__frame {
    animation: none;
  }
}

.auth-gate {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.auth-gate__brand {
  text-align: center;
}

.auth-gate__eyebrow {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-gate__logo {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 6vw, 3.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--ink);
}

.auth-gate__logo span {
  color: var(--accent-2);
}

.auth-gate__lede {
  margin: 0.85rem auto 0;
  max-width: 28ch;
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--muted);
}

.auth-gate__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.35rem 1.35rem 1.25rem;
  background: rgba(255, 252, 246, 0.88);
  border: 1px solid rgba(197, 210, 200, 0.95);
  backdrop-filter: blur(8px);
}

.auth-gate__error {
  margin: 0;
  padding: 0.7rem 0.85rem;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #7a2218;
  background: rgba(155, 44, 44, 0.08);
  border-left: 3px solid var(--danger);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
}

.auth-field__label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-field__input {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field__input::placeholder {
  color: #9aa89f;
}

.auth-field__input:hover {
  border-color: #a9b9ae;
}

.auth-field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.18);
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}

.password-field .auth-field__input,
.password-field input {
  padding-right: 2.8rem;
}

.password-field__toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-field__toggle:hover,
.password-field__toggle:focus-visible {
  color: var(--ink);
}

.password-field__icon {
  width: 1.25rem;
  height: 1.25rem;
}

.password-field__icon--hide,
.password-field.is-visible .password-field__icon--show {
  display: none;
}

.password-field.is-visible .password-field__icon--hide {
  display: block;
}

.auth-remember {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.auth-remember input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.auth-gate__submit {
  margin-top: 0.35rem;
  min-height: 50px;
  width: 100%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.auth-gate__submit:hover {
  filter: brightness(1.06);
}

.auth-gate__submit:active {
  transform: translateY(1px);
}

.auth-gate__submit:focus-visible {
  outline: 3px solid rgba(47, 107, 79, 0.35);
  outline-offset: 2px;
}

.auth-gate__note {
  margin: 0.15rem 0 0;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
}

.form-error {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.7rem;
  background: #fdecea;
  color: #8a1f11;
  border: 1px solid #f0c2bb;
}

.help-steps,
.help-license {
  margin: 0.75rem 0 1.1rem;
  padding-left: 1.2rem;
  line-height: 1.55;
}

.help-steps li,
.help-license li {
  margin-bottom: 0.45rem;
}

.sidebar-foot__user {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  word-break: break-all;
}

.sidebar-foot__quota {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  color: var(--muted, #5c675f);
}

.user-menu {
  position: relative;
}

.user-menu__trigger {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.user-menu__trigger:hover,
.user-menu.is-open .user-menu__trigger {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #e4eee7;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-avatar--lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.1rem;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-menu__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.user-menu__name {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu__email {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu__caret {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  margin-bottom: 0.2rem;
  transition: transform 0.15s ease;
}

.user-menu.is-open .user-menu__caret {
  transform: rotate(225deg);
  margin-bottom: 0;
  margin-top: 0.2rem;
}

.user-menu__panel {
  position: fixed;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(240px, calc(100vw - 1rem));
  padding: 0.35rem;
  border: 1px solid var(--line);
  background: #fffef9;
  box-shadow: var(--shadow);
  z-index: 80;
}

.user-menu__panel[hidden] {
  display: none;
}

.user-menu__item {
  display: block;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.user-menu__item:hover {
  background: rgba(47, 107, 79, 0.08);
  text-decoration: none;
}

.user-menu__item--danger {
  color: var(--danger);
  border-top: 1px dashed var(--line);
  margin-top: 0.2rem;
  padding-top: 0.65rem;
}

.account-page__identity {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.account-flash {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.8rem;
  background: rgba(47, 107, 79, 0.1);
  border-left: 3px solid var(--accent);
  color: var(--ink);
}

.account-flash--error {
  background: rgba(155, 44, 44, 0.08);
  border-left-color: var(--danger);
  color: #7a2218;
}

.account-sections {
  display: grid;
  gap: 0.85rem;
}

.account-card {
  margin: 0;
  padding: 0.95rem 1rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

.account-card h3 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.admin-page__head {
  margin-bottom: 1rem;
}

.admin-list__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.admin-list__head h3 {
  margin: 0;
}

.admin-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0;
}

.admin-inline-form select {
  min-width: 10rem;
  max-width: 14rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.admin-actions .inline-form {
  margin: 0;
  display: inline;
}

.admin-status {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
}

.admin-status.is-on { color: var(--accent); }
.admin-status.is-off { color: var(--danger); }

.table--admin td {
  vertical-align: top;
}

.file-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.file-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-picker__btn {
  flex-shrink: 0;
}

.file-picker__name {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.3;
  word-break: break-all;
}

@media (max-width: 900px) {
  .book-presets__grid {
    grid-template-columns: 1fr;
  }
}

.book-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.book-section {
  margin: 0;
  padding: 0.85rem 1rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  min-inline-size: 0;
}

.book-section legend {
  padding: 0 0.35rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.book-section .form-grid {
  margin-top: 0.35rem;
}

.book-custom-size {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}

.book-rc-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
}

.book-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}

.book-toggles .checks,
.book-brand-check {
  margin: 0;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
}

.book-brand-check {
  align-self: end;
  padding-bottom: 0.35rem;
}

.book-summary {
  margin-top: 1.1rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent);
  background: rgba(47, 107, 79, 0.06);
}

.book-summary__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.book-summary__body {
  margin: 0.25rem 0 0;
  font-size: 0.98rem;
  color: var(--ink);
  line-height: 1.4;
}

.book-actions {
  margin-top: 1rem;
}

.clue-editor-wrap {
  overflow: auto;
  padding: 0.5rem 0;
}

.clue-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), clamp(28px, 8vw, 40px));
  gap: 0;
  width: max-content;
  max-width: 100%;
  border: 1px solid #000;
  background: #000;
}

.clue-cell {
  width: clamp(28px, 8vw, 40px);
  height: clamp(28px, 8vw, 40px);
  border: 0;
  margin: 0;
  padding: 0;
  background: #eeeeee;
  color: #000;
  font: 700 clamp(13px, 3.5vw, 16px)/1 var(--font-body);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 0 0 1px #000;
}

.clue-cell.is-on {
  background: #ffffff;
}

.clue-cell.is-mine {
  background: #dddddd;
  cursor: not-allowed;
  opacity: 0.9;
}

.clue-cell:not(.is-mine):hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

@media (max-width: 1100px) {
  .preview-layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 960px) {
  :root {
    --content-pad: 0.85rem;
  }

  .app-frame {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    width: min(300px, 88vw);
    max-width: 100%;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
    border-right: 1px solid var(--line);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(28, 42, 34, 0.4);
  }

  .sidebar-backdrop.is-open {
    display: block;
  }

  .mobile-bar {
    display: flex;
  }

  .form-grid,
  .export-grid {
    grid-template-columns: 1fr;
  }

  .col-hide-md {
    display: none !important;
  }

  .batch-bar {
    align-items: stretch;
  }

  .input-row {
    flex-direction: column;
  }

  .panel {
    padding: 1rem 1.05rem;
  }

  .kv {
    grid-template-columns: 96px 1fr;
  }

  .paper-frame {
    width: 100%;
  }
}

@media (max-width: 720px) {
  :root {
    --content-pad: 0.75rem;
  }

  .col-hide-sm {
    display: none !important;
  }

  .app-content {
    padding-top: 1rem;
  }

  .panel h2 {
    font-size: 1.2rem;
  }

  /* Puzzle list: stacked cards */
  .table--puzzles thead {
    display: none;
  }

  .table--puzzles tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .table--puzzles tr {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    background: #fffef9;
    box-shadow: 0 4px 16px rgba(28, 42, 34, 0.04);
  }

  .table--puzzles td {
    border: 0;
    padding: 0.15rem 0;
    font-size: 0.92rem;
  }

  .table--puzzles td.col-check {
    grid-row: 1 / span 2;
    align-self: start;
    padding-top: 0.2rem;
  }

  .table--puzzles td[data-label="Title"] {
    grid-column: 2;
  }

  .table--puzzles td[data-label="Grid"],
  .table--puzzles td[data-label="Mines"],
  .table--puzzles td[data-label="Seed"],
  .table--puzzles td[data-label="Difficulty"] {
    grid-column: 2;
    display: flex;
    gap: 0.5rem;
    color: var(--muted);
  }

  .table--puzzles td[data-label="Grid"]::before,
  .table--puzzles td[data-label="Mines"]::before,
  .table--puzzles td[data-label="Seed"]::before,
  .table--puzzles td[data-label="Difficulty"]::before {
    content: attr(data-label) ":";
    font-weight: 600;
    min-width: 4.5rem;
  }

  .table--puzzles td[data-label="Actions"] {
    grid-column: 1 / -1;
    padding-top: 0.55rem;
    margin-top: 0.25rem;
    border-top: 1px dashed var(--line);
  }

  .table--puzzles .actions--row .btn {
    flex: 1 1 auto;
  }

  .batch-bar label {
    flex: 1 1 100%;
    min-width: 0;
  }

  .batch-bar .btn {
    width: 100%;
  }

  .book-form .form-grid {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    padding: 0.65rem;
    min-height: 280px;
  }

  .zoom-controls {
    width: 100%;
    justify-content: space-between;
  }

  /* Avoid iOS zoom-on-focus */
  input[type="text"],
  input[type="number"],
  select {
    font-size: 16px;
  }

  .clue-editor-wrap {
    margin: 0 -0.25rem;
    padding: 0.5rem 0.25rem;
  }
}

@media (max-width: 420px) {
  .mobile-bar__cta {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .actions .btn {
    font-size: 0.9rem;
  }

  .sheet-tab {
    flex: 1;
    text-align: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

@media (min-width: 961px) {
  .mobile-bar__cta {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .paper-frame,
  .preview-stage .sheet {
    transition: none;
  }
}

/* Plans, Print Spec Guard, unlock */
.print-guard {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
}
.print-guard__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.print-guard__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.print-guard__badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--line);
  color: var(--muted, #5a6a60);
}
.print-guard__badge.is-full {
  border-color: var(--accent);
  color: var(--accent);
}
.print-guard__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}
.print-guard__item {
  font-size: 0.9rem;
  line-height: 1.35;
  padding-left: 0.85rem;
  border-left: 3px solid var(--line);
}
.print-guard__item.is-pass { border-left-color: var(--accent); }
.print-guard__item.is-warn { border-left-color: #c48a2a; }
.print-guard__item.is-fail { border-left-color: var(--danger); }
.book-kit-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px dashed var(--line);
}
.book-kit-bar label { flex: 1 1 14rem; margin: 0; }
.book-kit-locked { margin: 0 0 0.85rem; }
.plan-feature-list {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.kit-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.kit-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}

.upgrade-page__head { margin-bottom: 1rem; }
.upgrade-tiers {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}
@media (min-width: 720px) {
  .upgrade-tiers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.upgrade-tier {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}
.upgrade-tier.is-current {
  border-color: var(--accent);
  background: rgba(47, 107, 79, 0.08);
}
.upgrade-tier__name {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.upgrade-tier__blurb {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}
.upgrade-tier__badge {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}
.upgrade-tier__badge--next { color: var(--ink); }
.upgrade-redeem {
  padding: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.upgrade-page__current {
  margin: 0.55rem 0 0;
  font-size: 0.95rem;
}
.upgrade-tier__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.upgrade-tier__cap {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.upgrade-tier__tagline {
  margin: 0 0 0.3rem;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.35;
}
.upgrade-tier__best {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
  color: var(--muted);
}
.upgrade-tier__list {
  margin: 0;
  padding: 0 0 0 1.05rem;
  display: grid;
  gap: 0.28rem;
  font-size: 0.9rem;
  line-height: 1.35;
}
.upgrade-tier.is-next {
  border-color: rgba(47, 107, 79, 0.45);
}

.book-kit-panel {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}
.book-kit-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.book-kit-panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.book-kit-empty {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
}
.book-kit-save {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}
.book-kit-save__label {
  margin: 0 0 0.55rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.upgrade-bump {
  margin: 0 0 1.25rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(47, 107, 79, 0.4);
  background: rgba(47, 107, 79, 0.06);
}
.upgrade-bump.is-current {
  border-color: var(--accent);
  background: rgba(47, 107, 79, 0.1);
}
.upgrade-section-title {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.start-page__head { margin-bottom: 1rem; }
.start-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.85rem;
}
.start-step {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}
.start-step h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.start-step p { margin: 0 0 0.45rem; }
.start-step p:last-child { margin-bottom: 0; }
.start-bullets {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.25rem;
  font-size: 0.95rem;
}
.start-bullets--numbered { list-style: decimal; }
.start-tips {
  margin-top: 1.1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
}

/* Interactive onboarding tour (spotlight + floating tip) */
.tour-launch {
  position: relative;
  z-index: 8;
  margin: 0 0 1rem;
}
.tour-launch__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(47, 107, 79, 0.28);
  background: rgba(47, 107, 79, 0.07);
}
.tour-launch__copy {
  display: grid;
  gap: 0.2rem;
  min-width: min(100%, 18rem);
}
.tour-launch__copy strong {
  font-family: var(--font-display);
}
.tour-launch__copy span {
  color: var(--muted);
  font-size: 0.92rem;
}
.tour-launch__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  position: relative;
  z-index: 5;
}
.tour-launch__actions .btn,
.tour-launch__btn {
  pointer-events: auto;
  position: relative;
  z-index: 5;
}
.tour-launch__btn {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  border: 1px dashed var(--line);
  background: rgba(255, 252, 246, 0.75);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.75rem 1rem;
  min-height: var(--touch);
  cursor: pointer;
}
.tour-launch__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(47, 107, 79, 0.08);
}
.tour-launch__meta {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.tour-root[hidden],
.tour-hole[hidden] {
  display: none !important;
}
.tour-root {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  z-index: 12000;
  pointer-events: none !important;
}
.tour-hole {
  position: fixed;
  border-radius: 8px;
  box-shadow:
    0 0 0 9999px rgba(16, 28, 22, 0.52),
    0 0 0 3px #fff,
    0 0 0 6px rgba(47, 107, 79, 0.95);
  pointer-events: none !important;
  transition: top 0.22s ease, left 0.22s ease, width 0.22s ease, height 0.22s ease;
}
.tour-tip {
  position: fixed;
  inset: auto;
  z-index: 13050;
  width: min(340px, calc(100vw - 1.5rem));
  height: auto;
  max-height: none;
  margin: 0;
  overflow: visible;
  background: #fffdf8;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(16, 28, 22, 0.28);
  padding: 0.9rem 1rem 0.85rem;
  pointer-events: auto;
}
.tour-tip:not(.is-on) {
  display: none !important;
}
.tour-tip.is-on,
.tour-tip:popover-open {
  display: block;
  pointer-events: auto;
}
.tour-tip__step {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.tour-tip__title {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.25;
}
.tour-tip__body {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.45;
}
.tour-tip__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.tour-tip__actions .btn {
  min-height: 40px;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  cursor: pointer;
}
.tour-tip__spacer {
  flex: 1;
  min-width: 0.5rem;
}
body.tour-active {
  overflow: auto;
}
.tour-target-pulse {
  border-radius: 4px;
  scroll-margin: 5rem;
}

@media (max-width: 720px) {
  .tour-tip.is-on,
  .tour-tip:popover-open {
    left: 0.75rem !important;
    right: 0.75rem !important;
    bottom: auto !important;
    width: auto;
  }
}
