
:root {
  --bg: #f3f7f8;
  --surface: #ffffff;
  --text: #17303b;
  --muted: #667780;
  --teal: #1f7898;
  --teal-dark: #15566d;
  --teal-soft: #e8f4f7;
  --line: #d9e4e8;
  --shadow: 0 14px 36px rgba(18, 50, 62, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--text); text-decoration: none; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.nav { display: flex; gap: 10px; }
.nav-link { border: 0; background: transparent; color: var(--text); padding: 10px 12px; border-radius: 10px; }
.nav-accent { background: var(--teal); color: white; }
.main-area { min-height: calc(100vh - 140px); padding: 72px 0; }
.view { display: none; }
.view.active { display: block; }
.hero {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 64px;
  align-items: center;
  padding: 72px 0;
}
.hero h1 {
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
  margin: 12px 0 20px;
  max-width: 780px;
}
.hero-copy { max-width: 660px; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.eyebrow {
  color: var(--teal);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .76rem;
}
.light-eyebrow { color: #bfe7f2; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-card { max-width: 430px; justify-self: end; width: 100%; }
.narrow { width: min(760px, 100%); margin: 0 auto; }
.centered { text-align: center; }
h1, h2, h3 { letter-spacing: -0.03em; }
h2 { font-size: 2rem; margin: 8px 0 12px; }
h3 { margin-top: 0; }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 16px; }
input, textarea {
  display: block; width: 100%; margin-top: 7px; border: 1px solid var(--line);
  border-radius: 12px; background: #fbfdfe; padding: 13px 14px; outline: none;
}
input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(31,120,152,.12); }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.primary-btn, .secondary-btn, .danger-btn, .text-btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700;
}
.primary-btn { background: var(--teal); color: white; }
.primary-btn:hover { background: var(--teal-dark); }
.secondary-btn { background: #e6eef1; color: var(--text); }
.danger-btn { background: #f6e6e3; color: #9d3025; }
.text-btn { background: transparent; color: var(--teal-dark); padding-left: 0; }
.inline-link { border: 0; background: transparent; color: var(--teal-dark); font-weight: 700; padding: 0; }
.small-copy, .muted { color: var(--muted); line-height: 1.6; }
.message { margin-top: 16px; font-size: .93rem; line-height: 1.5; }
.message.error { color: #a72a2a; }
.message.success { color: #2f6b43; }
.status-icon { font-size: 2rem; margin-bottom: 12px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.hidden { display: none !important; }

.library-hero, .topic-hero {
  background: linear-gradient(135deg, #1f7898, #15566d);
  color: white;
}
.library-hero-inner {
  min-height: 300px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 54px 0;
}
.library-title {
  font-size: clamp(2.3rem, 5vw, 4.6rem);
  line-height: 1.02;
  margin: 10px 0 12px;
}
.library-subtitle { color: #d9eef4; font-size: 1.05rem; line-height: 1.6; max-width: 720px; }
.library-section { padding: 56px 0 80px; }
.library-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 26px;
}
.search-input { width: min(320px, 100%); background: white; }
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.topic-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  padding: 26px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.topic-card:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(18,50,62,.12); }
.topic-number {
  width: 48px; height: 48px; border-radius: 14px; background: var(--teal-soft);
  color: var(--teal-dark); display: grid; place-items: center; font-weight: 700;
}
.topic-card h3 { margin-bottom: 8px; font-size: 1.2rem; }
.topic-card p { color: var(--muted); line-height: 1.55; margin: 0 0 14px; }
.topic-card span { color: var(--teal-dark); font-weight: 700; }

.topic-hero { padding: 54px 0 48px; }
.back-link { color: white; margin-bottom: 28px; }

.resource-section { margin-top: 8px; }
.section-heading { margin-bottom: 22px; }
.resource-list { display: grid; gap: 16px; }
.resource-item {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  box-shadow: var(--shadow);
}
.resource-item h3 { margin: 0 0 6px; }
.resource-item p { color: var(--muted); margin: 0; line-height: 1.55; }
.resource-type {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--teal-dark);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.dashboard-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 28px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.section-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.count-badge {
  min-width: 34px; height: 34px; padding: 0 10px; border-radius: 999px;
  background: #e6eef1; display: grid; place-items: center; font-weight: 700;
}
.user-list { display: grid; gap: 12px; margin-top: 22px; }
.user-item { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fbfdfe; }
.user-main { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.user-name { font-weight: 700; }
.user-email, .user-meta { color: var(--muted); font-size: .9rem; margin-top: 4px; word-break: break-word; }
.user-message { margin-top: 10px; color: var(--text); font-size: .92rem; line-height: 1.5; }
.user-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.empty-state { color: var(--muted); padding: 8px 0; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); padding: 24px 0 36px; font-size: .9rem; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 34px; min-height: auto; }
  .auth-card { justify-self: stretch; max-width: none; }
  .grid-two, .topic-grid, .admin-grid { grid-template-columns: 1fr; }
  .library-hero-inner, .dashboard-head, .library-toolbar { align-items: flex-start; flex-direction: column; }
  .resource-item { grid-template-columns: 1fr; }
  .main-area { padding-top: 40px; }
}


/* V1.4 Lighthouse banner */
.lighthouse-banner {
  width: 100%;
  min-height: 290px;
  background-image:
    linear-gradient(rgba(8, 28, 38, 0.08), rgba(8, 28, 38, 0.08)),
    url("lighthouse-banner.png");
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--line);
}

.member-welcome {
  background: white;
  border-bottom: 1px solid var(--line);
}

.member-welcome-inner {
  min-height: 150px;
  padding: 30px 0;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.member-welcome-title {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.05;
  margin: 8px 0 8px;
  letter-spacing: -0.04em;
}

@media (max-width: 820px) {
  .lighthouse-banner {
    min-height: 210px;
    background-position: center;
  }

  .member-welcome-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}


.login-subtitle {
  margin: 10px 0 0;
  max-width: 650px;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--muted);
}

select {
  display:block; width:100%; margin-top:7px; border:1px solid var(--line);
  border-radius:12px; background:#fbfdfe; padding:13px 14px; outline:none;
}
select:focus { border-color:var(--teal); box-shadow:0 0 0 3px rgba(31,120,152,.12); }
.content-topic-block { border:1px solid var(--line); border-radius:16px; padding:18px; background:#fbfdfe; }
.content-topic-block + .content-topic-block { margin-top:14px; }
.content-resource-row { margin-top:10px; padding:12px 14px; border-radius:12px; background:white; border:1px solid var(--line); display:flex; justify-content:space-between; gap:14px; align-items:center; }
.role-badge { display:inline-block; margin-left:8px; font-size:.72rem; text-transform:uppercase; letter-spacing:.06em; padding:4px 7px; border-radius:999px; background:var(--teal-soft); color:var(--teal-dark); font-weight:700; }


/* V1.7 content-management refinements */
.topic-card p,
#topicDescription,
.resource-item p,
.user-message,
.preserve-lines {
  white-space: pre-wrap;
}

.upload-progress {
  margin-top: 10px;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--teal-soft);
}

.upload-progress > div {
  width: 0%;
  height: 100%;
  background: var(--teal);
  transition: width .15s ease;
}


/* V1.8 resource editing + optional images */
.form-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}

.resource-image {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 14px;
  margin: 12px 0;
  border: 1px solid var(--line);
}

.resource-text-wrap {
  min-width: 0;
}

.resource-item.image-layout {
  display: block;
}

.resource-item.image-layout .resource-open-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: 14px;
}

@media (max-width: 820px) {
  .resource-item.image-layout .resource-open-row {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* V1.8.1 smaller resource images */
.resource-image {
  width: auto;
  max-width: 320px;
  max-height: 220px;
  object-fit: contain;
  display: block;
  margin: 12px 0;
}

@media (max-width: 600px) {
  .resource-image {
    max-width: 100%;
    max-height: 200px;
  }
}

.resource-video {
  display: block;
  width: min(100%, 760px);
  max-height: 520px;
  margin: 16px 0 6px;
  border-radius: 14px;
  background: #000;
}


/* V2.0 nested topics */
.subtopic-section {
  margin: 22px 0 26px;
}

.subtopic-section h3 {
  margin-bottom: 12px;
}

.subtopic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.subtopic-card {
  text-align: left;
  border: 1px solid var(--line);
  background: white;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
}

.subtopic-card:hover {
  transform: translateY(-1px);
}

.subtopic-card h4 {
  margin: 0 0 6px;
}

.subtopic-card p {
  margin: 0;
  white-space: pre-wrap;
}

.topic-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  font-size: .92rem;
}

.topic-breadcrumbs button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--teal);
  cursor: pointer;
  font: inherit;
}

.topic-breadcrumbs span {
  color: var(--muted);
}


/* V2.1 file preview + download */
.resource-file-preview {
  margin-top: 16px;
  width: 100%;
}

.resource-file-frame {
  display: block;
  width: 100%;
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.resource-file-image-preview {
  display: block;
  max-width: min(100%, 760px);
  max-height: 640px;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.resource-file-preview audio {
  width: min(100%, 760px);
}

.preview-close-btn {
  margin-top: 10px;
}

@media (max-width: 700px) {
  .resource-file-frame {
    min-height: 480px;
  }
}


/* V2.2 Word document preview */
.docx-preview {
  max-width: 820px;
  max-height: 720px;
  overflow: auto;
  padding: 28px 34px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  line-height: 1.6;
}

.docx-preview h1,
.docx-preview h2,
.docx-preview h3,
.docx-preview h4 {
  margin-top: 1.2em;
  margin-bottom: .55em;
}

.docx-preview p {
  margin: .65em 0;
  white-space: normal;
}

.docx-preview img {
  max-width: 100%;
  height: auto;
}

.docx-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.docx-preview td,
.docx-preview th {
  border: 1px solid var(--line);
  padding: 8px;
}

@media (max-width: 700px) {
  .docx-preview {
    padding: 18px;
    max-height: 620px;
  }
}


/* V2.3 PowerPoint preview */
.pptx-preview-shell {
  max-width: 960px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
}

.pptx-preview-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border-radius: 8px;
}

.pptx-preview-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}


/* V2.4 topic images */
.topic-card-image,
.subtopic-card-image,
.topic-detail-image {
  display: block;
  width: auto;
  max-width: 180px;
  max-height: 120px;
  object-fit: contain;
  border-radius: 12px;
  margin: 10px 0;
  border: 1px solid var(--line);
}

.topic-card-image {
  max-width: 150px;
  max-height: 100px;
}

.subtopic-card-image {
  max-width: 140px;
  max-height: 90px;
}

@media (max-width: 600px) {
  .topic-card-image,
  .subtopic-card-image,
  .topic-detail-image {
    max-width: 100%;
    height: auto;
  }
}

.topic-card-image { max-width: 220px; max-height: 150px; }
.subtopic-card-image { max-width: 200px; max-height: 135px; }
.topic-detail-image { max-width: 280px; max-height: 190px; }

.content-resource-row .button-row button[title="Move up"],
.content-resource-row .button-row button[title="Move down"] {
  min-width: 42px;
  padding-left: 12px;
  padding-right: 12px;
  font-size: 1.05rem;
}


/* V2.7 — cleaner vertical subtopic rows */
.subtopic-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.subtopic-card {
  width: 100%;
  display: grid;
  grid-template-columns: 155px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  text-align: left;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(18, 63, 78, 0.06);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.subtopic-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(18, 63, 78, 0.11);
}

.subtopic-row-image {
  width: 155px;
  height: 105px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
  background: #f4f7f8;
  flex-shrink: 0;
}

.subtopic-row-image:empty {
  background:
    linear-gradient(135deg, rgba(26, 126, 155, .06), rgba(26, 126, 155, .12));
}

.subtopic-row-image-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.subtopic-row-content {
  min-width: 0;
}

.subtopic-row-content h4 {
  margin: 0 0 7px;
  font-size: 1.08rem;
  color: var(--ink);
}

.subtopic-row-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.subtopic-row-open {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  color: var(--teal);
  font-weight: 700;
  white-space: nowrap;
}

.subtopic-row-open span:last-child {
  font-size: 1.15rem;
}

@media (max-width: 760px) {
  .subtopic-card {
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
  }

  .subtopic-row-image {
    width: 105px;
    height: 82px;
  }

  .subtopic-row-open {
    grid-column: 2;
    padding-left: 0;
    margin-top: -2px;
    font-size: .92rem;
  }
}

@media (max-width: 500px) {
  .subtopic-card {
    grid-template-columns: 90px minmax(0, 1fr);
  }

  .subtopic-row-image {
    width: 90px;
    height: 74px;
  }

  .subtopic-row-open span:first-child {
    display: none;
  }
}


/* V2.8 Lighthouse image library */
.image-library-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 30, 38, .52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.image-library-modal.hidden {
  display: none;
}

.image-library-panel {
  width: min(980px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0,0,0,.22);
}

.image-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.image-library-choice {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease;
}

.image-library-choice:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(18, 63, 78, .10);
}

.image-library-choice img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 10px;
  background: #f4f7f8;
}

.image-library-choice strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
}

.image-library-choice.selected {
  outline: 3px solid rgba(31, 139, 169, .28);
  border-color: var(--teal);
}
