/* RTP official template kit — shared tokens */
:root {
  --rtp-navy: #0a1f44;
  --rtp-navy-2: #132f5c;
  --rtp-gold: #c5a35a;
  --rtp-gold-2: #e4c98a;
  --rtp-red: #9b1c1c;
  --rtp-ink: #1a2230;
  --rtp-muted: #5a6578;
  --rtp-line: #d7deea;
  --rtp-paper: #fbfaf6;
  --rtp-white: #ffffff;
  --font: "Kanit", "Sarabun", "TH Sarabun New", system-ui, sans-serif;
  --display: "Kanit", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--rtp-ink);
  background: #e8ecf2;
  line-height: 1.45;
}

.sheet {
  width: min(210mm, 100%);
  min-height: 297mm;
  margin: 16px auto;
  background: var(--rtp-paper);
  box-shadow: 0 12px 40px rgba(10, 31, 68, 0.18);
  position: relative;
  overflow: hidden;
}

.sheet-landscape {
  width: min(297mm, 100%);
  min-height: 210mm;
}

.sheet-square {
  width: min(1080px, 100%);
  min-height: 1080px;
  aspect-ratio: 1;
}

.sheet-story {
  width: min(420px, 100%);
  min-height: 747px;
  aspect-ratio: 9/16;
}

.bar-top {
  height: 8px;
  background: linear-gradient(90deg, var(--rtp-navy), var(--rtp-navy-2) 55%, var(--rtp-gold));
}

.header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px 10px;
  border-bottom: 1px solid var(--rtp-line);
}

.logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo.lg { width: 88px; height: 88px; }
.logo.sm { width: 48px; height: 48px; }

.org {
  min-width: 0;
}
.org .line1 {
  font-weight: 700;
  font-size: 15px;
  color: var(--rtp-navy);
  letter-spacing: 0.02em;
}
.org .line2 {
  font-size: 12.5px;
  color: var(--rtp-muted);
  margin-top: 2px;
}
.org .line3 {
  font-size: 11px;
  color: var(--rtp-gold);
  font-weight: 600;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge-level {
  margin-left: auto;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--rtp-line);
  color: var(--rtp-navy);
  background: #fff;
  white-space: nowrap;
}
.badge-level.public { border-color: #8fbf9a; color: #1f6b3a; background: #eef8f0; }
.badge-level.internal { border-color: #e0c37a; color: #7a5a10; background: #fff8e8; }
.badge-level.secret { border-color: #d08a8a; color: #8a1f1f; background: #fff0f0; }

.body { padding: 16px 22px 20px; }
.title {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.25;
  color: var(--rtp-navy);
  font-weight: 700;
}
.meta {
  font-size: 12px;
  color: var(--rtp-muted);
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 0 14px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--rtp-line);
  border-radius: 10px;
  padding: 10px 10px 9px;
  text-align: center;
}
.kpi .n {
  font-size: 22px;
  font-weight: 700;
  color: var(--rtp-navy);
  line-height: 1.1;
}
.kpi .l {
  font-size: 11px;
  color: var(--rtp-muted);
  margin-top: 3px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
}
.panel {
  background: #fff;
  border: 1px solid var(--rtp-line);
  border-radius: 10px;
  padding: 12px 13px;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--rtp-navy);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.panel p, .panel li {
  font-size: 13px;
  color: var(--rtp-ink);
  margin: 0;
}
.panel ul { margin: 0; padding-left: 17px; }
.panel li { margin: 4px 0; }
.panel .muted { color: var(--rtp-muted); font-size: 12px; }

.next {
  margin-top: 12px;
  border-left: 4px solid var(--rtp-gold);
  background: linear-gradient(90deg, rgba(197,163,90,.12), transparent);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
}
.next strong { color: var(--rtp-navy); }

.footer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 22px 10px;
  border-top: 1px solid var(--rtp-line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: var(--rtp-muted);
  background: rgba(251,250,246,.96);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(10,31,68,.92);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
}
.toolbar a, .toolbar button {
  color: #0a1f44;
  background: linear-gradient(180deg, #e4c98a, #c5a35a);
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
}
.toolbar .ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
}
.hint {
  width: min(210mm, calc(100% - 24px));
  margin: 0 auto 20px;
  color: #5a6578;
  font-size: 12px;
  text-align: center;
}

/* Dark war-room variant */
.theme-dark {
  --rtp-paper: #0b1424;
  --rtp-ink: #e8eefc;
  --rtp-muted: rgba(232,238,252,.62);
  --rtp-line: rgba(143,208,255,.18);
  --rtp-navy: #8fd0ff;
  --rtp-navy-2: #5bb8f5;
  color-scheme: dark;
}
.theme-dark .sheet { background: radial-gradient(120% 80% at 80% 0%, #13284a, #0b1424 55%); }
.theme-dark .panel, .theme-dark .kpi { background: rgba(255,255,255,.04); }
.theme-dark .footer { background: rgba(8,14,28,.9); }
.theme-dark .org .line1 { color: #eaf0ff; }
.theme-dark .title { color: #ffe08a; }
.theme-dark .kpi .n { color: #fff; }
.theme-dark .badge-level { background: rgba(0,0,0,.25); color: #eaf0ff; }

/* Poster */
.poster-hero {
  padding: 28px 28px 20px;
  text-align: center;
}
.poster-hero .logo { width: 110px; height: 110px; margin: 0 auto 12px; display: block; }
.poster-hero h1 {
  margin: 8px 0 10px;
  font-size: 34px;
  line-height: 1.2;
  color: var(--rtp-navy);
}
.poster-hero .sub {
  font-size: 16px;
  color: var(--rtp-muted);
  max-width: 28ch;
  margin: 0 auto;
}
.bullets {
  margin: 18px 28px;
  display: grid;
  gap: 10px;
}
.bullet {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--rtp-line);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
}
.bullet .num {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, var(--rtp-gold-2), var(--rtp-gold));
  color: #2a1f08; font-weight: 700; flex-shrink: 0; font-size: 13px;
}

/* Infographic flow */
.flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.step {
  border: 1px solid var(--rtp-line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  text-align: center;
}
.step .n {
  width: 26px; height: 26px; margin: 0 auto 6px;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--rtp-navy); color: #fff; font-size: 12px; font-weight: 700;
}
.step h4 { margin: 0 0 4px; font-size: 13px; color: var(--rtp-navy); }
.step p { margin: 0; font-size: 11.5px; color: var(--rtp-muted); }

/* LINE card */
.line-card {
  width: min(390px, 100%);
  min-height: auto;
  margin: 16px auto;
  border-radius: 18px;
}
.line-card .body { padding: 14px 16px 18px; }
.line-card .title { font-size: 18px; }

[contenteditable="true"] {
  outline: none;
  border-radius: 4px;
}
[contenteditable="true"]:hover {
  box-shadow: inset 0 0 0 1px rgba(197,163,90,.45);
}
[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px rgba(197,163,90,.7);
  background: rgba(197,163,90,.06);
}

@media print {
  body { background: #fff; }
  .toolbar, .hint { display: none !important; }
  .sheet, .line-card {
    margin: 0;
    box-shadow: none;
    width: 100%;
    min-height: auto;
  }
  @page { margin: 10mm; size: A4; }
}

@media (max-width: 700px) {
  .kpis, .grid-2, .flow { grid-template-columns: 1fr 1fr; }
  .header { flex-wrap: wrap; }
  .badge-level { margin-left: 0; }
}
