* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f6f5f1;
  color: #2b2b2b;
  line-height: 1.5;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.site-header .header-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.site-header .subheader {
  color: #666;
  font-size: 1rem;
  font-style: italic;
}

.site-header .tagline {
  margin: 0 0 1.5rem;
  color: #666;
  font-size: 0.95rem;
}

/* ---------- Editor ---------- */

.editor {
  width: 100%;
  min-height: 55vh;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.6;
  padding: 0.9rem 0.75rem;
  border: 1px solid #d8d5cc;
  border-radius: 8px;
  background: #fff;
  resize: vertical;
  outline: none;
}

.editor:focus { border-color: #8f8a7a; }

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.counters { color: #777; font-size: 0.85rem; }

.btn {
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  border: 1px solid #c9c5ba;
  border-radius: 8px;
  background: #fff;
  color: #2b2b2b;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:hover:not(:disabled) { background: #efede7; }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: #2d5f3f;
  border-color: #2d5f3f;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #244d33; }

.popover-anchor { position: relative; }

.result-dialog {
  position: absolute;
  bottom: calc(100% + 13px);
  left: auto;
  right: 0;
  margin: 0;
  width: min(480px, calc(100vw - 2.5rem));
  padding: 1.25rem 1.5rem;
  background: #eaf3ec;
  border: 1px solid #bcd8c4;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  z-index: 10;
}

/* Wedge pointing down at the Generate Certificate button */
.result-dialog::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 4rem;
  width: 13px;
  height: 13px;
  background: #eaf3ec;
  border-right: 1px solid #bcd8c4;
  border-bottom: 1px solid #bcd8c4;
  transform: rotate(45deg);
}

.redact-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  font-size: 0.92rem;
  cursor: pointer;
  user-select: none;
}
.redact-option input { accent-color: #2d5f3f; margin: 0; }
.result-dialog h2 { margin: 0 0 0.5rem; font-size: 1.1rem; padding-right: 1.5rem; }
.result-dialog p { margin: 0.25rem 0 0.75rem; font-size: 0.92rem; }
.result-dialog .note { color: #5c7a64; margin-bottom: 0; }

.dialog-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.25rem;
  color: #5c7a64;
  cursor: pointer;
}
.dialog-close:hover { color: #2b2b2b; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.65rem;
}
.icon-btn .icon-check { color: #2d5f3f; }

.link-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.link-row + .link-row { margin-top: 0.5rem; }
.link-row .copy-desc { color: #5f6d63; font-style: italic; }
.link-row input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  border: 1px solid #bcd8c4;
  border-radius: 8px;
  background: #fff;
}

.error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fbeaea;
  border: 1px solid #e3b8b8;
  border-radius: 8px;
  color: #8a2e2e;
}

.hidden { display: none !important; }

/* ---------- Viewer ---------- */

.cert-header { margin-bottom: 1rem; }
.cert-meta { color: #666; font-size: 0.88rem; }
.cert-meta strong { color: #2b2b2b; font-weight: 600; }

.paste-notice {
  margin-top: 0.6rem;
  padding: 0.45rem 0.75rem;
  background: #fdf3e3;
  border: 1px solid #ecd3a3;
  border-radius: 8px;
  color: #7a5a1e;
  font-size: 0.85rem;
}

.stage-wrap {
  position: relative;
}

.stage {
  position: relative;
  height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 0.9rem 0.75rem 5rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: 1px solid #d8d5cc;
  border-radius: 8px;
  background: #fff;
}

.break-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.4rem 1rem;
  background: rgba(43, 43, 43, 0.85);
  color: #fff;
  font-size: 0.88rem;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
}

.sim-score {
  position: absolute;
  right: 0.75rem;
  bottom: 4.2rem;
  padding: 0.25rem 0.65rem;
  background: rgba(45, 95, 63, 0.85);
  color: #fff;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  pointer-events: none;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  vertical-align: text-bottom;
  background: #2d5f3f;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.2);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.8rem;
}

.slider { flex: 1; min-width: 100px; accent-color: #2d5f3f; }

.time-label {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: #666;
  min-width: 5.5rem;
}

.write-your-own {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: #777;
}
.write-your-own a { color: #2d5f3f; }

.loading { color: #777; padding: 2rem 0; }

/* ---------- 404 ---------- */

.notfound { text-align: center; padding: 4rem 0; }
.notfound h2 { font-size: 1.4rem; }
.notfound a { color: #2d5f3f; }
