:root {
  --color-background: #f7f1e7;
  --color-surface: #fffaf1;
  --color-paper: #fbf6ec;
  --color-pocket: rgba(255, 255, 255, 0.56);
  --color-ink: #24201b;
  --color-muted: #71675c;
  --color-border: #d9cdbc;
  --color-border-strong: #bcae9a;
  --color-accent: #7f5f3f;
  --color-accent-dark: #4d3829;
  --color-add: #8c806f;
  --color-on-accent: #fffaf1;
  --color-input-bg: #fffdf8;
  --color-card-face: #fffbf4;
  --color-spine: #e5d9c6;
  --color-error: #8a3d32;
  --color-danger-border: #b68b82;
  --gradient-top: rgba(255, 252, 245, 0.74);
  --gradient-bottom: rgba(247, 241, 231, 0.95);
  --surface-rgb: 255, 250, 241;
  --accent-rgb: 127, 95, 63;
  --shadow-rgb: 76, 61, 43;
  --shadow-soft: 0 18px 45px rgba(76, 61, 43, 0.14);
  --shadow-card: 0 8px 18px rgba(48, 39, 29, 0.18);
  --pocket-sheen: rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.18) 42%, rgba(165, 150, 128, 0.16);
  --radius-small: 6px;
  --radius-medium: 8px;
  --font-main: Georgia, "Times New Roman", serif;
  --font-ui: Arial, Helvetica, sans-serif;
  color-scheme: light dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-background: #1b1712;
    --color-surface: #241f18;
    --color-paper: #2a2318;
    --color-pocket: rgba(0, 0, 0, 0.26);
    --color-ink: #ece4d6;
    --color-muted: #ab9d89;
    --color-border: #473c2c;
    --color-border-strong: #6b5940;
    --color-accent: #d6ab6d;
    --color-accent-dark: #e8bc7c;
    --color-add: #b8a688;
    --color-on-accent: #241d14;
    --color-input-bg: #2f281d;
    --color-card-face: #322b1f;
    --color-spine: #3a3122;
    --color-error: #e5988a;
    --color-danger-border: #8a5245;
    --gradient-top: rgba(35, 29, 21, 0.55);
    --gradient-bottom: rgba(20, 16, 11, 0.92);
    --surface-rgb: 36, 31, 24;
    --accent-rgb: 214, 171, 109;
    --shadow-rgb: 0, 0, 0;
    --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.45);
    --shadow-card: 0 8px 18px rgba(0, 0, 0, 0.5);
    --pocket-sheen: rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04) 42%, rgba(255, 255, 255, 0.02);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --color-background: #1b1712;
  --color-surface: #241f18;
  --color-paper: #2a2318;
  --color-pocket: rgba(0, 0, 0, 0.26);
  --color-ink: #ece4d6;
  --color-muted: #ab9d89;
  --color-border: #473c2c;
  --color-border-strong: #6b5940;
  --color-accent: #d6ab6d;
  --color-accent-dark: #e8bc7c;
  --color-add: #b8a688;
  --color-on-accent: #241d14;
  --color-input-bg: #2f281d;
  --color-card-face: #322b1f;
  --color-spine: #3a3122;
  --color-error: #e5988a;
  --color-danger-border: #8a5245;
  --gradient-top: rgba(35, 29, 21, 0.55);
  --gradient-bottom: rgba(20, 16, 11, 0.92);
  --surface-rgb: 36, 31, 24;
  --accent-rgb: 214, 171, 109;
  --shadow-rgb: 0, 0, 0;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 8px 18px rgba(0, 0, 0, 0.5);
  --pocket-sheen: rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04) 42%, rgba(255, 255, 255, 0.02);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, var(--gradient-top), var(--gradient-bottom)),
    var(--color-background);
  color: var(--color-ink);
  font-family: var(--font-ui);
  transition: background-color 160ms ease, color 160ms ease;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  padding: 28px 20px 18px;
}

.header-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: min(1080px, 100%);
  margin: 0 auto;
}

.theme-toggle {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.theme-toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--color-border);
  transition: background-color 160ms ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--color-accent-dark);
  transition: transform 160ms ease, background-color 160ms ease;
}

:root[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(14px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle-thumb {
    transform: translateX(14px);
  }
}

.header-text {
  flex: 1 1 auto;
  min-width: 260px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.account-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.account-area button {
  white-space: nowrap;
}

.account-email {
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.sync-status {
  color: var(--color-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-status.is-error {
  color: var(--color-error);
}

.plan-badge {
  padding: 3px 9px;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  color: var(--color-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.plan-badge.is-plus {
  border-color: var(--color-accent-dark);
  color: var(--color-accent-dark);
}

.upgrade-button {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.upgrade-features {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upgrade-features li {
  position: relative;
  padding-left: 22px;
  color: var(--color-ink);
  font-size: 0.94rem;
  font-weight: 700;
}

.upgrade-features li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--color-accent-dark);
}

.upgrade-notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-small);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--color-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.upgrade-notice a {
  color: var(--color-accent-dark);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent-dark);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-button:hover,
.link-button:focus-visible {
  color: var(--color-accent);
}

.brand-mark {
  margin: 0 0 10px;
  color: var(--color-accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-family: var(--font-main);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.subtitle {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--color-muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 10px 0 48px;
}

.site-footer {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
  border-top: 1px solid var(--color-border);
  display: grid;
  gap: 10px;
}

.site-footer-disclaimer {
  max-width: 720px;
  color: var(--color-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  font-size: 0.85rem;
}

.site-footer-links a {
  color: var(--color-muted);
  text-decoration: none;
}

.site-footer-links a:hover,
.site-footer-links a:focus-visible {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

.site-footer-copyright {
  color: var(--color-muted);
  margin-left: auto;
}

.my-binders-view {
  display: grid;
  gap: 18px;
}

.library-header,
.editor-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.library-header {
  padding: 18px 0;
  border-bottom: 1px solid var(--color-border);
}

.library-header h2 {
  margin-bottom: 0;
  font-family: var(--font-main);
  font-size: 2rem;
}

.section-kicker {
  margin-bottom: 6px;
  color: var(--color-accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.library-actions,
.binder-list-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.back-button,
.danger-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-small);
}

.primary-button {
  border: 1px solid var(--color-accent-dark);
  background: var(--color-accent-dark);
  color: var(--color-on-accent);
}

.back-button {
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-accent-dark);
}

.danger-button {
  border: 1px solid var(--color-danger-border);
  background: var(--color-surface);
  color: var(--color-error);
}

.primary-button:hover,
.primary-button:focus-visible,
.back-button:hover,
.back-button:focus-visible,
.danger-button:hover,
.danger-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}

.library-message {
  min-height: 0;
}

.binder-list {
  display: grid;
  gap: 12px;
}

.binder-list-item {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: rgba(var(--surface-rgb), 0.78);
  box-shadow: 0 8px 22px rgba(var(--shadow-rgb), 0.07);
}

.binder-list-details h2 {
  margin-bottom: 6px;
  font-family: var(--font-main);
  font-size: 1.32rem;
}

.binder-list-details p {
  margin-bottom: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.empty-library {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 34px 0;
}

.empty-library h2,
.empty-library p {
  margin-bottom: 0;
}

.empty-library h2 {
  font-family: var(--font-main);
  font-size: 1.6rem;
}

.empty-library p {
  color: var(--color-muted);
}

.editor-navigation {
  min-height: 40px;
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

.binder-workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.binder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: rgba(var(--surface-rgb), 0.82);
  box-shadow: 0 10px 28px rgba(var(--shadow-rgb), 0.08);
}

.binder-name-field,
.layout-field,
.view-mode-field {
  display: grid;
  gap: 7px;
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.binder-name-field {
  flex: 1 1 300px;
  max-width: 420px;
}

.layout-field {
  flex: 0 0 150px;
}

.view-mode-field {
  grid-template-columns: repeat(2, minmax(0, auto));
  align-items: end;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  margin: 0;
}

.view-mode-field legend {
  grid-column: 1 / -1;
  padding: 0;
}

.view-mode-field label {
  display: grid;
}

.view-mode-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.view-mode-field span {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-input-bg);
  color: var(--color-muted);
}

.view-mode-field label:first-of-type span {
  border-radius: var(--radius-small) 0 0 var(--radius-small);
}

.view-mode-field label:last-of-type span {
  margin-left: -1px;
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
}

.view-mode-field input:checked + span {
  border-color: var(--color-accent-dark);
  background: var(--color-accent-dark);
  color: var(--color-on-accent);
}

.view-mode-field input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16);
}

.binder-name-field input,
.layout-field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
  color: var(--color-ink);
  outline: none;
}

.binder-name-field input:focus,
.layout-field select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16);
}

/* Sits inline with the other toolbar fields, but as a single checkbox
   row rather than a stacked label+control -- min-height matches the
   44px controls next to it so its bottom edge lines up with theirs
   under .binder-toolbar's align-items: end. */
.fade-missing-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.fade-missing-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent-dark);
}

.page-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

/* Superseded by the corner nav bar (.mobile-page-nav) that now sits
   directly above the binder content at every width -- kept in the DOM
   rather than removed (same "hide, don't remove" pattern already used
   elsewhere) since js/editor-interactions.js still wires these to the
   exact same goToPreviousPage/goToNextPage handlers as their corner-nav
   counterparts, and js/render.js still updates both in lockstep. */
#previous-page,
#page-indicator,
#next-page {
  display: none;
}

.nav-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--color-accent-dark);
  border-radius: var(--radius-small);
  background: var(--color-accent-dark);
  color: var(--color-on-accent);
  cursor: default;
}

.nav-button:disabled {
  border-color: var(--color-border-strong);
  background: var(--color-border);
  color: var(--color-muted);
}

.quiet-button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  color: var(--color-muted);
}

.quiet-button:hover,
.quiet-button:focus-visible {
  color: var(--color-accent-dark);
  border-color: var(--color-accent);
}

.quiet-button:disabled {
  opacity: 0.5;
}

.binder-data-area {
  display: grid;
  flex: 0 1 auto;
  gap: 6px;
}

.binder-data-controls {
  display: grid;
  grid-template-columns: repeat(5, auto);
  align-items: end;
  gap: 10px;
}

.data-controls-label {
  align-self: center;
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.import-backup-label {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.84rem;
  overflow: hidden;
}

.import-backup-label:hover,
.import-backup-label:focus-within {
  color: var(--color-accent-dark);
  border-color: var(--color-accent);
}

.import-backup-label input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  cursor: pointer;
  opacity: 0;
}

.data-message {
  min-height: 20px;
  margin: 0;
  color: var(--color-muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.data-message.is-error {
  color: var(--color-error);
}

.data-message.is-success {
  color: var(--color-accent-dark);
}

.page-indicator {
  display: grid;
  place-items: center;
  min-width: 78px;
  min-height: 40px;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  color: var(--color-muted);
  font-weight: 700;
}

.binder-stage {
  min-width: 0;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: rgba(var(--surface-rgb), 0.74);
  box-shadow: var(--shadow-soft);
}

/* Shown at every width now, not just mobile (the toolbar's own
   Previous/Next/page-indicator are permanently hidden below in favor of
   this one) -- flanks the actual binder content like turning pages of a
   physical book, rather than sitting in a separate control cluster in
   the toolbar. Constrained and centered to the same per-layout
   footprint the pages themselves use (--binder-max-width/--spread-width,
   set on .binder-stage by renderBinderView in js/render.js) so Previous/
   Next end up right at the pages' actual edges instead of the wider
   stage's. */
.mobile-page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: min(100%, var(--binder-max-width, 760px));
  margin: 0 auto 14px;
}

.binder-stage.is-spread-view .mobile-page-nav {
  max-width: min(100%, var(--spread-width, 1590px));
}

.mobile-nav-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-accent-dark);
  font-size: 1.4rem;
  line-height: 1;
}

.mobile-nav-button:disabled {
  opacity: 0.4;
}

.mobile-page-indicator {
  color: var(--color-muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.binder-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.binder-heading h2 {
  margin-bottom: 0;
  font-family: var(--font-main);
  font-size: 1.55rem;
}

.selection-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--color-accent-dark);
  font-size: 0.84rem;
  font-weight: 700;
}

.selection-status[hidden] {
  display: none;
}

.selection-sleeve-color {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  color: var(--color-accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

.selection-missing-field {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--color-accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

.selection-missing-field input {
  width: 15px;
  height: 15px;
  accent-color: var(--color-accent-dark);
}

.selection-cancel {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  color: var(--color-accent-dark);
}

.binder-viewer {
  min-width: 0;
  width: 100%;
}

.single-page-view {
  display: grid;
}

.spread-scroll {
  max-width: 100%;
  min-width: 0;
  width: 100%;
  overflow-x: auto;
  padding: 2px 0 8px;
}

.spread-view {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 22px minmax(280px, 1fr);
  align-items: center;
  gap: 14px;
  width: min(100%, var(--spread-width, 1590px));
  min-width: min(1180px, var(--spread-width, 1590px));
  margin: 0 auto;
}

.page-frame {
  display: grid;
  gap: 8px;
}

.page-frame-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  color: var(--color-muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-delete-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: none;
}

.page-delete-button:hover,
.page-delete-button:focus-visible {
  color: var(--color-accent-dark);
  border-color: var(--color-accent);
}

.binder-spine {
  align-self: stretch;
  min-height: 220px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(var(--shadow-rgb), 0.08), rgba(255, 255, 255, 0.45), rgba(var(--shadow-rgb), 0.12)),
    var(--color-spine);
  box-shadow: inset 0 0 12px rgba(var(--shadow-rgb), 0.14);
}

.empty-spread-side {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-medium);
  background: rgba(var(--surface-rgb), 0.56);
}

.empty-spread-add {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--color-accent-dark);
  border-radius: var(--radius-small);
  background: var(--color-accent-dark);
  color: var(--color-on-accent);
}

.binder-page {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--binder-columns, 3), 1fr);
  gap: clamp(3px, 0.5vw, 6px);
  width: min(var(--binder-max-width, 760px), 100%);
  margin: 0 auto;
  padding: clamp(14px, 2.6vw, 28px) clamp(14px, 2.6vw, 28px) clamp(14px, 2.6vw, 28px) clamp(24px, 4vw, 48px);
  border: 1px solid var(--color-border-strong);
  border-left: clamp(16px, 3vw, 30px) solid var(--color-spine);
  border-radius: var(--radius-medium);
  background:
    radial-gradient(circle at 14px 15%, rgba(108, 94, 76, 0.24) 0 3px, transparent 4px),
    radial-gradient(circle at 14px 50%, rgba(108, 94, 76, 0.24) 0 3px, transparent 4px),
    radial-gradient(circle at 14px 85%, rgba(108, 94, 76, 0.24) 0 3px, transparent 4px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 16%),
    var(--color-paper);
  box-shadow: inset 0 0 34px rgba(95, 78, 55, 0.1);
}

.spread-view .binder-page {
  width: 100%;
}

.pocket {
  position: relative;
  aspect-ratio: 2.5 / 3.5;
  min-width: 0;
  padding: 3%;
  border: 1px solid rgba(137, 123, 104, 0.64);
  border-radius: var(--radius-small);
  background:
    linear-gradient(135deg, var(--pocket-sheen)),
    var(--color-pocket);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    inset 0 -10px 20px rgba(110, 93, 68, 0.08);
  overflow: hidden;
}

.pocket:focus-visible {
  outline: 3px solid rgba(var(--accent-rgb), 0.28);
  outline-offset: 3px;
}

.pocket.is-drop-target {
  border-color: var(--color-accent);
  box-shadow:
    inset 0 0 0 2px rgba(var(--accent-rgb), 0.28),
    inset 0 -10px 20px rgba(110, 93, 68, 0.08);
}

.pocket.is-selected {
  border-color: var(--color-accent-dark);
  box-shadow:
    0 0 0 3px rgba(var(--accent-rgb), 0.22),
    inset 0 -10px 20px rgba(110, 93, 68, 0.08);
}

.pocket::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 4px;
  pointer-events: none;
}

/* A card fills its pocket edge to edge -- the pocket's own background,
   padding, and decorative inset line are only useful as an empty-slot
   affordance, so hide them once a card (and its sleeve, if any) is
   there instead of showing pocket chrome as a second box around it.
   border-color stays transparent rather than the border being removed
   outright, so is-drop-target/is-selected can still recolor it for
   drag/selection feedback. */
.pocket:not(.empty-pocket) {
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.pocket:not(.empty-pocket)::after {
  content: none;
}

.pocket-number {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--color-accent-dark);
  color: var(--color-on-accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.binder-card {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: 54% 1fr auto;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(49, 43, 34, 0.28);
  border-radius: 5px;
  background: var(--color-card-face);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.binder-card.is-real-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-color: rgba(49, 43, 34, 0.2);
  background: transparent;
}

/* The sleeve border lives on the image/fallback itself, not this outer
   box -- .pocket's percentage padding (resolved against width for both
   axes, a CSS quirk) makes this box's content area slightly off the
   card's true aspect ratio, so a border here would sit a few pixels off
   the actual card edges instead of hugging them like a real sleeve. */
.binder-card.is-real-card.has-sleeve {
  border-color: transparent;
}

/* Dims the whole card (art + sleeve border) rather than adding a badge
   -- reuses the same dimmed-state opacity already established for
   .mobile-nav-button:disabled elsewhere in this file, rather than
   inventing a new value. Only applied when the binder's own
   fadeMissingCards setting is on (see createBinderCard in render.js) --
   the status itself is always tracked, this is just the optional
   visual for it. */
.binder-card.is-missing {
  opacity: 0.4;
}

.binder-card[draggable="true"] {
  cursor: grab;
}

.binder-card[draggable="true"]:active {
  cursor: grabbing;
}

.binder-card-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 5px;
  background: var(--color-input-bg);
}

/* Border sits directly on the image/fallback box, which is sized to the
   actual rendered card (not the slightly-off-ratio outer pocket box
   above), so it hugs the card edges the way a real sleeve would. */
.has-sleeve .binder-card-image,
.has-sleeve .card-image-fallback {
  border: 6px solid var(--sleeve-color);
  border-radius: 8px;
}

.card-image-fallback {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 14px;
  border: 1px dashed var(--color-border-strong);
  border-radius: 5px;
  background: var(--color-input-bg);
  text-align: center;
}

.card-image-fallback-name {
  color: var(--color-ink);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.2;
}

.card-image-fallback-meta {
  color: var(--color-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.card-image-fallback-symbol {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.card-image-fallback-illustrator {
  color: var(--color-muted);
  font-size: 0.62rem;
  font-style: italic;
}

.remove-card {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(36, 32, 27, 0.12);
  border-radius: 999px;
  background: rgba(var(--surface-rgb), 0.82);
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 160ms ease, color 160ms ease;
}

.pocket:hover .remove-card,
.remove-card:focus-visible {
  opacity: 1;
}

.remove-card:hover,
.remove-card:focus-visible {
  color: var(--color-accent-dark);
}

.empty-pocket {
  display: grid;
  place-items: center;
}

.add-card {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(113, 103, 92, 0.52);
  border-radius: 5px;
  color: var(--color-add);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

.new-binder-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-medium);
  background: var(--color-surface);
  color: var(--color-ink);
  box-shadow: 0 24px 70px rgba(36, 32, 27, 0.28);
}

.new-binder-dialog::backdrop {
  background: rgba(36, 32, 27, 0.38);
}

.new-binder-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-field {
  display: grid;
  gap: 7px;
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.dialog-field input,
.dialog-field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
  color: var(--color-ink);
  outline: none;
}

.dialog-field input:focus,
.dialog-field select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.auth-dialog-actions {
  align-items: center;
  justify-content: space-between;
}

.import-local-intro {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.import-local-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.import-local-item {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
}

.import-local-item strong {
  display: block;
  color: var(--color-ink);
  font-size: 0.94rem;
}

.import-local-item span {
  display: block;
  margin-top: 2px;
  color: var(--color-muted);
  font-size: 0.82rem;
}

.card-dialog {
  width: min(960px, calc(100% - 32px));
  max-height: min(880px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-medium);
  background: transparent;
  color: var(--color-ink);
  box-shadow: 0 24px 70px rgba(36, 32, 27, 0.28);
}

.card-dialog::backdrop {
  background: rgba(36, 32, 27, 0.38);
}

.dialog-panel {
  padding: 20px;
  background: var(--color-surface);
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dialog-kicker {
  margin-bottom: 6px;
  color: var(--color-accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dialog-header h2 {
  margin-bottom: 0;
  font-family: var(--font-main);
  font-size: 1.55rem;
}

.dialog-close {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
  color: var(--color-accent-dark);
}

.search-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.search-field {
  display: grid;
  gap: 7px;
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.search-modifiers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
}

.search-mode-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.search-mode-field select {
  min-height: 30px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-weight: 700;
  outline: none;
}

.search-mode-field select:hover,
.search-mode-field select:focus {
  border-color: var(--color-border-strong);
  background: var(--color-input-bg);
  color: var(--color-ink);
}

.search-field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
  color: var(--color-ink);
  outline: none;
}

.search-field input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16);
}

.search-message {
  min-height: 22px;
  margin-bottom: 14px;
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-height: min(64vh, 680px);
  overflow-y: auto;
  padding-right: 4px;
}

.search-result-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
  color: inherit;
  text-align: left;
}

.search-result-card:hover,
.search-result-card:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}

.search-result-image-wrap {
  display: grid;
  place-items: center;
  aspect-ratio: 2.5 / 3.5;
  min-height: 180px;
  border-radius: 5px;
  background: var(--color-paper);
  overflow: hidden;
}

.search-result-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.search-result-text {
  display: grid;
  gap: 2px;
  color: var(--color-muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.search-result-text strong {
  color: var(--color-ink);
  font-size: 0.92rem;
}

.search-result-set-line {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Smaller than the fallback-box version -- this sits inline in a single
   text line next to the set name, not stacked in a dedicated card face. */
.search-result-set-line .card-image-fallback-symbol {
  width: 16px;
  height: 16px;
}

.search-result-illustrator {
  font-size: 0.68rem;
  font-style: italic;
  font-weight: 600;
}

.search-show-more {
  grid-column: 1 / -1;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
  color: var(--color-accent-dark);
  font-weight: 700;
}

.search-show-more:hover,
.search-show-more:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}

.search-show-more:disabled {
  cursor: wait;
  opacity: 0.62;
}

.search-result-set-logo {
  display: block;
  max-width: 82%;
  max-height: 60%;
  object-fit: contain;
}

.search-set-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-input-bg);
}

.search-set-back {
  color: var(--color-accent-dark);
  font-weight: 700;
  white-space: nowrap;
}

.search-set-toolbar-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.search-set-add-all {
  padding: 8px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-weight: 700;
  white-space: nowrap;
}

.search-set-add-all:hover,
.search-set-add-all:focus-visible {
  filter: brightness(1.05);
}

.search-set-add-all:disabled {
  cursor: wait;
  opacity: 0.62;
}

/* Gives the illustrator tile a card-like frame (border + rounded
   corners) instead of the plain image-wrap every other result tile
   uses -- position:relative so the name banner can sit over the
   generic avatar icon like a real card's name plate. */
.illustrator-card-frame {
  position: relative;
  border: 3px solid var(--color-accent-dark);
  border-radius: 10px;
}

.illustrator-card-name-banner {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 1;
  overflow: hidden;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(20, 15, 8, 0.72);
  color: #fdf6e8;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Generic person silhouette standing in for a picture -- deliberately
   not a real photo (none exists for these illustrators) and not
   another Pokemon card's art (confusing -- see createIllustratorResultCard
   in render.js). Sized down from the full frame so it doesn't crowd
   the name banner above it. */
.illustrator-card-avatar {
  width: 42%;
  height: 42%;
  margin-top: 12%;
  fill: var(--color-border-strong);
}

@media (max-width: 720px) {
  .site-header {
    padding-top: 22px;
  }

  .header-content {
    flex-wrap: wrap;
  }

  h1 {
    font-size: 2.1rem;
  }

  .subtitle {
    font-size: 0.94rem;
  }

  .binder-toolbar {
    align-items: stretch;
    flex-direction: column;
    order: 2;
  }

  /* Binder content first, toolbar controls below it -- the corner nav
     bar (.mobile-page-nav, styled above) already sits at the top of the
     binder content itself, not this toolbar. */
  .binder-stage {
    order: 1;
  }

  .library-header {
    align-items: flex-start;
  }

  .binder-list-item {
    grid-template-columns: 1fr;
  }

  .binder-list-actions {
    justify-content: flex-start;
  }

  .binder-heading {
    align-items: start;
    flex-direction: column;
  }

  .binder-name-field {
    flex: none;
    max-width: none;
  }

  .layout-field {
    flex-basis: auto;
  }

  .view-mode-field {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .binder-data-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .binder-data-area {
    width: 100%;
  }

  .data-controls-label {
    grid-column: 1 / -1;
  }

  .nav-button,
  .quiet-button,
  .import-backup-label,
  .page-indicator {
    width: 100%;
  }

  .search-results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-set-toolbar {
    flex-wrap: wrap;
  }

  .search-set-toolbar-info {
    order: 1;
    flex-basis: 100%;
    white-space: normal;
  }
}

@media (max-width: 460px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-bottom: 28px;
  }

  .binder-stage {
    padding: 12px;
  }

  .library-header {
    flex-direction: column;
  }

  .library-actions,
  .binder-list-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .library-actions button,
  .binder-list-actions button {
    width: 100%;
  }

  .binder-list-actions .danger-button {
    grid-column: 1 / -1;
  }

  .editor-navigation {
    align-items: flex-start;
    flex-direction: column;
  }

  .binder-page {
    gap: 4px;
    padding: 12px 10px 12px 22px;
  }

  .spread-scroll {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .spread-view {
    grid-template-columns: minmax(225px, 1fr) 14px minmax(225px, 1fr);
    gap: 8px;
    min-width: min(690px, var(--spread-width, 1590px));
  }

  .binder-spine {
    min-height: 170px;
  }

  .page-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .binder-data-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pocket {
    padding: 3%;
  }

  .pocket-number {
    width: 19px;
    height: 19px;
    font-size: 0.66rem;
  }

  .card-image-fallback-name {
    font-size: 0.72rem;
  }

  .card-image-fallback-meta {
    font-size: 0.58rem;
  }

  .add-card {
    font-size: 0.68rem;
  }

  .binder-page[data-layout="12"] .pocket-number {
    width: 17px;
    height: 17px;
    font-size: 0.58rem;
  }

  .binder-page[data-layout="12"] .add-card {
    font-size: 0.6rem;
  }

  .dialog-panel {
    padding: 14px;
  }

  .search-results-grid {
    gap: 10px;
    max-height: 52vh;
  }

  .search-result-card {
    padding: 8px;
  }

  .search-result-image-wrap {
    min-height: 136px;
  }

  .search-result-text {
    font-size: 0.68rem;
  }

  .search-result-text strong {
    font-size: 0.78rem;
  }
}

