:root {
  --bg: #f1fbfa;
  --surface: #ffffff;
  --surface-soft: #ecf6f5;
  --surface-section: #e6e6fa;
  --patient: #fffde7;
  --teal: #006767;
  --teal-2: #008b8b;
  --ink: #141d1d;
  --muted: #516162;
  --line: #bcc9c8;
  --line-soft: #d8e5e4;
  --danger: #ba1a1a;
  --warning: #ef6c00;
  --blue: #1976d2;
  --green: #2e7d32;
  --shadow: 0 14px 30px rgba(0, 48, 48, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(0, 139, 139, 0.08), rgba(241, 251, 250, 0) 340px),
    var(--bg);
  font-family: "Noto Sans Thai", Inter, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 24px;
  color: #fff;
  background: var(--teal-2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 3px 12px rgba(0, 48, 48, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--teal);
  background: #fff;
  border-radius: 6px;
  font-family: Inter, sans-serif;
  font-size: 14px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.82);
  font-family: Inter, "Noto Sans Thai", sans-serif;
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.top-actions a {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}

.top-actions a:hover {
  background: rgba(255, 255, 255, 0.18);
}

.layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  width: min(100%, 1920px);
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 64px;
  align-self: start;
  height: calc(100vh - 64px);
  padding: 18px 14px 18px 18px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.52);
  border-right: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.sidebar-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-header strong {
  color: var(--teal);
  font-size: 12px;
}

.section-nav {
  display: grid;
  gap: 6px;
}

.section-nav a {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}

.section-nav a:hover,
.section-nav a:focus-visible {
  color: var(--teal);
  background: #fff;
  border-color: var(--line-soft);
}

.section-nav .nav-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 5px;
  font-family: Inter, sans-serif;
  font-size: 11px;
}

.content {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 48px) 60px;
}

.cover {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.cover-copy,
.cover-panel,
.toolbar,
.file-alert,
.module-section,
.slide-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.cover-copy {
  padding: clamp(24px, 4vw, 48px);
}

.eyebrow,
.panel-label,
.module-kicker,
.slide-number,
.image-state {
  color: var(--teal);
  font-family: Inter, "Noto Sans Thai", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.cover h1 {
  max-width: 980px;
  margin-top: 8px;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1.08;
}

.cover p {
  max-width: 920px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.4vw, 20px);
  line-height: 1.75;
}

.cover-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.cover-stats span {
  display: inline-flex;
  gap: 7px;
  align-items: baseline;
  padding: 10px 13px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
}

.cover-stats strong {
  color: var(--teal);
  font-family: Inter, sans-serif;
  font-size: 24px;
}

.cover-panel {
  position: relative;
  display: grid;
  align-items: center;
  min-height: 310px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 253, 231, 0.92), rgba(255, 255, 255, 0.92)),
    var(--patient);
  overflow: hidden;
}

.preview-card {
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 14px 28px rgba(0, 48, 48, 0.14);
  overflow: hidden;
}

.preview-card img {
  display: block;
  width: 100%;
  height: auto;
}

.preview-card figcaption {
  padding: 9px 11px;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 800;
}

.preview-primary {
  width: 86%;
  justify-self: end;
}

.preview-secondary {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 58%;
}

.toolbar {
  position: sticky;
  top: 76px;
  z-index: 20;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
  padding: 14px;
}

.search-field {
  display: grid;
  flex: 1;
  gap: 6px;
}

.search-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search-field input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.search-field input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 103, 103, 0.14);
}

.display-controls {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
}

.display-controls button {
  min-height: 34px;
  padding: 6px 12px;
  color: var(--muted);
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.display-controls button.is-active {
  color: #fff;
  background: var(--teal);
}

.file-alert {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
  padding: 18px 20px;
  background:
    linear-gradient(90deg, rgba(255, 253, 231, 0.96), rgba(255, 255, 255, 0.96)),
    var(--patient);
  border-color: rgba(239, 108, 0, 0.28);
  scroll-margin-top: 150px;
}

.file-alert h2 {
  margin-top: 6px;
  font-size: clamp(18px, 1.6vw, 24px);
}

.file-alert p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.file-alert ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-alert li {
  padding: 9px 10px;
  color: var(--danger);
  background: #fff;
  border: 1px solid rgba(186, 26, 26, 0.18);
  border-radius: 6px;
  font-family: Inter, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.module-container {
  display: grid;
  gap: 22px;
}

.module-section {
  scroll-margin-top: 150px;
  overflow: clip;
}

.module-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 22px 24px;
  background: linear-gradient(90deg, var(--surface-section), #fff);
  border-bottom: 1px solid var(--line-soft);
}

.module-title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
}

.module-index {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 6px;
  font-family: Inter, sans-serif;
  font-size: 14px;
  font-weight: 800;
}

.module-title h2 {
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.2;
}

.module-header p {
  max-width: 940px;
  margin: 10px 0 0 50px;
  color: var(--muted);
  line-height: 1.7;
}

.module-count {
  justify-self: end;
  padding: 8px 10px;
  color: var(--teal);
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-family: Inter, "Noto Sans Thai", sans-serif;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.slide-list {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.slide-card {
  scroll-margin-top: 160px;
  overflow: hidden;
  box-shadow: none;
}

.slide-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.slide-number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 6px;
}

.slide-heading h3 {
  font-size: clamp(18px, 1.7vw, 24px);
  line-height: 1.28;
}

.slide-heading p {
  max-width: 980px;
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.slide-path {
  max-width: 380px;
  padding: 7px 9px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-family: Inter, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.screen-frame {
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(236, 246, 245, 0.85), rgba(255, 255, 255, 0.92)),
    var(--surface-soft);
}

.screen-media {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 380px;
  overflow: auto;
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.screen-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 900px;
  object-fit: contain;
  cursor: zoom-in;
}

body.view-large .screen-media img {
  max-height: none;
}

body.view-large .content {
  padding-inline: clamp(14px, 2vw, 28px);
}

.screen-placeholder {
  display: grid;
  gap: 12px;
  width: min(100%, 760px);
  min-height: 340px;
  place-content: center;
  padding: 34px;
  text-align: center;
  background: repeating-linear-gradient(
    -45deg,
    #fff,
    #fff 14px,
    #fff6f3 14px,
    #fff6f3 28px
  );
  border: 1px dashed rgba(186, 26, 26, 0.45);
  border-radius: 6px;
}

.screen-placeholder strong {
  color: var(--danger);
  font-size: 22px;
}

.screen-placeholder span {
  color: var(--muted);
  line-height: 1.55;
}

.image-state {
  color: var(--warning);
}

.is-hidden {
  display: none !important;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 72px 24px 28px;
  background: rgba(10, 22, 22, 0.86);
}

.lightbox.is-open {
  display: grid;
}

.lightbox figure {
  display: grid;
  gap: 10px;
  width: min(100%, 1680px);
  max-height: calc(100vh - 120px);
  margin: 0;
}

.lightbox img {
  width: 100%;
  max-height: calc(100vh - 170px);
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
}

.lightbox figcaption {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  min-height: 40px;
  padding: 8px 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    flex-wrap: wrap;
    gap: 12px;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .section-nav {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .cover {
    grid-template-columns: 1fr;
  }

  .toolbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .display-controls {
    width: 100%;
  }

  .display-controls button {
    flex: 1;
  }

  .file-alert,
  .module-header,
  .slide-header {
    grid-template-columns: 1fr;
  }

  .module-header p {
    margin-left: 0;
  }

  .module-count {
    justify-self: start;
  }

  .slide-path {
    max-width: none;
  }

  .screen-media {
    min-height: 260px;
  }
}

@media (max-width: 640px) {
  .top-actions {
    width: 100%;
    overflow-x: auto;
  }

  .content {
    padding: 18px 12px 40px;
  }

  .cover-copy,
  .cover-panel,
  .module-header,
  .slide-list,
  .slide-header {
    padding: 16px;
  }

  .cover h1 {
    font-size: 31px;
  }

  .cover-stats span {
    width: 100%;
    justify-content: space-between;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toolbar,
  .lightbox {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .layout,
  .content {
    display: block;
    width: 100%;
    padding: 0;
  }

  .cover,
  .module-section,
  .slide-card {
    break-inside: avoid;
    box-shadow: none;
  }

  .screen-media {
    overflow: hidden;
  }
}
