:root {
  --bg: #f7f8f2;
  --surface: #ffffff;
  --surface-soft: #f3f6f8;
  --ink: #10222e;
  --muted: #4d6577;
  --border: #d6e1e7;
  --brand: #0f5f8c;
  --brand-2: #168f8b;
  --accent: #f29f05;
  --accent-soft: #fff4d9;
  --shadow-lg: 0 24px 60px rgba(13, 42, 62, 0.16);
  --shadow-md: 0 10px 26px rgba(13, 42, 62, 0.09);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 7% 8%, #fbe4b2 0%, transparent 22%),
    radial-gradient(circle at 90% 3%, #b4d8e2 0%, transparent 25%),
    linear-gradient(180deg, #f6f3e8 0%, #f3f6f8 48%, #eef3f6 100%);
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.01em;
}

.app-header {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 2.2rem 2rem 1.5rem;
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, #08415f 0%, #0f5f8c 45%, #168f8b 100%);
  border-bottom: 3px solid rgba(255, 255, 255, 0.18);
  z-index: -2;
}

.app-header::after {
  content: "";
  position: absolute;
  width: 480px;
  height: 480px;
  right: -140px;
  top: -320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  z-index: -1;
}

.hero {
  width: 100%;
  max-width: none;
  margin: 0;
  color: #f7fbff;
  animation: rise-in 480ms ease-out both;
}

.hero-logo {
  height: 36px;
  width: auto;
  display: block;
  margin-bottom: 0.75rem;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(2rem, 3.2vw, 2.85rem);
  line-height: 1.04;
}

.hero-copy {
  margin: 0;
  max-width: none;
  color: #d8edf7;
  font-size: 1.03rem;
}

.hero-tags {
  margin-top: 0.95rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-tags span {
  display: inline-block;
  padding: 0.25rem 0.62rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.17);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 0.78rem;
  color: #ecf8ff;
}

.hero-how {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-step {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  color: #d8edf7;
}

.hero-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1000;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 1rem;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.15rem 2rem 1.5rem;
}

.site-nav {
  width: 100%;
  background: #0b3a54;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0;
  padding: 0 2rem;
  max-width: none;
}

.site-nav-link {
  display: inline-block;
  padding: 0.52rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #a8cfe0;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}

.site-nav-link:hover {
  color: #f0f8ff;
}

.site-nav-link--active {
  color: #f0f8ff;
  border-bottom-color: var(--accent);
}

.metrics {
  width: 100%;
  max-width: none;
  margin: 0.5rem 0 0.5rem;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.metric-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #c9dbe6;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  box-shadow: none;
}

.metric-label {
  margin: 0;
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4d697a;
}

.metric-value {
  margin: 0.1rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0d4e74;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(251, 253, 255, 0.98));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: none;
  animation: rise-in 420ms ease-out both;
}

.panel:nth-child(2) {
  animation-delay: 80ms;
}

.panel:nth-child(3) {
  animation-delay: 150ms;
}

.panel-wide {
  min-width: 0;
}

h2 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
  color: #083b59;
}

h3 {
  margin: 1.15rem 0 0.6rem;
  font-size: 0.96rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1f617e;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #2d4d61;
}

#topic-search,
#class-size,
.duration-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.52rem 0.62rem;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}

#topic-search {
  margin-bottom: 0.8rem;
}

#topic-search:focus,
#class-size:focus,
.duration-select:focus,
button:focus {
  outline: 2px solid rgba(15, 95, 140, 0.25);
  outline-offset: 2px;
}

.topics-tree details {
  margin-bottom: 0.4rem;
  padding: 0.2rem 0.15rem;
  border-radius: 8px;
}

.topics-tree summary {
  cursor: pointer;
  font-weight: 700;
  color: #174e6a;
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.26rem 0;
  padding: 0.25rem 0.3rem;
  border-radius: 8px;
}

.topic-row:hover {
  background: #edf6fb;
}

.help {
  margin: 0 0 0.65rem;
  font-size: 0.87rem;
  color: var(--muted);
}

.lesson-list {
  list-style: none;
  padding: 0;
  margin: 0;
  min-height: 220px;
}

.remove-btn {
  background: none;
  border: none;
  box-shadow: none;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
  transition: color 120ms ease;
}

.remove-btn:hover {
  color: #dc2626;
  transform: none;
  box-shadow: none;
  filter: none;
}

.lesson-item {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.45rem;
  border: 1px solid #d6e0e8;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(17, 44, 66, 0.04);
}

.lesson-item.dragging {
  opacity: 0.55;
}

.drag-handle {
  color: #3d6982;
  cursor: grab;
  font-weight: 700;
}

.controls {
  display: flex;
  gap: 0.6rem;
  align-items: end;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.controls label {
  min-width: 110px;
}

#class-size {
  width: 130px;
}

button {
  border: none;
  border-radius: 11px;
  padding: 0.57rem 0.84rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: #f5fbff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 16px rgba(8, 65, 95, 0.2);
  transition: transform 120ms ease, box-shadow 150ms ease, filter 150ms ease;
}

#clear-btn {
  background: linear-gradient(135deg, #556978, #344855);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(8, 65, 95, 0.25);
  filter: saturate(1.05);
}

button:active {
  transform: translateY(0);
}

#print-btn:disabled {
  cursor: not-allowed;
  color: #dce8f0;
  background: linear-gradient(135deg, #7f95a4, #677c89);
  box-shadow: none;
  filter: grayscale(0.15);
}

#print-btn:disabled:hover {
  transform: none;
  box-shadow: none;
  filter: grayscale(0.15);
}

#generate-btn.needs-attention {
  animation: generate-attention 620ms ease-in-out 2;
}

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

.sow-cover {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
  background: linear-gradient(160deg, #f0f7fc, #e8f3f9);
}

.cover-logo-row {
  margin-bottom: 0.75rem;
}

.cover-logo {
  height: 32px;
  width: auto;
  filter: invert(1) sepia(1) saturate(3) hue-rotate(175deg) brightness(0.4);
}

.cover-title {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.6rem;
  color: #083b59;
  margin: 0 0 0.15rem;
}

.cover-subject {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 0.9rem;
}

.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.cover-meta-item {
  background: #fff;
  border: 1px solid #cddde8;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  display: flex;
  flex-direction: column;
  min-width: 80px;
}

.cover-meta-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.cover-meta-value {
  font-size: 1rem;
  font-weight: 700;
  color: #0d4e74;
}

.cover-about {
  font-size: 0.9rem;
  color: #2d4d61;
  border-top: 1px solid #ccdde8;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.cover-about h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1f617e;
  margin: 0 0 0.4rem;
}

.cover-about p {
  margin: 0 0 0.4rem;
  line-height: 1.55;
}

.cover-footer {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid #cddde8;
  padding-top: 0.5rem;
}

.lesson-packs {
  display: grid;
  gap: 0.7rem;
}

.lesson-card {
  border: 1px solid #d4e0e8;
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  background:
    linear-gradient(180deg, #ffffff, #f8fbfd);
}

.block-list {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
}

.block-list li {
  border-top: 1px dashed #dde7ee;
  padding: 0.45rem 0;
}

.block-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.block-print-content {
  display: none;
}

.asset-viewer {
  border: 1px solid #d3dfe8;
  background: linear-gradient(180deg, #fefefe, #f6fafc);
  border-radius: 12px;
  min-height: 240px;
  padding: 0.85rem;
}

.content-render {
  border: 1px solid #dce7ef;
  border-radius: 10px;
  background: #fff;
  padding: 0.78rem;
  font-size: 0.95rem;
}

.content-render ul {
  margin: 0.4rem 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #d4e0e8;
  font-size: 0.9rem;
}

#hardware-summary {
  max-width: 100%;
}

#hardware-summary .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 12px;
}

#hardware-summary table {
  min-width: 920px;
}

th,
td {
  border-bottom: 1px solid #e3edf3;
  padding: 0.5rem 0.45rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

#hardware-summary th,
#hardware-summary td {
  white-space: normal;
}

#hardware-summary td:nth-child(6) {
  min-width: 150px;
}

.hardware-own-input {
  width: 100%;
  min-width: 120px;
  max-width: 160px;
}

th {
  background: linear-gradient(180deg, #e8f3f9, #ddeef7);
  color: #124764;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr:hover {
  background: #f1f8fc;
}

.to-buy {
  font-weight: 700;
  color: #235d24;
}

.hardware-image-cell {
  width: 92px;
}

.hardware-image {
  width: 72px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #d7e3eb;
  background: #fff;
}

.lesson-image-item {
  border-top: 1px dashed #dde7ee;
  padding: 0.6rem 0;
}

.lesson-image-lesson {
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 1px solid #d3dfe8;
  object-fit: contain;
}

.lesson-images-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed #dde7ee;
}

.lesson-worksheet-img {
  max-width: calc(50% - 0.25rem);
  max-height: 220px;
  width: auto;
  height: auto;
  border-radius: 6px;
  border: 1px solid #d3dfe8;
  object-fit: contain;
  background: #f8fbfd;
}

.lesson-image-viewer-wrap {
  margin-top: 0.75rem;
}

.lesson-image-viewer {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 1px solid #d3dfe8;
  object-fit: contain;
}

.lecturer-checks .lesson-card {
  margin-bottom: 0.65rem;
}

.teacher-check-list {
  margin: 0.55rem 0 0;
  padding-left: 1.1rem;
}

.teacher-check-list li {
  margin-bottom: 0.3rem;
}

.muted {
  color: var(--muted);
}

@keyframes rise-in {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes generate-attention {
  0% {
    transform: translateY(0);
    box-shadow: 0 8px 16px rgba(8, 65, 95, 0.2);
  }
  50% {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 0 0 4px rgba(242, 159, 5, 0.22), 0 12px 24px rgba(8, 65, 95, 0.24);
  }
  100% {
    transform: translateY(0);
    box-shadow: 0 8px 16px rgba(8, 65, 95, 0.2);
  }
}

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

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

@media (max-width: 640px) {
  .app-header {
    padding: 1.6rem 1rem 1.15rem;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .hero-copy {
    font-size: 0.95rem;
  }

  .panel {
    border-radius: 14px;
    padding: 0.85rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  #class-size {
    width: 100%;
  }

  .metrics {
    grid-template-columns: 1fr;
    padding: 0 1rem;
  }

  .site-nav {
    padding: 0 1rem;
  }

  .layout {
    padding: 1rem;
  }
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #0c4869;
  color: #f2f8fc;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 0.56rem 0.74rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease;
  z-index: 1200;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media print {
  .app-header,
  .site-nav,
  .panel:first-child,
  .panel:nth-child(2),
  .metrics,
  .output-actions,
  .asset-viewer,
  .toast,
  button,
  h2,
  h3:not(.cover-about h2) {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-family: Georgia, "Times New Roman", serif;
  }

  .layout {
    display: block;
    padding: 0;
    max-width: none;
  }

  .panel {
    border: none;
    box-shadow: none;
    background: #fff;
    padding: 0;
    animation: none;
  }

  .viewer-heading,
  .asset-viewer,
  .hero-logo {
    display: none !important;
  }

  .sow-cover {
    border: none;
    border-radius: 0;
    background: #fff;
    padding: 3rem 2.5rem;
    page-break-after: always;
    display: flex;
    flex-direction: column;
    min-height: 90vh;
  }

  .cover-logo {
    filter: none;
    height: 44px;
  }

  .cover-title {
    font-size: 2.4rem;
    margin-top: 2rem;
  }

  .cover-subject {
    font-size: 1.15rem;
    margin-bottom: 1.5rem;
  }

  .cover-meta {
    gap: 1rem;
    margin-bottom: 2rem;
  }

  .cover-meta-item {
    min-width: 110px;
    padding: 0.5rem 0.9rem;
  }

  .cover-about {
    font-size: 0.95rem;
    max-width: 600px;
  }

  .cover-footer {
    margin-top: auto;
    padding-top: 1rem;
  }

  .student-lesson-card {
    page-break-before: always;
  }

  .lecturer-checks-section {
    page-break-before: always;
  }

  .lecturer-checks-section > .muted {
    display: none !important;
  }

  .lecturer-card {
    page-break-before: auto !important;
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 0.35rem;
  }

  #sow-summary {
    page-break-before: always;
    break-before: page;
  }

  #sow-summary,
  #hardware-summary {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .block-print-content {
    display: block !important;
    margin-top: 0.3rem;
    font-size: 0.88rem;
    color: #000;
  }

  .lesson-image-item {
    display: block !important;
  }

  .lesson-image-lesson {
    max-height: 200px;
  }

  .lesson-images-gallery {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #bbb;
    break-inside: avoid;
  }

  .lesson-worksheet-img {
    max-width: calc(50% - 0.2rem);
    max-height: 180px;
    border-radius: 4px;
    object-fit: contain;
  }

  .block-item-header button {
    display: none !important;
  }

  #hardware-summary .table-wrap {
    overflow: visible !important;
  }

  #hardware-summary table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed;
  }

  #hardware-summary th,
  #hardware-summary td {
    font-size: 0.72rem;
    padding: 0.25rem 0.2rem;
    word-break: break-word;
  }

  #hardware-summary th:nth-child(6),
  #hardware-summary td:nth-child(6) {
    display: none;
  }

  #hardware-summary .hardware-image {
    width: 44px;
    height: 32px;
    border-radius: 4px;
  }

  table,
  th,
  td {
    border-color: #bbb;
  }
}
