:root {
  --navy: #14285a;
  --blue: #29419c;
  --blue-2: #3658c9;
  --blue-soft: #edf1ff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9dfeb;
  --paper: #ffffff;
  --canvas: #f4f6fb;
  --success: #18794e;
  --success-soft: #eaf7f0;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #98600c;
  --shadow: 0 18px 45px rgba(20, 40, 90, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -10%, rgba(54, 88, 201, .15), transparent 28rem),
    var(--canvas);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.site-header {
  min-height: 210px;
  padding: 42px max(5vw, 28px);
  color: #fff;
  background:
    linear-gradient(115deg, rgba(10, 25, 68, .96), rgba(41, 65, 156, .93)),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(255,255,255,.03) 18px 19px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
}

.brand-mark {
  width: 84px;
  height: 84px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.08);
}

.eyebrow, .kicker {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 11px;
  font-weight: 800;
}

.eyebrow { color: #cfd9ff; }
.site-header h1 { margin: 0; font-size: clamp(28px, 4vw, 46px); line-height: 1.1; letter-spacing: -.03em; }
.lede { margin: 10px 0 0; color: #e3e9ff; max-width: 720px; font-size: 16px; }

.header-badge {
  padding: 12px 15px;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  text-align: right;
}
.header-badge span { font-size: 11px; color: #cfd9ff; text-transform: uppercase; letter-spacing: .1em; }
.header-badge strong { font-size: 14px; }

.app-shell {
  width: min(1460px, calc(100% - 40px));
  margin: -28px auto 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.workflow { display: grid; gap: 20px; }
.panel {
  background: var(--paper);
  border: 1px solid rgba(20, 40, 90, .1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.panel-heading h2 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.015em; }
.kicker { color: var(--blue); }
.step-number {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 10px;
  font-weight: 800;
}

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; }
.field-wide { grid-column: span 2; }
.field > span { color: #344054; font-size: 13px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd6e4;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(54,88,201,.12); }
.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(180,35,24,.08) !important; }

.drop-zone {
  min-height: 155px;
  border: 1.5px dashed #aeb9d5;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfcff, #f6f8ff);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  text-align: center;
  padding: 24px;
  transition: border-color .15s, background .15s, transform .15s;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--blue); background: var(--blue-soft); transform: translateY(-1px); }
.drop-zone.disabled { cursor: not-allowed; opacity: .62; background: #f5f6f8; transform: none; }
.drop-zone.disabled:hover { border-color: #aeb9d5; background: #f5f6f8; }
.upload-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--blue); background: #fff; box-shadow: 0 6px 16px rgba(41,65,156,.12); font-size: 22px; }
.drop-zone small { color: var(--muted); }
.status-line { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.status-line.neutral { color: var(--muted); background: #f7f8fa; }
.status-line.success { color: var(--success); background: var(--success-soft); }
.status-line.error { color: var(--danger); background: var(--danger-soft); }

.lesson-heading { align-items: flex-start; }
.lesson-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.planning-bar { margin: -4px 0 18px; padding: 14px 16px; border: 1px solid #cdd6f0; border-radius: 13px; background: var(--blue-soft); display: grid; grid-template-columns: minmax(210px, 280px) 1fr; gap: 20px; align-items: end; }
.planning-bar p { margin: 0 0 3px; color: #4b5877; font-size: 12px; }
.lesson-configs { display: grid; gap: 14px; }
.lesson-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lesson-card-header { padding: 13px 16px; background: #f8f9fd; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.lesson-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.lesson-title b { color: var(--blue); }
.lesson-title input { min-width: 460px; max-width: 100%; padding: 8px 10px; font-weight: 750; }
.lesson-stats { display: flex; gap: 8px; color: var(--muted); font-size: 12px; }
.lesson-stats span { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.lesson-stats .variance { color: var(--warning); border-color: #e4bd72; background: #fff8e8; }
.remove-lesson { border: 0; color: var(--danger); background: transparent; padding: 5px 7px; font-size: 12px; font-weight: 800; }
.lesson-card-body { padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 14px; align-items: start; }
.lesson-card .hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.validation-panel { position: static; }
.compact-heading { margin-bottom: 18px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.metric-grid > div { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfe; }
.metric-grid span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.metric-grid strong { display: block; margin-top: 3px; font-size: 21px; }
.validation-panel h3 { margin: 22px 0 10px; font-size: 13px; }
.domain-list { display: grid; gap: 7px; }
.domain-row { display: grid; grid-template-columns: 100px 1fr 24px; align-items: center; gap: 8px; font-size: 12px; }
.domain-bar { height: 7px; border-radius: 999px; background: #e9edf5; overflow: hidden; }
.domain-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #6d87e7); }
.validation-summary { margin-top: 20px; padding: 11px 12px; border-radius: 10px; font-weight: 750; font-size: 13px; }
.validation-summary.waiting { background: #f4f5f7; color: var(--muted); }
.validation-summary.pass { background: var(--success-soft); color: var(--success); }
.validation-summary.fail { background: var(--danger-soft); color: var(--danger); }
.validation-messages { margin: 10px 0 0; padding-left: 20px; max-height: 245px; overflow: auto; color: var(--danger); font-size: 12px; }
.validation-messages:empty { display: none; }

.preview-panel { grid-column: 1 / -1; min-height: 420px; }
.preview-heading { align-items: flex-start; }
.preview-note { margin-left: auto; color: var(--muted); font-size: 12px; max-width: 320px; text-align: right; }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); }
.tab { border: 0; color: var(--muted); background: transparent; padding: 10px 14px; font-weight: 750; border-bottom: 2px solid transparent; }
.tab.active { color: var(--blue); border-color: var(--blue); }
.preview-content { padding-top: 20px; overflow: auto; }
.document-preview { width: min(820px, 100%); margin: 0 auto; padding: 38px 46px 50px; border: 1px solid #e1e4eb; background: #fff; box-shadow: 0 12px 32px rgba(23,32,51,.09); font-family: "Arial Narrow", Arial, sans-serif; }
.document-preview .institution { text-align: center; }
.document-preview .institution h3 { margin: 0; color: var(--blue); font: 700 28px Georgia, serif; }
.document-preview .institution p { margin: 2px 0; }
.document-preview .subject { margin-top: 14px; font: 800 18px Arial, sans-serif; }
.document-preview .term { color: var(--blue); font: 800 18px Arial, sans-serif; }
.directions { margin: 20px 0; text-align: justify; }
.preview-question { margin: 15px 0; }
.preview-question > strong { display: block; margin-bottom: 2px; }
.preview-choice { margin-left: 22px; }
.preview-choice.correct { color: #ee0000; }
.tos-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.tos-preview { min-width: 1100px; width: 100%; border-collapse: collapse; font: 12px Arial, sans-serif; }
.tos-preview caption { padding: 18px; font-size: 18px; font-weight: 800; }
.tos-preview th, .tos-preview td { border: 1px solid #5f6570; padding: 7px; text-align: center; vertical-align: middle; }
.tos-preview thead tr:first-child th { color: #fff; background: var(--blue); }
.tos-preview thead tr:nth-child(2) th { background: #e9edf8; }
.tos-preview td:first-child, .tos-preview td:nth-child(2) { text-align: left; }
.tos-preview tfoot td { font-weight: 800; }
.key-preview { columns: 3 210px; column-gap: 28px; }
.key-entry { break-inside: avoid; margin: 0 0 7px; }

.empty-state { padding: 36px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); background: #fafbfc; text-align: center; }
.button { border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; font-weight: 800; transition: transform .12s, box-shadow .12s, opacity .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(20,40,90,.14); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button.primary { color: #fff; background: var(--blue); }
.button.secondary { color: var(--blue); border-color: #b9c4e5; background: #fff; }
.button.compact { padding: 7px 10px; font-size: 12px; }
.action-bar { grid-column: 1 / -1; padding: 20px 24px; border-radius: var(--radius); color: #fff; background: var(--navy); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.action-bar .kicker { color: #b9c8ff; }
.action-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.action-bar .button.secondary { color: #fff; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.08); }
.action-bar .button.primary { color: var(--navy); background: #fff; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: 380px; padding: 12px 16px; border-radius: 11px; color: #fff; background: var(--ink); box-shadow: 0 15px 35px rgba(0,0,0,.2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 1fr; }
  .validation-panel { position: static; }
  .preview-panel, .action-bar { grid-column: auto; }
}

@media (max-width: 760px) {
  .site-header { grid-template-columns: auto 1fr; padding: 30px 20px 48px; }
  .header-badge { display: none; }
  .brand-mark { width: 58px; height: 58px; }
  .app-shell { width: min(100% - 24px, 1460px); }
  .panel { padding: 18px; border-radius: 14px; }
  .form-grid, .lesson-card-body { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .lesson-heading, .preview-heading, .action-bar { align-items: stretch; flex-direction: column; }
  .lesson-actions, .preview-note { margin-left: 47px; text-align: left; }
  .planning-bar { grid-template-columns: 1fr; }
  .lesson-card-header { align-items: flex-start; flex-direction: column; }
  .lesson-title { width: 100%; }
  .lesson-stats { flex-wrap: wrap; }
  .action-buttons { justify-content: stretch; }
  .action-buttons .button { flex: 1 1 210px; }
  .document-preview { padding: 26px 22px 34px; }
  .key-preview { columns: 1; }
}
