:root {
  --db-ink: #172033;
  --db-muted: #5e6b82;
  --db-line: #dce3ec;
  --db-panel: #ffffff;
  --db-soft: #f5f8fc;
  --db-blue: #1663d5;
  --db-cyan: #0891b2;
  --db-green: #0f8a65;
  --db-red: #c43b47;
  --db-amber: #b45309;
  --db-shadow: 0 18px 50px rgba(30, 52, 85, 0.1);
}

* { box-sizing: border-box; }

body.redundancy-page {
  min-height: 100vh;
  margin: 0;
  color: var(--db-ink);
  background: #f5f8fc;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { touch-action: manipulation; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.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; }

.learning-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 64px; }
.module-topbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.module-header { max-width: 800px; margin: 0 auto 28px; text-align: center; }
.module-header h1 { margin: 12px 0 10px; font-size: clamp(2.1rem, 5vw, 3.7rem); line-height: 1.05; letter-spacing: -0.045em; color: #123568; }
.module-header p { margin: 0; color: var(--db-muted); font-size: clamp(1rem, 2vw, 1.16rem); line-height: 1.65; }
.module-header .module-task-number { margin-bottom: 6px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid #abddea; border-radius: 999px; color: #0d6f8b; background: #eefbfe; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.075em; text-transform: uppercase; }

.data-status { display: flex; align-items: center; justify-content: center; gap: 12px; width: min(620px, 100%); margin: 48px auto; padding: 22px; border: 1px solid var(--db-line); border-radius: 16px; background: white; color: var(--db-muted); }
.data-status[hidden] { display: none; }
.data-status.error { color: #7f1d1d; border-color: #fecaca; background: #fff7f7; }
.status-spinner { width: 19px; height: 19px; border: 2px solid #b9d9e5; border-top-color: var(--db-cyan); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-card { position: sticky; top: 10px; z-index: 20; padding: 14px 18px; margin-bottom: 14px; border: 1px solid rgba(191, 205, 222, 0.9); border-radius: 15px; background: rgba(255, 255, 255, 0.92); box-shadow: 0 10px 32px rgba(30, 52, 85, 0.1); backdrop-filter: blur(12px); }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 9px; color: var(--db-muted); font-size: 0.85rem; }
.progress-copy strong { color: #214a7a; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e8edf4; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--db-cyan), var(--db-blue)); transition: width 0.35s ease; }

.step-tabs { display: grid; grid-template-columns: repeat(8, minmax(92px, 1fr)); gap: 8px; margin-bottom: 18px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.step-tab { min-width: 92px; min-height: 64px; padding: 9px 8px; border: 1px solid var(--db-line); border-radius: 12px; background: rgba(255,255,255,0.76); color: var(--db-muted); text-align: left; cursor: pointer; transition: 0.18s ease; }
.step-tab span { display: block; margin-bottom: 3px; color: #335372; font-weight: 800; font-size: 0.76rem; }
.step-tab small { display: block; line-height: 1.25; font-size: 0.72rem; }
.step-tab:hover, .step-tab:focus-visible { border-color: #76a7e5; background: white; transform: translateY(-1px); }
.step-tab[aria-selected="true"] { color: white; border-color: var(--db-blue); background: linear-gradient(135deg, #087d9c, #2458c7); box-shadow: 0 10px 22px rgba(24, 89, 177, 0.23); }
.step-tab[aria-selected="true"] span { color: white; }
.step-tab.is-complete span::after { content: " ✓"; color: var(--db-green); }
.step-tab[aria-selected="true"].is-complete span::after { color: #d8fff3; }
.step-tab[hidden] { display: none; }

.step-panel { min-height: 620px; padding: clamp(20px, 4vw, 42px); border: 1px solid var(--db-line); border-radius: 24px; background: var(--db-panel); box-shadow: var(--db-shadow); animation: panel-in 0.28s ease both; }
.step-panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }
.step-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.step-number { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 15px; background: linear-gradient(135deg, #0d89a8, #2458c7); color: white; font-size: 1.12rem; font-weight: 900; box-shadow: 0 9px 20px rgba(26, 96, 175, 0.22); }
.step-number.complete { background: var(--db-green); }
.step-kicker { margin: 0 0 2px; color: var(--db-cyan); font-weight: 800; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.step-heading h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 2rem); color: #15375f; letter-spacing: -0.025em; }

.scenario-card, .task-card, .short-summary { padding: 18px 20px; margin: 0 0 22px; border: 1px solid #dbe6f3; border-radius: 16px; background: #f6faff; }
.scenario-card.accent { border-left: 5px solid var(--db-cyan); }
.scenario-card p, .task-card p { margin: 0 0 8px; line-height: 1.55; }
.scenario-card p:last-child, .task-card p:last-child { margin-bottom: 0; }
.task-card { background: white; }
.task-card.prominent { max-width: 860px; margin-inline: auto; }
.task-card h3 { margin: 0 0 8px; color: #1b426f; font-size: 1.05rem; }
.task-card.locked { border-style: dashed; background: #f8fafd; }
.task-card.locked .choice-list, .task-card.locked .action-row { opacity: 0.55; }
.task-card.locked .choice-option { cursor: not-allowed; }
.task-card.locked .choice-option:hover { border-color: var(--db-line); background: #fbfcfe; }
.task-gate { display: flex; align-items: flex-start; gap: 8px; padding: 10px 13px; margin: 0 0 12px !important; border: 1px solid #f2bf72; border-radius: 12px; background: #fff8e8; color: #77410c; font-weight: 700; line-height: 1.45; }
.task-gate[hidden] { display: none; }

.table-shell { margin: 0 0 22px; border: 1px solid var(--db-line); border-radius: 16px; overflow: hidden; background: white; }
.table-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--db-line); background: #eef4fa; color: #315170; font-size: 0.82rem; }
.table-caption strong { font-family: "SFMono-Regular", Consolas, monospace; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 780px; table-layout: fixed; }
.data-table th, .data-table td { padding: 11px 12px; border-right: 1px solid #e7ecf2; border-bottom: 1px solid #e7ecf2; text-align: left; vertical-align: top; font-size: 0.82rem; line-height: 1.35; }
.data-table th:last-child, .data-table td:last-child { border-right: 0; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table th { background: #fafcff; color: #40556f; font-family: "SFMono-Regular", Consolas, monospace; font-weight: 800; }
.data-table .repeat-cell { background: #fff8df; }
.column-selector { width: 100%; padding: 8px; margin: -8px; border: 2px solid transparent; border-radius: 8px; background: transparent; color: inherit; font-family: inherit; font-weight: inherit; text-align: left; cursor: pointer; }
.column-selector[aria-pressed="true"] { border-color: #e69b21; background: #fff2c8; color: #7a4300; }
.description-cell { width: 30%; max-width: 310px; }
.truncate-text { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.url-cell { color: #356b9f; word-break: break-all; }
.email-input { width: 100%; min-width: 220px; padding: 9px 10px; border: 1px solid #b8c5d5; border-radius: 9px; background: white; color: var(--db-ink); }
.email-input.changed { border-color: #17936c; background: #edfff8; }
.email-input.conflict { border-color: #d97706; background: #fff8eb; box-shadow: 0 0 0 2px rgba(217,119,6,0.12); }
.row-status { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 999px; background: #eef2f6; color: #52647b; font-size: 0.7rem; font-weight: 800; }
.row-status.new { background: #e2faef; color: #0d7253; }
.row-status.conflict { background: #fff0da; color: #98510c; }

.aha-alert { padding: 15px 18px; margin: -7px 0 22px; border: 1px solid #f2bf72; border-radius: 14px; background: #fff8e8; color: #77410c; }
.aha-alert strong { display: block; margin-bottom: 4px; }
.concept-reveal[hidden], .split-visual[hidden] { display: none; }
.concept-reveal { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; padding: 22px; margin-top: 18px; border: 1px solid #bfdacb; border-radius: 18px; background: linear-gradient(135deg, #f1fff9, #f4f8ff); }
.concept-reveal > div:not(.concept-arrow) { padding: 14px; border-radius: 12px; background: white; }
.concept-reveal span { color: #126c55; font-weight: 900; font-size: 1.08rem; }
.concept-reveal p { margin: 4px 0 0; color: var(--db-muted); }
.concept-arrow { color: #4e7297; font-size: 1.5rem; font-weight: 900; }

.choice-list { display: grid; gap: 9px; margin: 15px 0; }
.choice-option { display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px; border: 1px solid var(--db-line); border-radius: 12px; background: #fbfcfe; cursor: pointer; transition: 0.16s ease; }
.choice-option:hover { border-color: #9cbde5; background: #f6faff; }
.choice-option:has(input:checked) { border-color: #4f8bd7; background: #eef6ff; }
.choice-option input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--db-blue); }
.choice-option span { line-height: 1.4; }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.primary-button, .secondary-button, .danger-button { min-height: 43px; padding: 10px 16px; border: 1px solid transparent; border-radius: 11px; font-weight: 800; cursor: pointer; transition: 0.16s ease; }
.primary-button { color: white; border-color: #1455b1; background: linear-gradient(135deg, #087f9e, #2459c6); box-shadow: 0 8px 18px rgba(28, 91, 176, 0.18); }
.primary-button:hover, .primary-button:focus-visible { filter: brightness(1.06); transform: translateY(-1px); }
.primary-button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.primary-button:disabled:hover { filter: none; transform: none; }
.secondary-button { color: #244d78; border-color: #b8c9dd; background: white; }
.secondary-button:hover, .secondary-button:focus-visible { border-color: #6e9bcf; background: #f5f9ff; }
.danger-button { color: #9d2632; border-color: #efb6bc; background: #fff7f8; }
.feedback { min-height: 1.4em; margin: 14px 0 0 !important; font-weight: 700; }
.feedback.success { color: #0c7455; }
.feedback.error { color: #ad2936; }
.feedback.hint { color: #9a5b0d; }
.short-summary { color: #245d4d; border-color: #bfe4d3; background: #f1fff8; }

.assignment-workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.attribute-zone { min-height: 190px; padding: 16px; border: 2px dashed #bdcad9; border-radius: 16px; background: #f9fbfd; }
.attribute-zone[data-zone="pool"] { grid-column: 1 / -1; min-height: 120px; }
.attribute-zone.drag-over { border-color: var(--db-cyan); background: #effcff; }
.attribute-zone h3 { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 12px; color: #294f77; }
.attribute-zone h3 small { color: var(--db-muted); font-weight: 500; }
.attribute-list, .attribute-bank { display: flex; flex-wrap: wrap; gap: 9px; }
.attribute-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 8px 11px; border: 1px solid #aec1d8; border-radius: 10px; background: white; color: #274966; font-family: "SFMono-Regular", Consolas, monospace; font-weight: 800; cursor: grab; box-shadow: 0 3px 8px rgba(37, 62, 91, 0.06); }
.attribute-chip::after { content: "↻"; color: #8295aa; font-family: sans-serif; font-size: 0.78rem; }
.attribute-chip:active { cursor: grabbing; }
.attribute-chip.selected { color: #0b6e53; border-color: #53b493; background: #edfff8; }
.split-visual { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 24px; padding: 24px; border-radius: 16px; background: #eefbf7; color: #17624f; animation: split-in 0.65s ease both; }
.split-visual span { padding: 12px 15px; border: 1px solid #b5dfd0; border-radius: 11px; background: white; }
@keyframes split-in { from { opacity: 0; transform: scale(0.96); } }

.class-card-layout { display: grid; grid-template-columns: minmax(190px, 0.7fr) minmax(300px, 1.5fr) minmax(190px, 0.7fr); align-items: start; gap: 22px; }
.class-card { overflow: hidden; border: 2px solid #526a84; border-radius: 0; background: white; box-shadow: 0 12px 24px rgba(31, 55, 84, 0.1); }
.class-card h3 { margin: 0; padding: 11px 14px; border-bottom: 2px solid #526a84; background: #edf3f9; text-align: center; font-family: "SFMono-Regular", Consolas, monospace; }
.class-card ul { list-style: none; padding: 0; margin: 0; }
.class-card li { padding: 9px 13px; border-bottom: 1px solid #dce3eb; font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.86rem; }
.class-card li:last-child { border-bottom: 0; }
.class-card .fixed-attribute { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #f2f6fa; color: #1f4568; font-weight: 800; }
.class-card .fixed-attribute span { color: #6b7c90; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.035em; text-transform: uppercase; }
.placeholder-row { color: #8a97a7; font-style: italic; }
.class-card-task { padding: 20px; border: 1px solid var(--db-line); border-radius: 16px; background: var(--db-soft); }
.class-card-task p { margin-top: 0; line-height: 1.5; }
.class-card-task .attribute-bank { margin: 16px 0; }

.relation-stage { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 26px; align-items: start; margin-bottom: 24px; }
.mini-table-card { position: relative; border: 1px solid var(--db-line); border-radius: 14px; overflow: hidden; background: white; }
.mini-table-card h3 { margin: 0; padding: 11px 14px; background: #edf3f9; color: #264f78; font-family: "SFMono-Regular", Consolas, monospace; }
.mini-table-card table { width: 100%; border-collapse: collapse; }
.mini-table-card th, .mini-table-card td { padding: 9px 10px; border-top: 1px solid #e3e8ef; text-align: left; font-size: 0.8rem; }
.mini-table-card th { color: #53667d; background: #fafcff; font-family: "SFMono-Regular", Consolas, monospace; }
.link-column { background: #fff5cf !important; color: #784c00 !important; font-weight: 900; }
.relation-reveal { padding: 22px; margin-top: 22px; border: 1px solid #9ed7c2; border-radius: 16px; background: #effdf8; text-align: center; }
.relation-reveal code { display: inline-block; padding: 8px 11px; border-radius: 9px; background: white; color: #126f56; font-weight: 900; }
.relation-reveal span { padding: 0 12px; color: #2e6988; font-size: 1.5rem; font-weight: 900; }
.relation-reveal p { margin: 12px 0 0; color: #315f51; }

.final-quiz { display: grid; gap: 17px; }
.final-quiz fieldset { min-width: 0; padding: 18px; border: 1px solid var(--db-line); border-radius: 16px; }
.final-quiz legend { padding: 0 8px; color: #1c4169; font-weight: 800; }
.final-quiz legend span { display: inline-grid; place-items: center; width: 27px; height: 27px; margin-right: 6px; border-radius: 50%; background: #e9f2fc; color: #1a5dab; }
.mini-assignment { display: grid; gap: 10px; margin-top: 14px; }
.mini-assignment-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(150px, 1fr); align-items: center; gap: 12px; }
.mini-assignment-row code { font-weight: 800; }
.mini-assignment-row select { width: 100%; padding: 9px 10px; border: 1px solid #b8c7d9; border-radius: 9px; background: white; color: var(--db-ink); }

.summary-panel { min-height: 0; }
.summary-intro { color: var(--db-muted); }
.answer-summary { display: grid; gap: 14px; margin-top: 22px; }
.summary-section { padding: 18px; border: 1px solid var(--db-line); border-radius: 15px; background: #fbfcfe; }
.summary-section h3 { margin: 0 0 5px; color: #1c4c7e; }
.summary-section .prompt { margin: 0 0 12px; color: var(--db-muted); font-size: 0.88rem; }
.summary-grid { display: grid; grid-template-columns: minmax(170px, 0.45fr) 1fr; gap: 7px 14px; margin: 0; }
.summary-grid dt { color: #52647a; font-weight: 700; }
.summary-grid dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.summary-result { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-weight: 800; font-size: 0.76rem; }
.summary-result.complete { color: #0b7053; background: #e1f8ef; }
.summary-result.open { color: #8a570e; background: #fff1d8; }
.summary-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 24px; }
.solution-download { margin-top: 26px; padding: 20px 22px; border: 1px solid var(--db-line); border-left: 5px solid var(--db-blue); border-radius: 8px; background: white; box-shadow: 0 2px 8px rgba(30, 52, 85, 0.06); }
.solution-download h2 { margin: 0; color: #174a80; font-size: 1.15rem; }
.solution-reveal { margin-top: 13px; }
.solution-reveal summary { width: fit-content; cursor: pointer; color: #174a80; font-weight: 800; }
.solution-reveal[open] summary { margin-bottom: 14px; }
.solution-code-form { display: grid; gap: 11px; max-width: 480px; }
.solution-code-form label { font-weight: 800; }
.solution-code-controls { display: flex; gap: 10px; }
.solution-code-controls input { min-width: 0; flex: 1 1 190px; padding: 11px 12px; border: 1px solid #b8c7d9; border-radius: 5px; color: var(--db-ink); letter-spacing: 0.08em; text-transform: uppercase; }
.solution-code-controls button { flex: 0 0 auto; }
.solution-code-message { min-height: 1.3rem; margin: 0; color: var(--db-muted); }
.solution-code-message.error { color: var(--db-red); }
.download-button { display: inline-flex; width: fit-content; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 5px; background: var(--db-blue); color: white; font-weight: 800; text-decoration: none; }
.download-button:hover, .download-button:focus-visible { background: #104da9; outline: 3px solid rgba(23, 99, 213, 0.25); outline-offset: 2px; }
.download-button[hidden] { display: none; }
.tab-flow-navigation { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--db-line); }
.tab-flow-button { flex: 1 1 260px; }
.tab-flow-button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.step-heading h2[tabindex="-1"]:focus,
.tab-panel > h2[tabindex="-1"]:focus {
  outline: 3px solid rgba(23, 99, 213, 0.35);
  outline-offset: 4px;
  border-radius: 4px;
}

button:focus-visible, input:focus-visible, select:focus-visible, [role="tab"]:focus-visible { outline: 3px solid rgba(23, 99, 213, 0.35); outline-offset: 2px; }

@media (max-width: 860px) {
  .learning-shell { width: min(100% - 20px, 1180px); }
  .progress-card { top: 6px; }
  .step-tabs { grid-template-columns: repeat(8, 104px); }
  .class-card-layout { grid-template-columns: 1fr 1fr; }
  .class-card-task { grid-column: 1 / -1; grid-row: 1; }
}

@media (max-width: 650px) {
  .module-topbar { align-items: stretch; }
  .module-topbar .back-link { flex: 1; justify-content: center; text-align: center; }
  .step-panel { padding: 20px 15px; border-radius: 18px; }
  .progress-copy { font-size: 0.76rem; }
  .concept-reveal, .assignment-workspace, .class-card-layout, .relation-stage { grid-template-columns: 1fr; }
  .concept-arrow { transform: rotate(90deg); text-align: center; }
  .attribute-zone[data-zone="pool"] { grid-column: auto; }
  .class-card-task { grid-column: auto; grid-row: auto; }
  .mini-assignment-row, .summary-grid { grid-template-columns: 1fr; }
  .solution-code-controls { align-items: stretch; flex-direction: column; }
  .summary-grid dt { margin-top: 5px; }
  .tab-flow-button { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  body.redundancy-page { background: white; }
  .site-backdrop, .module-topbar, .module-header, .progress-card, .step-tabs, .tab-flow-navigation, .summary-actions, .solution-download, #data-status { display: none !important; }
  .learning-shell { width: 100%; padding: 0; }
  .step-panel { display: none !important; box-shadow: none; border: 0; padding: 0; }
  #step-summary { display: block !important; }
  .summary-section { break-inside: avoid; }
}
