:root {
  --ink: #172033;
  --muted: #637083;
  --line: #d8dee8;
  --paper: #ffffff;
  --panel: #f5f7fb;
  --accent: #0f6f73;
  --accent-2: #a33d2f;
  --gold: #b48a32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background: #e9edf4;
}

button, input, textarea, select { font: inherit; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
}

.control-panel {
  height: 100vh;
  overflow: auto;
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.panel-head, .preview-toolbar, .row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

.group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.template-button, .small-button, .icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  cursor: pointer;
}

.template-button {
  min-height: 38px;
  padding: 6px;
  font-size: 13px;
  font-weight: 700;
}

.template-button.active {
  border-color: var(--accent);
  background: #e6f4f3;
  color: #075255;
}

.small-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

.icon-button {
  min-width: 58px;
  min-height: 44px;
  padding: 8px 12px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.field {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.checkline, .audit-list label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0;
  color: #2e394b;
  font-size: 13px;
}

.stop-card {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stop-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 13px;
}

.stop-card-head button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.stop-card .two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.photo-uploader {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.photo-editor-list {
  display: grid;
  gap: 8px;
}

.photo-editor-item {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 8px;
}

.photo-editor-item img {
  width: 54px;
  height: 42px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.photo-editor-item input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}

.photo-editor-item button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--accent-2);
  font-weight: 700;
  cursor: pointer;
}

.preview-zone {
  height: 100vh;
  overflow: auto;
  padding: 22px;
}

.preview-toolbar {
  max-width: 880px;
  margin: 0 auto 14px;
  color: var(--muted);
}

#templateName {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

#pageHint {
  font-size: 12px;
}

.report {
  width: min(100%, 820px);
  margin: 0 auto 40px;
  background: var(--paper);
  box-shadow: 0 16px 50px rgba(28, 40, 62, .16);
}

.page {
  min-height: 1120px;
  padding: 68px 72px;
  border-bottom: 1px solid #edf0f5;
  position: relative;
}

.cover-page {
  display: grid;
  place-items: center;
  text-align: center;
}

.cover-inner {
  display: grid;
  gap: 32px;
  justify-items: center;
}

.mark {
  width: 116px;
  height: 116px;
  border: 12px solid var(--accent);
  border-radius: 50%;
  position: relative;
}

.mark::before, .mark::after {
  content: "";
  position: absolute;
  inset: 18px -28px;
  border: 12px solid var(--accent);
  border-radius: 50%;
}

.mark::after { transform: rotate(90deg); }

.report h3 {
  margin: 0 0 20px;
  font-size: 22px;
  text-align: center;
}

.cover-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.7;
}

.cover-period, .cover-publisher {
  font-size: 18px;
  font-weight: 700;
}

.section {
  margin-bottom: 24px;
}

.section-title {
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--ink);
  font-size: 17px;
  font-weight: 800;
}

.plain-list {
  margin: 0;
  padding-left: 1.4em;
  line-height: 1.9;
}

.body-text {
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 14px;
}

.two-column-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  font-size: 14px;
}

.two-column-list strong {
  display: block;
  margin-bottom: 4px;
}

.stop {
  break-inside: avoid;
  margin-top: 26px;
}

.stop h4 {
  margin: 0 0 12px;
  padding: 8px 10px;
  background: #eef3f7;
  border-left: 5px solid var(--accent);
  font-size: 16px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.meta-grid dt {
  color: var(--muted);
  font-weight: 800;
}

.meta-grid dd { margin: 0; }

.subblock {
  margin: 12px 0;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  line-height: 1.8;
  font-size: 13px;
}

.source-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.photo-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.photo-figure {
  margin: 0;
  break-inside: avoid;
}

.photo-figure img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  display: block;
}

.photo-figure figcaption {
  margin-top: 5px;
  color: #475367;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.photo-box {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #e7eff0, #f8f3e7);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.finding {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  background: #fff9ec;
  line-height: 1.8;
}

.audit-box {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.audit-box strong { display: block; margin-bottom: 8px; }

.official .cover-page { display: none; }
.official .page { padding-top: 72px; }
.photo .stop h4 { background: #f6eeee; border-left-color: var(--accent-2); }
.photo .mark, .photo .mark::before, .photo .mark::after { border-color: var(--accent-2); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .control-panel { height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-zone { height: auto; padding: 14px; }
  .page { min-height: auto; padding: 44px 28px; }
  .date-range { grid-template-columns: 1fr; }
  .two-column-list { grid-template-columns: 1fr; }
  .photo-editor-item { grid-template-columns: 48px 1fr; }
  .photo-editor-item button { grid-column: 2; }
  .photo-row { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .control-panel, .preview-toolbar { display: none; }
  .app { display: block; }
  .preview-zone { height: auto; padding: 0; overflow: visible; }
  .report { width: 210mm; margin: 0; box-shadow: none; }
  .page {
    min-height: 297mm;
    page-break-after: always;
    border-bottom: 0;
  }
}
