:root {
  --ink: #10192E;
  --gold: #A9793D;
  --gold-soft: #c9a46a;
  --ivory: #E9E1CE;
  --ivory-2: #f4efe3;
  --white: #FFFFFF;
  --muted: #5c5a52;
  --line: #d7ceba;
  --danger: #9b2c2c;
  --danger-bg: #f8e4e0;
  --shadow: 0 18px 40px rgba(16, 25, 46, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(169, 121, 61, 0.08), transparent 55%),
    radial-gradient(800px 380px at 100% 10%, rgba(16, 25, 46, 0.06), transparent 50%),
    var(--ivory);
  color: var(--ink);
}

.hairline {
  height: 4px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--ink) 50%, var(--gold) 100%);
}

.wrap { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 72px; }

.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
.mark {
  display: flex;
  gap: 14px;
  align-items: center;
}
.seal {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--gold);
  display: grid; place-items: center;
  background: var(--white);
  box-shadow: inset 0 0 0 4px var(--ivory);
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  color: var(--gold);
  font-size: 20px;
}
.mark h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.mark p { color: var(--muted); font-size: 13px; margin-top: 4px; letter-spacing: 0.04em; text-transform: uppercase; }
.disclaimer {
  max-width: 340px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  text-align: right;
}

.steps {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
}
.dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--gold);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: var(--ivory-2);
  flex: none;
}
.step.active .dot { background: var(--gold); color: white; border-color: var(--gold); }
.step.done .dot { background: var(--ink); color: var(--gold-soft); border-color: var(--ink); }
.step span { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.rule {
  height: 1px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.rule i {
  display: block; height: 100%; width: 0;
  background: var(--gold);
  transition: width 0.4s ease;
}
.rule.fill i { width: 100%; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
h2.display {
  font-family: "Cormorant Garamond", serif;
  font-size: 36px;
  font-weight: 500;
  margin: 6px 0 8px;
}
.lede { color: var(--muted); max-width: 62ch; line-height: 1.55; margin-bottom: 22px; }
.lede em { font-family: "Cormorant Garamond", serif; font-size: 1.15em; color: var(--ink); }

label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.search-row { position: relative; margin-bottom: 12px; }
.search-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: var(--ivory-2);
  color: var(--ink);
  outline: none;
}
.search-row input:focus { border-color: var(--gold); background: white; }

.picker {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
.cats { display: flex; flex-direction: column; gap: 6px; }
.cat {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.cat:hover { background: var(--ivory-2); color: var(--ink); }
.cat.on { background: var(--ink); color: var(--ivory); border-color: var(--ink); }

.tpl-list {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
}
.tpl {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.tpl small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tpl:hover { background: var(--ivory-2); }
.tpl.on { background: #f3ead4; }
.tpl.on small { color: var(--gold); }

.capture {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  font: inherit;
  line-height: 1.55;
  background: var(--ivory-2);
  color: var(--ink);
  outline: none;
}
.capture:focus { border-color: var(--gold); background: white; }

.row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.left-actions { display: flex; gap: 8px; flex-wrap: wrap; }

button.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  will-change: transform;
}
button.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(16, 25, 46, 0.12); }
button.btn:active { transform: translateY(1px) scale(0.98); box-shadow: none; }
button.btn:disabled { opacity: 0.45; transform: none; box-shadow: none; cursor: not-allowed; }

.btn-gold { background: var(--gold); color: white; }
.btn-ink { background: var(--ink); color: var(--ivory); }
.btn-ghost { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn.recording { background: var(--danger); color: white; }

.hint { font-size: 12px; color: var(--muted); }

.status {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}
.status.err { color: var(--danger); }

.letter {
  position: relative;
  overflow: hidden;
  background: #fbf8f1;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.letter-head {
  background: var(--ink);
  color: var(--ivory);
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.letter-head b {
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-weight: 500;
}
.letter-head span { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-soft); }
.watermark {
  position: absolute;
  right: 18px; top: 70px;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(169, 121, 61, 0.18);
  opacity: 0.35;
  pointer-events: none;
}
.letter-body { padding: 22px 24px 28px; position: relative; }
.sec { margin-bottom: 18px; }
.sec h3 {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.sec h3::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
}
.sec p { line-height: 1.6; color: #2a2a28; }
mark.flag {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0 3px;
  border-radius: 3px;
}

.flags {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--ivory-2);
  border-radius: 12px;
  font-size: 13px;
}
.flags li { margin: 4px 0 4px 16px; }

.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--ink);
  color: var(--ivory);
  padding: 12px 16px;
  border-radius: 12px;
  display: none;
  z-index: 20;
  box-shadow: var(--shadow);
}

@media (max-width: 800px) {
  .mast { flex-direction: column; }
  .disclaimer { text-align: left; max-width: none; }
  .picker { grid-template-columns: 1fr; }
  .cats { flex-direction: row; overflow: auto; }
  .cat { white-space: nowrap; }
  .steps { grid-template-columns: 1fr; }
  .rule { display: none; }
  .mark h1 { font-size: 28px; }
  h2.display { font-size: 28px; }
  .panel { padding: 20px; }
}
