/* Purpose: V1 simple paper-builder wizard demo styles (layered on paper_studio.css). */

.pw-page {
  background:
    radial-gradient(circle at 12% 0%, rgba(251, 191, 36, 0.16), transparent 34%),
    radial-gradient(circle at 88% 10%, rgba(26, 92, 51, 0.5), transparent 42%),
    linear-gradient(135deg, #01411c 0%, #1a5c33 48%, #0f172a 100%);
  background-attachment: fixed;
  color: #fff;
  overflow-x: hidden;
}
.pw-topbar { position: sticky; }
.pw-auth-actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.pw-auth-actions[hidden] { display: none !important; }
.pw-page .ps-modal { color: var(--ps-ink); }

/* ── Landing ── */
.pw-landing { padding-top: 44px; }
.pw-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
  align-items: center;
  gap: clamp(28px, 5vw, 70px);
  padding: 24px 0 52px;
}
.pw-hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.3rem, 5vw, 3.9rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  color: #fff;
}
.pw-hero h1 span { color: var(--ps-gold); }
.pw-hero-lead {
  max-width: 650px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.7;
}
.pw-hero .ps-eyebrow { color: var(--ps-gold); }
.pw-hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.pw-hero-actions .ps-button-large { min-height: 54px; }
.pw-topbar .ps-button-primary,
.pw-hero-actions .ps-button-primary {
  background: var(--ps-gold); color: #3b2a06;
  box-shadow: 0 12px 26px rgba(251, 191, 36, 0.2);
}
.pw-topbar .ps-button-primary:hover,
.pw-hero-actions .ps-button-primary:hover { background: #f5b400; }
.pw-hero-actions .ps-button-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(10px);
}
.pw-hero-actions .ps-button-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.4);
}
.pw-hero-note { max-width: 560px; margin-top: 14px; color: rgba(255, 255, 255, 0.56); }

.pw-sample-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: 18px;
  padding: 24px 26px 20px;
  box-shadow: 0 26px 60px rgba(1, 65, 28, 0.14);
  transform: rotate(1.5deg);
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ps-ink);
}
.pw-sample-card::before {
  content: "";
  position: absolute;
  inset: 10px -10px -10px 10px;
  border: 1px solid rgba(1, 65, 28, 0.12);
  border-radius: 18px;
  z-index: -1;
}
.pw-sample-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.pw-sample-logo {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--ps-green); color: #fff; font-family: "Inter", sans-serif; font-weight: 800;
}
.pw-sample-head strong { display: block; font-size: .86rem; text-transform: uppercase; letter-spacing: .04em; }
.pw-sample-head span { display: block; margin-top: 2px; color: #6b7280; font-size: .72rem; }
.pw-sample-card h3 { margin: 0; text-align: center; font-size: 1.3rem; }
.pw-sample-meta { display: flex; justify-content: center; gap: 12px; margin: 7px 0 16px; color: #4b5563; font-size: .75rem; }
.pw-sample-section { border-top: 1px solid #e5e7eb; padding-top: 10px; margin-top: 10px; }
.pw-sample-section strong { display: block; font-size: .78rem; }
.pw-sample-section span { float: right; margin-top: -1.05rem; color: #6b7280; font-size: .68rem; }
.pw-sample-section i {
  display: block; height: 7px; margin-top: 8px;
  background: linear-gradient(90deg, #e5e7eb, #f3f4f6);
  border-radius: 999px;
}
.pw-sample-section i:nth-of-type(2) { width: 86%; }
.pw-sample-section i:nth-of-type(3) { width: 68%; }
.pw-sample-footer { text-align: center; margin-top: 18px; padding-top: 10px; border-top: 1px solid #e5e7eb; color: #9ca3af; font-size: .65rem; }

.pw-draft-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  padding: 16px 18px; margin: 0 0 28px;
  background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--ps-radius-sm); backdrop-filter: blur(12px);
}
.pw-draft-banner strong { display: block; color: var(--ps-gold); }
.pw-draft-banner span { display: block; margin-top: 2px; color: rgba(255, 255, 255, 0.66); font-size: .86rem; }
.pw-draft-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pw-how-head { margin-bottom: 18px; }
.pw-how-head .ps-eyebrow { color: var(--ps-gold); }
.pw-how-head h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2rem); color: #fff; }
.pw-how-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.pw-how-card {
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--ps-radius-sm); padding: 20px; box-shadow: 0 16px 38px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(12px);
}
.pw-how-card > span {
  width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center;
  background: rgba(251, 191, 36, 0.15); color: var(--ps-gold); font-weight: 800; margin-bottom: 12px;
}
.pw-how-card h3 { margin: 0 0 6px; font-size: 1rem; color: #fff; }
.pw-how-card p { margin: 0; color: rgba(255, 255, 255, 0.62); font-size: .87rem; line-height: 1.55; }

.pw-advanced-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  margin-top: 34px; padding: 22px 24px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--ps-radius); box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
}
.pw-advanced-strip strong { font-size: 1rem; color: #fff; }
.pw-advanced-strip p { margin: 4px 0 0; color: rgba(255, 255, 255, 0.62); font-size: .88rem; max-width: 720px; }
.pw-advanced-strip .ps-button-secondary {
  background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255, 255, 255, 0.22);
}
.pw-advanced-strip .ps-button-secondary:hover { background: rgba(255, 255, 255, 0.14); }

/* ── Wizard shell ── */
.pw-modal-backdrop {
  position: fixed; inset: 0; z-index: 75; display: grid; place-items: center;
  padding: 20px; background: rgba(10, 24, 16, 0.6); backdrop-filter: blur(7px);
}
.pw-modal-backdrop[hidden] { display: none; }
.pw-wizard {
  width: min(1080px, 100%);
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ps-card); border-radius: 24px;
  border: 1px solid rgba(251, 191, 36, 0.22);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.44), 0 0 0 1px rgba(251, 191, 36, 0.08);
  color: var(--ps-ink);
}
.pw-wizard-head {
  position: relative; padding: 20px 24px 0;
  background: linear-gradient(135deg, #01411c 0%, #0a2c19 100%);
  color: #fff; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.pw-wizard-heading { display: flex; align-items: center; gap: 14px; padding-right: 48px; }
.pw-step-badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 6px 11px; background: rgba(251, 191, 36, 0.15); color: var(--ps-gold);
  border: 1px solid rgba(251, 191, 36, 0.28);
  font-size: .76rem; font-weight: 700; white-space: nowrap;
}
.pw-wizard-head h2 { margin: 0; font-size: clamp(1.2rem, 2.2vw, 1.55rem); letter-spacing: -0.02em; color: #fff; }
.pw-close {
  position: absolute; top: 16px; right: 16px;
  color: #fff; border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08);
}
.pw-close:hover { background: rgba(255, 255, 255, 0.16); }
.pw-progress { height: 5px; margin: 16px -24px 0; background: rgba(255, 255, 255, 0.12); }
.pw-progress > div { height: 100%; width: 25%; background: var(--ps-gold); border-radius: 0 999px 999px 0; transition: width .22s ease; }

.pw-wizard-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 24px;
  background: #f6f8f4; overscroll-behavior: contain;
}
.pw-step[hidden] { display: none; }
.pw-step-lead { margin: 0 0 22px; color: var(--ps-muted); font-size: .95rem; }
.pw-field-title { margin: 24px 0 10px; font-size: .92rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ps-muted); }
.pw-field-title:first-of-type { margin-top: 0; }
.pw-empty { margin: 0; padding: 18px; color: var(--ps-muted); font-size: .9rem; border: 1px dashed var(--ps-line); border-radius: 14px; }

.pw-wizard-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #01411c 0%, #0a2c19 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.pw-summary-bar {
  min-width: 0; color: rgba(255, 255, 255, 0.72); font-size: .84rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pw-footer-actions { display: flex; gap: 10px; flex: none; }
.pw-wizard-footer .ps-button-secondary {
  background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255, 255, 255, 0.22);
}
.pw-wizard-footer .ps-button-secondary:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.38); }
.pw-wizard-footer .ps-button-primary { background: var(--ps-gold); color: #3b2a06; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2); }
.pw-wizard-footer .ps-button-primary:hover { background: #f5b400; }

/* ── Choice cards ── */
.pw-card-grid { display: grid; gap: 11px; }
.pw-class-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.pw-subject-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pw-chapter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pw-choice-card {
  position: relative;
  text-align: left; border: 1px solid var(--ps-green);
  background: linear-gradient(145deg, #ffffff 0%, #f0f7f1 100%);
  border-radius: 14px; padding: 14px; cursor: pointer; color: #123a22;
  transition: border-color .15s, box-shadow .15s, transform .15s, background .15s;
}
.pw-choice-card:hover {
  border-color: var(--ps-green-dark);
  background: linear-gradient(145deg, #fbfdfb 0%, #e6f2e8 100%);
  transform: translateY(-1px);
}
.pw-choice-card strong { display: block; font-size: 1rem; line-height: 1.25; color: #123a22; }
.pw-choice-card span { display: block; margin-top: 5px; color: #5b6b61; font-size: .8rem; line-height: 1.35; }
.pw-choice-card.is-selected {
  border-color: var(--ps-green);
  background: linear-gradient(145deg, #0a5b2a 0%, #01411c 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(1, 65, 28, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.pw-choice-card.is-selected strong { color: #fff; }
.pw-choice-card.is-selected span { color: rgba(255, 255, 255, 0.76); }
.pw-choice-card.is-selected::before {
  content: "✓";
  position: absolute; top: 8px; right: 9px;
  width: 20px; height: 20px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--ps-gold); color: #3b2a06;
  font-family: "Inter", sans-serif; font-size: .68rem; font-weight: 900; line-height: 1;
}
.pw-class-grid .pw-choice-card { text-align: center; padding: 15px 8px; }
.pw-class-grid .pw-choice-card strong { font-size: 1.05rem; }
.pw-subject-grid .pw-choice-card { border-left: 4px solid var(--ps-green); }
.pw-subject-grid .pw-choice-card.is-selected { border-left-color: var(--ps-green); }
.pw-subject-grid .pw-choice-card strong { font-size: .98rem; }
.pw-option-grid { display: flex; align-items: stretch; gap: 12px; }
.pw-option-grid .pw-choice-card { flex: 1 1 0; min-width: 0; min-height: 112px; display: flex; flex-direction: column; justify-content: center; padding: 18px; }
.pw-option-grid .pw-choice-card strong { font-size: 1.02rem; }
.pw-or {
  flex: 0 0 auto; align-self: center;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--ps-green-soft); color: var(--ps-green);
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
}
.pw-option-grid .pw-choice-card:not(.is-selected)[data-coverage="full"] {
  background: linear-gradient(145deg, #fbfdfb 0%, #e6f2e8 100%);
}
.pw-option-grid .pw-choice-card:not(.is-selected)[data-coverage="half"] {
  background: linear-gradient(145deg, #f8fbf4 0%, #e4eeda 100%);
  border-color: var(--ps-green);
}
.pw-option-grid .pw-choice-card:not(.is-selected)[data-coverage="half"] strong { color: #2f4a1f; }
.pw-option-grid .pw-choice-card:not(.is-selected)[data-coverage="half"] span { color: #5b6b61; }
.pw-option-grid .pw-choice-card:not(.is-selected)[data-coverage="chapters"] {
  background: linear-gradient(145deg, #f7fcf8 0%, #dceee2 100%);
}
.pw-option-grid .pw-choice-card:hover { border-color: var(--ps-green); }

.pw-half-controls { margin-top: 18px; padding: 16px; background: linear-gradient(145deg, #fbfdfb 0%, #eef7ef 100%); border: 1px solid #c9dccd; border-radius: 14px; }
.pw-segmented { display: inline-flex; border: 1px solid var(--ps-line); border-radius: 999px; overflow: hidden; background: #fff; }
.pw-segmented button {
  border: 0; background: transparent; padding: 9px 16px; font-size: .86rem; font-weight: 600;
  color: var(--ps-muted); cursor: pointer;
}
.pw-segmented button.is-selected { background: var(--ps-green); color: #fff; }
.pw-inline-note { margin: 10px 0 0; color: var(--ps-muted); font-size: .84rem; }

.pw-chapter-picker { margin-top: 18px; }
.pw-chapter-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.pw-chapter-toolbar span { color: var(--ps-muted); font-size: .84rem; font-weight: 600; }
.pw-chapter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.pw-chapter-grid .pw-choice-card {
  position: relative; padding: 11px 12px; padding-right: 58px;
  border-radius: 10px; border-color: rgba(1, 65, 28, 0.22);
  background: #fff; box-shadow: none;
}
.pw-chapter-grid .pw-choice-card:hover {
  background: #f7fbf7; border-color: var(--ps-green); transform: none;
}
.pw-chapter-grid .pw-choice-card strong { font-size: .9rem; line-height: 1.25; }
.pw-chapter-grid .pw-choice-card span { margin-top: 3px; font-size: .72rem; color: #7b8a80; }
.pw-chapter-grid .pw-choice-card.is-selected {
  background: var(--ps-green); border-color: var(--ps-green); box-shadow: none;
}
.pw-chapter-grid .pw-choice-card.is-selected strong { color: #fff; }
.pw-chapter-grid .pw-choice-card.is-selected span { color: rgba(255, 255, 255, 0.7); }
.pw-chapter-grid .pw-choice-card::after {
  content: attr(data-count); position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  padding: 0; border-radius: 0; background: transparent;
  color: #7b8a80; font-size: .68rem; font-weight: 600;
}
.pw-chapter-grid .pw-choice-card.is-selected::after { background: transparent; color: rgba(255, 255, 255, 0.72); }
.pw-chapter-grid .pw-choice-card.is-selected::before { display: none; }
.pw-chapter-grid .pw-choice-card.is-disabled { opacity: .5; cursor: not-allowed; transform: none; }
.pw-book-chip {
  display: flex; align-items: center; gap: 9px; margin-top: 18px; padding: 11px 13px;
  border-radius: 12px; border: 1px solid var(--ps-line); background: var(--ps-green-soft);
  color: var(--ps-green); font-size: .85rem; font-weight: 600;
}

/* ── Marks, time, patterns ── */
.pw-meta-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pw-marks-box, .pw-time-box {
  padding: 18px;
  background: linear-gradient(145deg, #ffffff 0%, #f0f7f1 100%);
  border: 1px solid var(--ps-green); border-radius: 14px;
}
.pw-field-label { display: block; margin-bottom: 9px; font-size: .84rem; font-weight: 700; }
.pw-marks-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pw-marks-input { width: 112px; font-size: 1.4rem; font-weight: 800; padding: 8px 11px; border-color: var(--ps-green); }
.pw-marks-hint { color: var(--ps-muted); font-size: .8rem; }
.pw-chip-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.pw-chip {
  border: 1px solid var(--ps-green); background: #fff; color: var(--ps-ink);
  border-radius: 999px; padding: 7px 12px; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.pw-chip:hover { border-color: var(--ps-green-dark); }
.pw-chip.is-selected { background: var(--ps-green); border-color: var(--ps-green); color: #fff; }
.pw-time-selects { display: flex; align-items: center; gap: 8px; }
.pw-time-selects select { width: auto; min-width: 96px; padding: 9px 11px; font-weight: 600; border-color: var(--ps-green); }
.pw-time-selects span { font-weight: 800; color: var(--ps-muted); }

.pw-pattern-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-top: 26px; }
.pw-pattern-head .pw-field-title { margin: 0 0 2px; }
.pw-pattern-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.pw-pattern-card {
  position: relative; text-align: left; border: 1px solid var(--ps-green);
  background: linear-gradient(145deg, #ffffff 0%, #f0f7f1 100%);
  border-radius: 14px; padding: 18px; cursor: pointer; color: #123a22;
  transition: border-color .15s, box-shadow .15s, transform .15s, background .15s;
}
.pw-pattern-card:hover {
  border-color: var(--ps-green-dark);
  background: linear-gradient(145deg, #fbfdfb 0%, #e6f2e8 100%);
  transform: translateY(-1px);
}
.pw-pattern-card.is-selected {
  border-color: var(--ps-green);
  background: linear-gradient(145deg, #0a5b2a 0%, #01411c 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(1, 65, 28, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.pw-pattern-card.is-selected::after {
  content: "✓";
  position: absolute; top: 10px; right: 11px;
  width: 21px; height: 21px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--ps-gold); color: #3b2a06;
  font-family: "Inter", sans-serif; font-size: .7rem; font-weight: 900; line-height: 1;
}
.pw-pattern-card.is-disabled { opacity: .55; cursor: not-allowed; transform: none; }
.pw-pattern-badge {
  display: inline-block; margin-bottom: 9px; padding: 4px 8px; border-radius: 999px;
  background: #fff7e6; border: 1px solid #f3d38a; color: #7a5a10;
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em;
}
.pw-pattern-card h4 { margin: 0; font-size: 1.02rem; color: inherit; }
.pw-pattern-card > p { margin: 4px 0 0; color: #5b6b61; font-size: .8rem; }
.pw-pattern-card.is-selected > p { color: rgba(255, 255, 255, 0.72); }
.pw-pattern-breakdown { list-style: none; padding: 0; margin: 11px 0 0; display: grid; gap: 4px; }
.pw-pattern-breakdown li { display: flex; justify-content: space-between; gap: 10px; color: #5b6b61; font-size: .8rem; }
.pw-pattern-breakdown li strong { color: #123a22; font-weight: 600; }
.pw-pattern-card.is-selected .pw-pattern-breakdown li,
.pw-pattern-card.is-selected .pw-pattern-breakdown li strong { color: rgba(255, 255, 255, 0.84); }
.pw-pattern-total { display: block; margin-top: 11px; padding-top: 9px; border-top: 1px solid #eef2ee; font-size: .79rem; font-weight: 700; color: var(--ps-green); }
.pw-pattern-card.is-selected .pw-pattern-total { color: var(--ps-gold); border-top-color: rgba(255, 255, 255, 0.18); }
.pw-pattern-empty { grid-column: 1 / -1; padding: 18px; border: 1px dashed var(--ps-line); border-radius: 12px; color: var(--ps-muted); font-size: .88rem; }

.pw-custom-panel {
  margin-top: 14px; padding: 18px;
  background: linear-gradient(145deg, #ffffff 0%, #f0f7f1 100%);
  border: 1px solid var(--ps-green); border-radius: 14px;
}
.pw-custom-panel[hidden] { display: none; }
.pw-custom-head, .pw-custom-row {
  display: grid; grid-template-columns: minmax(0, 1.5fr) 1.1fr 1fr .7fr;
  gap: 10px; align-items: center;
}
.pw-custom-head { padding: 0 4px 9px; color: var(--ps-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.pw-custom-row { padding: 9px 4px; border-top: 1px solid #eef2ee; }
.pw-custom-row .pw-type-label { font-size: .85rem; font-weight: 600; }
.pw-stepper { display: flex; align-items: center; gap: 5px; }
.pw-stepper button {
  width: 30px; height: 30px; border: 1px solid var(--ps-green); border-radius: 9px;
  background: #fff; color: var(--ps-green); font-size: 1rem; font-weight: 800; line-height: 1;
}
.pw-stepper button:hover { border-color: var(--ps-green-dark); }
.pw-stepper input { width: 54px; padding: 6px; text-align: center; font-weight: 700; border-color: var(--ps-green); }
.pw-custom-row .pw-marks-input-sm { width: 72px; padding: 6px; text-align: center; border-color: var(--ps-green); }
.pw-custom-row .pw-row-total { text-align: right; font-size: .9rem; }
.pw-custom-total {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--ps-line);
}
.pw-custom-total strong { font-size: .94rem; }
.pw-custom-total span { display: block; margin-top: 2px; color: var(--ps-muted); font-size: .78rem; }

.pw-pattern-status { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: .86rem; background: #f8faf8; border: 1px solid var(--ps-line); color: var(--ps-muted); }
.pw-pattern-status.is-ok { background: #f2faf4; border-color: #b7e0c2; color: var(--ps-success); }
.pw-pattern-status.is-warn { background: #fffaf0; border-color: #f3d38a; color: #7a5a10; }
.pw-pattern-status.is-bad { background: #fff5f5; border-color: #f2b8b8; color: var(--ps-danger); }
.pw-pattern-status ul { margin: 6px 0 0; padding-left: 18px; }

/* ── Preview ── */
.pw-preview-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(240px, .7fr); gap: 22px; align-items: start; }
.pw-paper {
  position: relative; background: #fff; border: 1px solid #cfd8d2; border-radius: 12px;
  padding: 28px 30px 26px; font-family: Georgia, "Times New Roman", serif; font-size: .86rem;
  box-shadow: var(--ps-shadow-soft); overflow: hidden;
}
.pw-paper-head { text-align: center; border-bottom: 2px solid #1f2937; padding-bottom: 12px; }
.pw-paper-school { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #4b5563; }
.pw-paper-head h2 { margin: 6px 0 2px; font-size: 1.35rem; }
.pw-paper-subject { margin: 0; color: #374151; font-weight: 600; }
.pw-paper-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 3px 16px; margin-top: 9px; color: #4b5563; font-size: .74rem; }
.pw-paper-section { margin-top: 18px; }
.pw-paper-section-title { font-weight: 700; font-size: .88rem; border-bottom: 1px solid #d1d5db; padding-bottom: 4px; }
.pw-paper-section-title small { font-weight: 600; color: #4b5563; }
.pw-paper-line { height: 10px; margin-top: 10px; border-bottom: 1px dashed #d1d5db; }
.pw-paper-line.is-short { width: 74%; }
.pw-paper-lock {
  display: flex; align-items: center; gap: 12px;
  margin: 22px -30px -26px; padding: 15px 30px;
  background: linear-gradient(180deg, rgba(255,255,255,.75), #fff7e6 45%);
  border-top: 1px solid #f3d38a;
}
.pw-paper-lock[hidden] { display: none; }
.pw-lock-icon { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; background: #fff3d6; color: #b45309; }
.pw-paper-lock strong { display: block; color: #5f430b; font-family: "Inter", sans-serif; font-size: .86rem; }
.pw-paper-lock p { margin: 2px 0 0; color: #7a5a10; font-family: "Inter", sans-serif; font-size: .78rem; }

.pw-preview-side { background: #fff; border: 1px solid var(--ps-line); border-radius: 16px; padding: 18px; box-shadow: var(--ps-shadow-soft); }
.pw-preview-side h3 { margin: 0 0 12px; font-size: 1rem; }
.pw-summary-list { display: grid; gap: 8px; }
.pw-summary-list > div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 7px; border-bottom: 1px solid #eef2ee; font-size: .84rem; }
.pw-summary-list > div:last-child { border-bottom: 0; }
.pw-summary-list span { color: var(--ps-muted); }
.pw-summary-list strong { text-align: right; }
.pw-preview-availability { margin-top: 14px; padding: 11px 12px; border-radius: 11px; background: #f8faf8; border: 1px solid var(--ps-line); color: var(--ps-muted); font-size: .8rem; }
.pw-preview-availability.is-ok { background: #f2faf4; border-color: #b7e0c2; color: var(--ps-success); }
.pw-preview-availability.is-bad { background: #fff5f5; border-color: #f2b8b8; color: var(--ps-danger); }
.pw-generation-status {
  display: flex; flex-direction: column; gap: 3px; margin-top: 14px; padding: 12px 13px;
  border-radius: 11px; background: #eef6ff; border: 1px solid #b9d7f5; color: #1e4f7a;
  font-size: .8rem;
}
.pw-generation-status[hidden] { display: none; }
.pw-generation-status strong { font-size: .86rem; }
.pw-generation-status span { color: #356b98; }

.pw-paper.pw-paper-frame-card { padding: 0; overflow: hidden; background: #fff; }
.pw-paper-frame { display: block; width: 100%; height: min(72vh, 780px); border: 0; background: #fff; }
.pw-preview-loading, .pw-preview-error {
  min-height: min(72vh, 780px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 30px; text-align: center; color: var(--ps-muted);
}
.pw-preview-loading-icon {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--ps-green-soft); color: var(--ps-green); margin-bottom: 4px;
}
.pw-preview-loading-icon .icon { width: 28px; height: 28px; }
.pw-preview-loading strong, .pw-preview-error strong { color: var(--ps-ink); font-size: 1rem; }
.pw-preview-loading span, .pw-preview-error span { color: var(--ps-muted); font-size: .86rem; max-width: 440px; }
.pw-preview-error { color: var(--ps-danger); }
.pw-preview-error[hidden], .pw-preview-loading[hidden] { display: none; }
.pw-preview-note {
  display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 11px 12px;
  border-radius: 11px; background: #fff7e6; border: 1px solid #f3d38a; color: #7a5a10;
  font-size: .8rem; font-weight: 600;
}
.pw-preview-note[hidden] { display: none; }
.pw-preview-note .icon { width: 16px; height: 16px; flex: none; }

/* ── Sample modal ── */
.pw-sample-modal { width: min(640px, 100%); }
.pw-sample-paper { font-family: Georgia, "Times New Roman", serif; font-size: .82rem; }
.pw-sample-paper h2 { text-align: center; margin: 4px 0 2px; font-size: 1.3rem; }
.pw-sample-paper .pw-paper-subject { text-align: center; }
.pw-sample-paper .pw-paper-meta { border-top: 1px dashed #9ca3af; border-bottom: 1px dashed #9ca3af; padding: 7px 0; margin: 12px 0 0; }
.pw-sample-paper .pw-paper-section p { margin: 7px 0 0; }
.pw-paper-footer { text-align: center; margin-top: 20px; padding-top: 8px; border-top: 1px solid #ddd; color: #9ca3af; font-size: .7rem; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .pw-class-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pw-chapter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .pw-hero { grid-template-columns: 1fr; }
  .pw-sample-card { max-width: 560px; transform: none; }
  .pw-how-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pw-preview-layout { grid-template-columns: 1fr; }
  .pw-pattern-grid { grid-template-columns: 1fr; }
  .pw-meta-panel { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .pw-modal-backdrop { padding: 0; }
  .pw-wizard { width: 100%; height: 100vh; max-height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .pw-wizard-head { padding: 16px 16px 0; }
  .pw-wizard-body { padding: 18px 16px; }
  .pw-wizard-footer { padding: 12px 16px; }
  .pw-progress { margin-left: -16px; margin-right: -16px; }
  .pw-subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pw-option-grid { display: grid; grid-template-columns: 1fr 1fr; }
  .pw-or { display: none; }
  .pw-option-grid .pw-choice-card { min-height: 0; }
  .pw-chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .pw-landing { padding-top: 24px; }
  .pw-hero { padding-top: 8px; }
  .pw-hero-actions { align-items: stretch; }
  .pw-hero-actions .ps-button { width: 100%; }
  .pw-how-grid { grid-template-columns: 1fr; }
  .pw-class-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pw-subject-grid { grid-template-columns: 1fr; }
  .pw-option-grid { grid-template-columns: 1fr; }
  .pw-chapter-grid { grid-template-columns: 1fr; }
  .pw-wizard-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .pw-wizard-footer { align-items: stretch; flex-direction: column; gap: 10px; }
  .pw-footer-actions { width: 100%; }
  .pw-footer-actions .ps-button { flex: 1; }
  .pw-summary-bar { white-space: normal; }
  .pw-custom-head { display: none; }
  .pw-custom-row { grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 2px; }
  .pw-custom-row .pw-type-label { grid-column: 1 / -1; }
  .pw-custom-row .pw-row-total { text-align: left; }
  .pw-paper { padding: 20px 18px; }
  .pw-paper-frame, .pw-preview-loading, .pw-preview-error { height: 62vh; min-height: 62vh; }
  .pw-paper-lock { margin: 18px -18px -20px; padding: 13px 18px; }
}
