﻿:root {
  --bg: #eef1ea;
  --card: #ffffff;
  --ink: #171d22;
  --muted: #4c5d73;
  --line: #d6deea;
  --accent: #1b75bc;
  --accent-dark: #134f9c;
  --accent-2: #6a4bc3;
  --paper: #fbfbf7;
  --shadow: 0 16px 42px rgba(24, 38, 28, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Gill Sans", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 9%, rgba(27, 117, 188, 0.16) 0, rgba(27, 117, 188, 0) 36%),
    radial-gradient(circle at 91% 4%, rgba(106, 75, 195, 0.14) 0, rgba(106, 75, 195, 0) 32%),
    linear-gradient(150deg, #f5f8fc 0%, #e9eef7 50%, #eceff8 100%);
}

.container {
  width: min(1320px, 96vw);
  margin: 22px auto 38px;
}

.container-single {
  width: min(1320px, 96vw);
}

.page-header {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 244, 0.96));
  border: 1px solid #ccd8ec;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px 22px;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: "";
  position: absolute;
  right: -50px;
  top: -50px;
  width: 140px;
  height: 140px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(106, 75, 195, 0.24) 0, rgba(106, 75, 195, 0) 70%);
}

.page-header h1 {
  margin: 0 0 4px;
  font-family: "Arial Black", "Trebuchet MS", sans-serif;
  letter-spacing: 0.01em;
  font-size: clamp(1.55rem, 2.8vw, 2.1rem);
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.filters {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 220px auto auto;
  gap: 10px;
  align-items: end;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid #cfd9ea;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(25, 44, 31, 0.08);
}

.filters label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

input,
select,
button,
.link-button,
.open-link {
  font: inherit;
}

input,
select {
  padding: 10px 11px;
  border: 1px solid #bfcbb9;
  border-radius: 10px;
  background: #fff;
}

button,
.open-link,
.link-button {
  display: inline-block;
  text-decoration: none;
  border-radius: 10px;
  border: 0;
  padding: 10px 13px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

button,
.open-link {
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(27, 117, 188, 0.28);
}

.link-button {
  background: #edf2fb;
  color: var(--ink);
  border: 1px solid #cfdbef;
}

button:hover,
.open-link:hover,
.link-button:hover {
  transform: translateY(-1px);
}

.result-meta {
  margin-top: 14px;
  color: var(--muted);
}

.cards {
  margin-top: 12px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  background: linear-gradient(165deg, #ffffff 0%, #f4f7fd 100%);
  border: 1px solid #d0daea;
  border-radius: 14px;
  padding: 15px;
  box-shadow: 0 8px 18px rgba(19, 36, 24, 0.08);
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.card .code,
.card .meta,
.badge {
  margin: 0 0 6px;
  color: var(--muted);
}

.badge {
  font-weight: 600;
  color: var(--accent-dark);
}

.empty {
  grid-column: 1 / -1;
}

.top-actions {
  display: flex;
  gap: 10px;
  margin: 14px 0 12px;
  align-items: center;
}

.passage-doc {
  background: linear-gradient(180deg, #fff 0%, var(--paper) 100%);
  border: 1px solid #d2dced;
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.passage-header {
  border-bottom: 2px solid #dce5f3;
  margin-bottom: 16px;
  padding-bottom: 10px;
}

.passage-header h1 {
  margin: 0 0 6px;
  font-family: "Arial Black", "Trebuchet MS", sans-serif;
  font-size: clamp(1.5rem, 2.2vw, 2.05rem);
  letter-spacing: 0.01em;
}

.passage-header p {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 600;
}

.word-wall {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #cfd9eb;
  border-radius: 14px;
  background: #f3f7fd;
  max-width: 520px;
}

.word-wall-label {
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--muted);
}

.word-wall img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

.word-wall-inline {
  display: none;
  margin: 12px 0 16px;
  padding: 14px 18px;
  border: 3px dashed #b6c7e7;
  border-radius: 24px;
  background: #f5f7ff;
  max-width: 680px;
}

.word-wall-inline img {
  border-radius: 18px;
  max-height: 180px;
  object-fit: cover;
  object-position: center;
}

section {
  margin-bottom: 16px;
}

section h2 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
}

.passage-content {
  line-height: 1.58;
  font-size: 1.08rem;
}

.passage-paragraph {
  margin: 0 0 10px;
}

.passage-paragraph.tts-reading {
  background: linear-gradient(90deg, rgba(27, 117, 188, 0.16), rgba(106, 75, 195, 0.12));
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 4px 8px 4px 10px;
  margin-left: -10px;
  transition: background-color 0.2s ease;
}

.passage-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid #ced9ee;
  border-radius: 12px;
  background: #eef3fd;
}

.passage-tab {
  border: 1px solid #c6d5ef;
  background: #fff;
  color: #223038;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: none;
}

.passage-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 8px 14px rgba(27, 117, 188, 0.24);
}

.tts-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid #ced9ee;
  border-radius: 12px;
  background: #f7f9fe;
}

.tts-btn {
  border: 1px solid #c6d5ef;
  background: #fff;
  color: #223038;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.tts-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tts-rate-label {
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 700;
}

.tts-rate {
  border: 1px solid #bfd0ee;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  font-size: 0.88rem;
}

.tts-status {
  color: var(--muted);
  font-size: 0.86rem;
  min-height: 1em;
}

.passage-title {
  text-align: center;
  font-weight: 700;
}

.passage-body {
  text-indent: 1.35em;
}

.passage-level {
  display: none;
  break-inside: avoid;
}

.passage-level.is-active {
  display: block;
}

.download-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 2px solid #dce5f3;
}

.download-panel h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.download-form {
  display: grid;
  gap: 12px;
}

.download-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.download-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--muted);
}

.download-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.passage-layout {
  display: grid;
  grid-template-columns: minmax(400px, 560px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  min-height: calc(100vh - 210px);
}

.passage-side {
  min-width: 0;
}

.passage-sticky {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 34px);
  overflow: auto;
}

.passage-side .word-wall-inline {
  display: block;
  float: none;
  max-width: none;
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid #cfd9eb;
  border-radius: 14px;
  background: #f3f7fd;
}

.passage-side .word-wall-inline img {
  width: 100%;
  max-height: 620px;
  border-radius: 10px;
  object-fit: contain;
}

.passage-side .word-wall-inline a {
  display: block;
}

.passage-main {
  min-width: 0;
  height: calc(100vh - 34px);
  max-height: calc(100vh - 34px);
  overflow-y: auto;
  padding-right: 8px;
}

.pat-box {
  border: 1px solid #cfd9eb;
  border-radius: 14px;
  background: #f3f7fd;
  padding: 12px 14px;
}

.pat-box-title {
  margin: 0 0 8px;
  font-size: 1.02rem;
  text-decoration: underline;
  color: var(--accent-dark);
}

.pat-box-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.35;
}

.pat-box-list li + li {
  margin-top: 4px;
}

.passage-level::after {
  content: "";
  display: block;
  clear: both;
}

.pdf-export .passage-header .word-wall {
  display: none;
}

.pdf-export .word-wall-inline {
  display: block;
  float: left;
  max-width: 380px;
  margin: 0 20px 12px 0;
  padding: 12px 14px;
  border-radius: 22px;
}

.pdf-export .word-wall-inline img {
  width: 100%;
  max-height: 260px;
}

.pdf-export .passage-label {
  display: none;
}

.pdf-export .passage-level + .passage-level {
  page-break-before: always;
  break-before: page;
}

.rp-template-export {
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  width: 816px;
  margin: 0;
  padding: 34px;
  box-sizing: border-box;
}

.pdf-export-root {
  width: 816px;
  max-width: 816px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: #fff;
}

.rp-template-page {
  width: 100%;
  min-height: 988px;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 10px;
  box-sizing: border-box;
}

.rp-template-page + .rp-template-page {
  page-break-before: always;
  break-before: page;
}

.rp-template-header-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}

.rp-template-header-img {
  width: auto;
  max-width: 100%;
  max-height: 62px;
  height: auto;
  object-fit: contain;
  display: block;
}

.rp-template-page-title {
  text-align: center;
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 18pt;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 2px;
}

.rp-template-content-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3in;
  gap: 18px;
  align-items: start;
  margin: 0;
}

.rp-template-focus-box,
.rp-template-visual-box {
  overflow: visible;
}

.rp-template-visual-box {
  border: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
}

.rp-template-focus-box {
  display: block;
}

.rp-template-focus-title {
  margin: 0 0 8px;
  font-weight: 700;
  text-decoration: underline;
  font-size: 12pt;
}

.rp-template-focus-list {
  margin: 0;
  padding-left: 22px;
  font-size: 11pt;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.rp-template-visual-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rp-template-visual {
  width: 100%;
  max-height: 4in;
  height: auto;
  object-fit: contain;
  display: block;
}

.rp-template-purpose {
  margin: 0 0 8px;
  text-align: center;
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 12pt;
  font-style: italic;
  line-height: 1.3;
}

.rp-template-body {
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 12pt;
  line-height: 1.4;
  margin: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.rp-template-body .passage-title {
  display: none;
}

.rp-template-body .passage-paragraph {
  margin: 0 0 6px;
}

.rp-template-body .passage-body {
  text-indent: 0;
}

.rp-template-footer {
  text-align: center;
  margin-top: 0;
  padding-top: 6px;
}

.rp-template-footer-logo {
  width: auto;
  max-width: 118px;
  max-height: 34px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
}

.rp-template-footer-copy {
  margin: 0;
  font-size: 9px;
}

.pdf-export .rp-template-page {
  min-height: auto;
}

.pdf-render-sandbox {
  position: fixed;
  left: 0;
  top: 0;
  width: 816px;
  background: #fff;
  z-index: -1;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

.pdf-render-sandbox .container,
.pdf-render-sandbox .container-single {
  width: 100%;
  max-width: none;
  margin: 0;
}

.pdf-render-sandbox .pdf-export-root {
  width: 816px;
  max-width: 816px;
  margin: 0;
}

@media (max-width: 1180px) {
  .container,
  .container-single {
    width: min(1160px, 96vw);
  }

  .passage-layout {
    grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .container,
  .container-single {
    width: min(980px, 96vw);
  }

  .passage-layout {
    grid-template-columns: minmax(290px, 380px) minmax(0, 1fr);
    gap: 16px;
    min-height: calc(100vh - 195px);
  }

  .passage-main {
    height: calc(100vh - 34px);
    max-height: calc(100vh - 34px);
  }
}

@media (max-width: 760px) {
  .container,
  .container-single {
    width: min(760px, 96vw);
    margin-top: 14px;
  }

  .page-header {
    border-radius: 16px;
    padding: 15px 16px;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .passage-doc {
    border-radius: 14px;
    padding: 16px;
  }

  .passage-content {
    font-size: 1rem;
    line-height: 1.52;
  }

  .passage-layout {
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: 0;
  }

  .passage-sticky {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .passage-main {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

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

@media print {
  @page {
    size: Letter portrait;
    margin: 0.35in;
  }

  html,
  body {
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .container,
  .container-single {
    width: 100%;
    margin: 0;
  }

  .passage-doc {
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  .pdf-export-root,
  .rp-template-export {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .rp-template-page {
    width: 100% !important;
    min-height: calc(11in - 0.7in) !important;
    page-break-after: always;
    break-after: page;
  }

  .rp-template-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .rp-template-content-row {
    grid-template-columns: minmax(0, 1fr) 2.75in;
    gap: 14px;
  }

  .rp-template-header-img {
    width: auto;
    max-width: 100%;
    max-height: 56px;
    height: auto;
  }

  .rp-template-visual {
    width: 100%;
    height: auto;
    max-height: 3.8in;
    object-fit: contain;
  }

  section,
  .passage-level {
    page-break-inside: avoid;
  }
}

.download-spinner {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.download-spinner.is-visible {
  display: flex;
}

.download-spinner .spinner-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.download-spinner .spinner-wheel {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 6px solid #cfd8dc;
  border-top-color: #1a73e8;
  animation: rp-spin 0.9s linear infinite;
}

.download-spinner .spinner-text {
  margin-top: 12px;
  font-size: 14px;
  color: #1f2937;
}

@keyframes rp-spin {
  to { transform: rotate(360deg); }
}
