:root {
  color-scheme: light;
  --ink: #19352f;
  --muted: #65766f;
  --line: #dce9e3;
  --paper: #fbfdfb;
  --cream: #f5f1e8;
  --teal: #0b766f;
  --teal-dark: #07544f;
  --mint: #dff3ec;
  --coral: #e77263;
  --shadow: 0 22px 54px rgba(33, 70, 61, 0.11);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--cream); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 90% 0%, rgba(212, 239, 229, 0.78), transparent 30rem),
    linear-gradient(180deg, #f7f5ee 0%, #fbfdfb 48%, #f4f1e8 100%);
  color: var(--ink);
}

a { color: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

.portal-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  border-bottom: 1px solid rgba(122, 151, 141, 0.24);
}

.portal-brand, .portal-header-actions, .scope-list, .template-meta, .template-actions, .dialog-head, .separation-line, .portal-footer {
  display: flex;
  align-items: center;
}

.portal-brand { gap: 11px; text-decoration: none; }
.portal-brand strong { display: block; font-size: 15px; letter-spacing: 0.16em; }
.portal-brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; }

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--teal-dark);
  color: white;
  font-size: 19px;
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(7, 84, 79, 0.2);
}

.portal-header-actions { gap: 12px; }
.version-pill, .scope-list span {
  border: 1px solid #bbddd2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
}
.version-pill { padding: 7px 10px; }
.back-link { color: var(--teal-dark); font-size: 13px; font-weight: 850; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  gap: clamp(32px, 7vw, 96px);
  align-items: end;
  padding: clamp(64px, 10vw, 120px) 0 78px;
}

.eyebrow { margin: 0 0 12px; color: var(--teal); font-size: 11px; font-weight: 950; letter-spacing: 0.16em; }
.hero-copy h1 { max-width: 760px; margin: 0; font-size: clamp(52px, 8vw, 104px); font-weight: 850; letter-spacing: -0.07em; line-height: 0.91; }
.hero-copy h1 em { color: var(--coral); font-style: normal; }
.hero-lede { max-width: 660px; margin: 30px 0 24px; color: var(--muted); font-size: clamp(16px, 1.8vw, 20px); line-height: 1.65; }
.scope-list { flex-wrap: wrap; gap: 8px; }
.scope-list span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px; letter-spacing: 0; }
.scope-list i { display: inline-grid; width: 17px; height: 17px; place-items: center; border-radius: 50%; background: var(--mint); color: var(--teal-dark); font-size: 11px; font-style: normal; }

.separation-card { position: relative; overflow: hidden; padding: 28px; border: 1px solid #cfe5dc; border-radius: 22px; background: rgba(255, 255, 255, 0.72); box-shadow: var(--shadow); }
.separation-card::after { content: ""; position: absolute; right: -45px; bottom: -60px; width: 180px; height: 180px; border: 1px solid rgba(11, 118, 111, 0.17); border-radius: 50%; }
.separation-icon { display: grid; width: 38px; height: 38px; margin-bottom: 34px; place-items: center; border-radius: 12px; background: var(--mint); color: var(--teal-dark); font-size: 20px; font-weight: 900; }
.separation-card h2 { margin: 0 0 10px; font-size: 25px; letter-spacing: -0.03em; }
.separation-card > p:not(.eyebrow) { position: relative; z-index: 1; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.separation-line { position: relative; z-index: 1; gap: 8px; margin-top: 26px; color: var(--teal-dark); font-size: 11px; font-weight: 850; }
.separation-line span { width: 30px; height: 2px; background: var(--coral); }

.library-section, .partner-use-section { padding: 42px 0 76px; border-top: 1px solid rgba(122, 151, 141, 0.24); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.section-heading.compact { align-items: center; }
.section-heading h2 { margin: 0; font-size: clamp(28px, 4vw, 43px); letter-spacing: -0.055em; line-height: 1; }
.section-heading p:not(.eyebrow) { max-width: 620px; margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.section-note { max-width: 260px; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.45; text-align: right; }
.library-count { display: grid; min-width: 112px; padding: 13px 17px; border-left: 3px solid var(--coral); background: #fff9f3; }
.library-count strong { font-size: 35px; line-height: 1; }
.library-count span { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }

.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.template-card { overflow: hidden; border: 1px solid #d8e8e1; border-radius: 20px; background: var(--paper); box-shadow: 0 14px 34px rgba(33, 70, 61, 0.08); }
.template-preview { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #dfece7; }
.template-preview img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 240ms ease; }
.template-card:hover .template-preview img { transform: scale(1.025); }
.template-preview::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, transparent 50%, rgba(7, 84, 79, 0.55)); }
.preview-badge { position: absolute; z-index: 1; top: 14px; left: 14px; padding: 7px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); color: var(--teal-dark); font-size: 10px; font-weight: 950; letter-spacing: 0.1em; }
.preview-pages { position: absolute; z-index: 1; right: 14px; bottom: 14px; color: white; font-size: 12px; font-weight: 850; }
.template-body { padding: 24px; }
.template-body h3 { margin: 0 0 8px; font-size: 25px; letter-spacing: -0.04em; }
.template-body > p { min-height: 48px; margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.template-meta { flex-wrap: wrap; gap: 7px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.template-meta span { color: var(--muted); font-size: 11px; font-weight: 800; }
.template-meta span + span::before { content: "·"; margin-right: 7px; color: #a8bbb4; }
.template-actions { flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.action-button { display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 6px; padding: 0 13px; border: 1px solid #b9d8ce; border-radius: 8px; background: white; color: var(--teal-dark); font-size: 12px; font-weight: 900; text-decoration: none; cursor: pointer; }
.action-button:hover { border-color: var(--teal); background: #eff9f5; }
.action-button.primary { border-color: var(--teal-dark); background: var(--teal-dark); color: white; }
.action-button.primary:hover { background: var(--teal); }

.workflow-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.workflow-grid article { min-height: 170px; padding: 21px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,0.55); }
.workflow-grid article > span { display: block; margin-bottom: 24px; color: var(--coral); font-size: 12px; font-weight: 950; letter-spacing: 0.1em; }
.workflow-grid strong { display: block; font-size: 17px; }
.workflow-grid p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.guardrail-note { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 13px; margin-top: 18px; padding: 16px 18px; border-left: 3px solid var(--coral); background: #fff8f2; color: #70534a; font-size: 12px; line-height: 1.6; }
.guardrail-note strong { color: #a24e42; white-space: nowrap; }

.portal-footer { justify-content: space-between; gap: 12px; padding: 25px 0 35px; border-top: 1px solid rgba(122, 151, 141, 0.24); color: var(--muted); font-size: 11px; line-height: 1.5; }

.gallery-dialog { width: min(1000px, calc(100% - 28px)); max-height: min(88vh, 900px); padding: 0; border: 1px solid #cfe5dc; border-radius: 18px; background: #fbfdfb; color: var(--ink); box-shadow: 0 26px 90px rgba(16, 47, 40, 0.25); }
.gallery-dialog::backdrop { background: rgba(17, 43, 37, 0.62); backdrop-filter: blur(4px); }
.gallery-dialog-inner { padding: 22px; }
.dialog-head { justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.dialog-head h2 { margin: 0; font-size: 26px; letter-spacing: -0.04em; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid #c5ddd4; border-radius: 50%; background: white; color: var(--teal-dark); font-size: 25px; cursor: pointer; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-height: 70vh; overflow-y: auto; padding-right: 3px; }
.gallery-grid figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: white; }
.gallery-grid img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.gallery-grid figcaption { padding: 8px 10px; color: var(--muted); font-size: 11px; font-weight: 800; }

@media (max-width: 820px) {
  .portal-shell { width: min(100% - 28px, 640px); }
  .portal-header { min-height: 72px; }
  .version-pill { display: none; }
  .portal-hero { grid-template-columns: 1fr; gap: 30px; padding: 58px 0 56px; }
  .hero-copy h1 { font-size: clamp(50px, 16vw, 80px); }
  .separation-card { max-width: none; }
  .section-heading, .section-heading.compact { align-items: flex-start; flex-direction: column; }
  .section-note { max-width: none; text-align: left; }
  .library-count { align-self: stretch; grid-template-columns: auto auto; align-items: center; gap: 9px; border-left: 0; border-top: 3px solid var(--coral); }
  .library-count strong { font-size: 28px; }
  .library-count span { margin-top: 0; }
  .template-grid, .workflow-grid { grid-template-columns: 1fr; }
  .template-body > p { min-height: 0; }
  .portal-footer { align-items: flex-start; flex-direction: column; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .portal-header-actions { gap: 0; }
  .back-link { font-size: 12px; }
  .hero-lede { font-size: 15px; }
  .template-body { padding: 19px; }
  .template-body h3 { font-size: 22px; }
  .action-button { flex: 1 1 auto; }
  .guardrail-note { grid-template-columns: 1fr; gap: 5px; }
  .gallery-dialog-inner { padding: 14px; }
  .gallery-grid { grid-template-columns: 1fr; }
}
