:root {
  --navy: #0f2233;
  --navy-2: #162f43;
  --cream: #fafaf8;
  --muted: rgba(250, 250, 248, 0.68);
  --line: rgba(250, 250, 248, 0.14);
  --orange: #e85d2c;
  --orange-dark: #c9471d;
  --panel: rgba(255, 255, 255, 0.055);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

@font-face {
  font-family: "Sequel Sans";
  src: url("assets/sequel-sans-book-disp.otf") format("opentype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Sequel Sans";
  src: url("assets/sequel-sans-light-disp.otf") format("opentype");
  font-style: normal;
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Caeli";
  src: url("assets/caeli-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Caeli";
  src: url("assets/caeli-bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Caeli";
  src: url("assets/caeli-light.ttf") format("truetype");
  font-style: normal;
  font-weight: 300;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Sequel Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--navy);
  color: var(--cream);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

body[data-auth="locked"] .app-shell {
  display: none;
}

body[data-auth="unlocked"] .pin-gate {
  display: none;
}

.pin-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px clamp(18px, 4vw, 56px);
}

.pin-card {
  width: min(430px, 100%);
  display: grid;
  gap: 22px;
  text-align: center;
}

.pin-card img {
  width: min(330px, 84%);
  max-height: 42px;
  object-fit: contain;
  justify-self: center;
}

.pin-card form {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.pin-card label {
  width: min(340px, 100%);
  text-align: center;
}

.pin-card input[type="password"] {
  text-align: center;
}

button,
input,
a {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 28px clamp(18px, 4vw, 56px);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 48px;
}

body[data-state="upload"] .site-header {
  justify-content: center;
}

body[data-state="upload"] .header-actions {
  display: none;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup img#brandLogo {
  display: block;
  width: clamp(220px, 22vw, 350px);
  max-height: 38px;
  object-fit: contain;
}

.brand-lockup img#brandLogo:not([src]),
.brand-lockup img#brandLogo.is-missing {
  display: none;
}

.asset-preload {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.brand-fallback {
  display: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-lockup img#brandLogo.is-missing + .brand-fallback {
  display: inline;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dev-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.dev-toggle input {
  accent-color: var(--orange);
}

.state-panel {
  display: none;
  padding: clamp(42px, 8vh, 92px) 0 36px;
}

.state-panel.active {
  display: block;
}

.upload-wrap,
.download-layout {
  width: min(760px, 100%);
  margin: 0 auto;
  text-align: center;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 28px;
  color: var(--cream);
  font-size: clamp(40px, 7vw, 104px);
  font-weight: 300;
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
}

.dropzone {
  display: flex;
  min-height: 270px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  border: 1px dashed rgba(250, 250, 248, 0.35);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    rgba(0, 0, 0, 0.08);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--orange);
  background: rgba(232, 93, 44, 0.1);
  transform: translateY(-1px);
}

.dropzone input,
.secondary-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone-title {
  color: var(--cream);
  font-family: "Caeli", "Sequel Sans", Inter, system-ui, sans-serif;
  font-size: clamp(24px, 2.4vw, 36px);
  font-weight: 400;
  text-transform: none;
}

.dropzone-subtitle,
.footer-note {
  color: var(--muted);
  font-size: 14px;
}

.footer-note {
  margin-top: 28px;
  font-family: "Caeli", "Sequel Sans", Inter, system-ui, sans-serif;
  font-weight: 300;
}

.section-heading {
  max-width: 980px;
  margin-bottom: 28px;
}

.section-heading h1 {
  max-width: 900px;
  margin-bottom: 0;
  font-size: clamp(42px, 6.3vw, 88px);
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.editor-panel,
.pages-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.045)),
    rgba(11, 24, 34, 0.64);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.editor-panel {
  position: sticky;
  top: 24px;
  padding: 24px;
}

.pages-panel {
  padding: 22px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.panel-header span {
  color: var(--muted);
  font-size: 12px;
}

.field-grid {
  display: grid;
  gap: 15px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input[type="text"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(250, 250, 248, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream);
  padding: 10px 12px;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--orange);
}

.coverart-editor {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 16px;
  margin: 22px 0;
}

.coverart-preview {
  width: 128px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.16);
  color: rgba(250, 250, 248, 0.44);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}

.coverart-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.coverart-actions p {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.primary-button {
  width: 100%;
  background: var(--orange);
  color: #fff;
  padding: 12px 18px;
  font-weight: 500;
}

.primary-button:hover {
  background: var(--orange-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.secondary-button,
.ghost-button {
  border: 1px solid rgba(250, 250, 248, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--cream);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
}

.ghost-button {
  min-height: 38px;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: rgba(250, 250, 248, 0.34);
  background: rgba(255, 255, 255, 0.1);
}

.hidden {
  display: none;
}

.status-message {
  min-height: 18px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-message.is-error {
  color: #ffb39d;
}

.upload-status {
  margin-top: 18px;
  margin-bottom: 0;
}

.page-viewer {
  display: grid;
  gap: 18px;
}

.page-viewer-frame {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 16px;
  align-items: center;
}

.page-preview-wrap {
  max-height: min(72vh, 620px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 18px;
}

.page-preview {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
}

.page-nav-button {
  width: 48px;
  aspect-ratio: 1;
  border: 1px solid rgba(250, 250, 248, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--cream);
  cursor: pointer;
  font-size: 34px;
  line-height: 1;
}

.page-nav-button:disabled {
  cursor: default;
  opacity: 0.25;
}

.page-viewer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-button {
  min-height: 34px;
  padding: 7px 10px;
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--cream);
  font-size: 13px;
  font-weight: 700;
}

.page-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.page-content {
  color: rgba(250, 250, 248, 0.84);
  font-size: 12px;
  line-height: 1.35;
}

.include-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.include-toggle input {
  accent-color: var(--orange);
}

.download-preview-wrap {
  width: min(360px, 100%);
  margin: 0 auto 24px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

#coverPreviewCanvas {
  display: block;
  width: 100%;
  height: auto;
}

.download-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.download-actions .primary-button {
  width: auto;
  min-width: 180px;
}

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

  .editor-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 20px 14px;
  }

  .site-header,
  .header-actions,
  .coverart-editor {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-viewer-frame {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 8px;
  }

  .page-nav-button {
    width: 36px;
    font-size: 26px;
  }

  .page-viewer-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-actions {
    justify-content: flex-start;
  }
}
