:root {
  --bg: #e6e0d4;
  --paper: #f7f3ea;
  --ink: #1d1915;
  --muted: #6f675e;
  --line: #ddd4c4;
  --seal: #8d2e2a;
  --ok: #1d6a48;
  --warn: #8a5a12;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 400px at 10% -10%, #f3ecdf, transparent 50%),
    var(--bg);
  color: var(--ink);
  font: 17px/1.55 "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}
a { color: inherit; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 7vw 0;
}
.brand {
  font-family: "Iowan Old Style", Palatino, "Songti SC", serif;
  font-size: 22px;
  text-decoration: none;
  letter-spacing: 0.04em;
}
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); }
main { padding: 28px 7vw 80px; }
.sheet {
  max-width: 760px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 28px 32px;
  box-shadow: 0 20px 50px rgba(60, 40, 20, 0.06);
}
.narrow { max-width: 520px; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--seal);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
}
h1 {
  font-family: "Iowan Old Style", Palatino, "Songti SC", serif;
  font-weight: 500;
  font-size: 40px;
  line-height: 1.15;
  margin: 0 0 12px;
}
h2 { font-size: 18px; margin: 28px 0 10px; }
.lead, .muted { color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
label { display: block; margin: 14px 0; font-size: 14px; color: var(--muted); }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
button, .button {
  appearance: none;
  border: 0;
  background: var(--seal);
  color: #fff8f4;
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
button.danger { background: transparent; color: var(--seal); border: 1px solid var(--seal); }
button:disabled { opacity: 0.6; cursor: progress; }
.inline { display: flex; gap: 12px; align-items: end; margin-top: 12px; }
.inline label { flex: 1; }
.error { color: var(--seal); min-height: 1.2em; }
.status { display: inline-block; padding: 4px 10px; border-radius: 999px; background: #efe6d4; }
.status-pending { background: #f3e0c2; color: var(--warn); }
.status-released { background: #dceadf; color: var(--ok); }
dl { margin: 18px 0; }
dl div { display: grid; grid-template-columns: 88px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-top: 1px solid var(--line); }
.list a { display: flex; justify-content: space-between; gap: 12px; text-decoration: none; }
.list p { margin: 4px 0 0; color: var(--muted); }
pre {
  white-space: pre-wrap;
  background: #fffdf8;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--line);
}

/* A small, deliberate step at a time: prepare, write, seal. */
.compose-sheet { max-width: 600px; margin: 12px auto 0; padding: 32px 36px 24px; }
.compose-sheet h1 { font-size: clamp(29px, 4vw, 38px); line-height: 1.4; }
.compose-sheet .lead { font-size: 16px; line-height: 1.85; margin-bottom: 24px; }
.compose-progress { display: flex; gap: 0; list-style: none; padding: 0 0 23px; margin: 0 0 30px; border-bottom: 1px solid var(--line); }
.compose-progress li { display: flex; align-items: center; gap: 7px; flex: 1; font-size: 13px; color: var(--muted); }
.compose-progress li:last-child { flex: 0 0 auto; }
.compose-progress li span { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; width: 25px; height: 25px; font-size: 12px; }
.compose-progress li[aria-current="step"] { color: var(--seal); }
.compose-progress li[aria-current="step"] span { color: var(--paper); background: var(--seal); border-color: var(--seal); }
.compose-progress .is-complete span { background: #e6ebdf; border-color: #d4ddca; color: var(--ok); }
.compose-recipient { font-size: 14px; margin: 0 0 22px; overflow-wrap: anywhere; }
.compose-recipient span { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 28px; }
.compose-actions a, .compose-back { font-size: 13px; color: var(--muted); text-decoration: none; }
.compose-back { padding-left: 0; background: transparent; }
.compose-actions button[type="submit"] { font-size: 14px; }
.compose-note, .field-note { font-size: 12px; color: var(--muted); line-height: 1.8; }
.compose-note { margin: 20px 0 0; }
.field-note { margin-top: -5px; }
.optional { float: right; font-size: 12px; }
.compose-sheet textarea { min-height: 145px; }
.compose-options { margin-top: 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; }
.compose-options summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.compose-summary { padding: 12px 15px; background: #eee7d8; font-size: 13px; border-radius: 8px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .compose-sheet { padding: 25px 21px 18px; }
  .compose-progress li { font-size: 11px; gap: 5px; }
  .compose-progress li span { width: 22px; height: 22px; }
  .compose-actions { gap: 10px; }
  .compose-actions button[type="submit"] { padding: 10px 13px; font-size: 12px; }
}

.passphrase-notice { margin: 22px 0; padding: 18px 20px; background: #f0e5d5; border: 1px solid #ddc8ac; border-left: 4px solid var(--seal); border-radius: 8px; }
.passphrase-notice p { margin: 8px 0 0; color: #625246; font-size: 13px; line-height: 1.85; }
.passphrase-notice .passphrase-notice-title { margin: 0 0 8px; font-family: "Songti SC", Palatino, serif; font-size: 20px; color: var(--ink); }
.passphrase-notice strong { color: var(--seal); font-size: 14px; }

.compose-delete { padding: 0; background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }

.page-back { display: inline-block; color: var(--muted); font-size: 13px; text-decoration: none; margin-bottom: 24px; }
.envelope-overview { margin: 12px auto 0; }
.envelope-overview h1, .envelope-task h1 { overflow-wrap: anywhere; line-height: 1.35; }
.envelope-task { max-width: 600px; margin: 12px auto 0; }
.envelope-task h1 { font-size: clamp(28px, 4vw, 36px); }
.overview-note { margin-top: 16px; }
.envelope-more { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.envelope-more[open] > .field-note { margin: 16px 0 18px; }
.envelope-more summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.envelope-choices { display: grid; gap: 12px; margin-top: 26px; }
.envelope-choices a { display: flex; align-items: center; gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.envelope-choices a:hover { background: #eee7d9; }
.choice-number { font-family: Palatino, serif; font-size: 22px; color: var(--seal); }
.envelope-choices a > span:nth-child(2) { flex: 1; }
.envelope-choices strong { display: block; font-size: 17px; font-weight: 500; }
.envelope-choices small { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.7; }
.edit-group { border: 0; border-top: 1px solid var(--line); padding: 14px 0 0; margin: 24px 0; min-width: 0; }
.edit-group legend { font-size: 18px; padding-right: 16px; }

.app-footer { padding: 0 7vw 28px; font-size: 12px; color: var(--muted); }
.app-footer a { text-decoration: none; }
.faq-page { max-width: 850px; margin: 20px auto 0; }
.faq-intro { max-width: 650px; padding-bottom: 25px; }
.faq-intro h1 { line-height: 1.4; font-size: clamp(36px, 5vw, 52px); margin-top: 15px; }
.faq-intro .lead { font-size: 16px; line-height: 1.9; max-width: 560px; }
.faq-top-nav { display: flex; gap: 24px; font-size: 14px; }
.faq-top-nav a { text-decoration: none; }
.faq-topics { display: flex; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--line); padding-top: 22px; }
.faq-topics a { font-size: 13px; padding: 8px 14px; border: 1px solid #cfc2ad; border-radius: 999px; text-decoration: none; }
.faq-topics a:hover { background: var(--paper); }
.faq-group { margin-top: 45px; scroll-margin-top: 24px; }
.faq-group h2 { font-family: "Songti SC", Palatino, serif; font-size: 26px; font-weight: 500; margin-bottom: 18px; }
.faq-group h2 span { font-family: Palatino, serif; font-size: 15px; color: var(--seal); padding-right: 10px; }
.faq-group details { border-top: 1px solid #d0c4b3; }
.faq-group details:last-child { border-bottom: 1px solid #d0c4b3; }
.faq-group summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: 17px; line-height: 1.8; padding: 21px 0; }
.faq-group summary::-webkit-details-marker { display: none; }
.faq-group summary::after { content: "+"; color: var(--seal); flex-shrink: 0; font-size: 23px; font-weight: 300; }
.faq-group details[open] > summary::after { content: "−"; }
.faq-answer { padding: 0 30px 22px 0; max-width: 730px; }
.faq-answer p { font-size: 15px; line-height: 1.95; color: var(--muted); margin: 0 0 12px; }
.faq-answer p:last-child { margin-bottom: 0; }
.faq-answer strong { color: var(--ink); font-weight: 500; }
.faq-group summary:focus-visible { outline: 2px solid var(--seal); outline-offset: 4px; }
.faq-ending { margin-top: 55px; padding: 30px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.faq-ending h2 { font-family: "Songti SC", Palatino, serif; font-weight: 500; font-size: 27px; margin-top: 0; }
.faq-ending p { font-size: 15px; color: var(--muted); line-height: 1.9; margin-bottom: 23px; }
@media (max-width: 600px) {
  .faq-page { margin-top: 12px; }
  .faq-group summary { font-size: 15px; }
  .faq-answer { padding-right: 5px; }
  .faq-answer p { font-size: 14px; }
  .faq-ending { padding: 23px; }
  .faq-top-nav { gap: 16px; font-size: 13px; }
}
.management-link { display: inline-block; font-size: 14px; color: var(--muted); margin: 15px 0 0; text-underline-offset: 4px; }
.request-callout { margin-top: 22px; padding: 18px; background: #f3e0c2; border-radius: 10px; }
.request-callout p { margin-top: 0; font-size: 14px; }
.sealed-envelope-card { border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-top: 28px; }
.sealed-envelope-card h2 { margin-top: 8px; }

/* Keep editing controls and their explanations in separate, spaced rows. */
.edit-sheet .field-note { margin: 8px 0 0; }
.edit-sheet .file-original { margin-top: 24px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; }
.file-original-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.file-original-heading > div { min-width: 0; }
.file-original-label { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.file-original-name { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.file-original .secondary-button { flex-shrink: 0; background: transparent; color: var(--seal); border: 1px solid var(--seal); font-size: 13px; padding: 8px 14px; }
.edit-sheet .file-original .field-note { margin-top: 14px; }
.edit-sheet .file-replacement { margin-top: 22px; }
.edit-sheet #action-status, .edit-sheet #action-error { margin: 14px 0 0; min-height: 0; font-size: 14px; overflow-wrap: anywhere; }
.edit-sheet #action-status:empty, .edit-sheet #action-error:empty { display: none; }
.edit-sheet .passphrase-notice { margin: 28px 0 0; }
@media (max-width: 480px) {
  .file-original-heading { flex-direction: column; align-items: flex-start; gap: 12px; }
}

.key-dialog { width: min(440px, calc(100% - 32px)); padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 80px #1d19152b; }
.key-dialog::backdrop { background: #1d191566; }
.key-dialog h2 { margin: 0 0 12px; font-family: "Songti SC", Palatino, serif; font-size: 26px; font-weight: 500; }
.key-dialog .field-note { margin: 0 0 18px; }
.key-dialog .error:empty { display: none; }

.recipient-code-row { display: flex; align-items: stretch; gap: 12px; }
.recipient-code-row input { margin-top: 0; flex: 1; min-width: 0; }
.recipient-code-row button { flex: 0 0 126px; border-radius: 10px; font-size: 14px; }
.recipient-code-row button:disabled, .edit-sheet button[type="submit"]:disabled, #confirm-delete:disabled { cursor: not-allowed; background: #d4cec4; color: #777168; opacity: 1; }
.edit-sheet #recipient-status { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.edit-sheet #recipient-status:empty { display: none; }
@media (max-width: 480px) {
  .recipient-code-row { gap: 8px; }
  .recipient-code-row button { flex-basis: 112px; font-size: 12px; }
}
.key-dialog > form > p:not(.field-note):not(.error):not(.muted) { font-size: 14px; line-height: 1.8; }
.key-dialog #delete-status { font-size: 13px; }
.key-dialog #delete-status:empty { display: none; }

.envelope-heading { display: flex; align-items: center; gap: 20px; margin-bottom: 12px; }
.envelope-heading h1 { flex: 1; min-width: 0; margin: 0; }
.envelope-settings { flex-shrink: 0; color: var(--muted); font-size: 13px; text-underline-offset: 4px; }
.overview-actions { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 28px; }
.overview-actions .management-link { margin: 0; }

.key-dialog .recipient-code-row + .field-note { margin: 10px 0 0; }

.compose-sheet .compose-step-title { font-family: inherit; font-size: 12px; font-weight: 400; line-height: 1.6; margin: 0 0 14px; }

.note-paper { position: relative; margin: 28px 0 4px; padding: 30px 30px 36px; background: linear-gradient(145deg, #fffdf4, #f5edda); box-shadow: 0 8px 22px #58472b0b, 0 1px 2px #58472b12; border-radius: 2px 2px 8px 2px; }
.note-paper::after { content: ""; position: absolute; top: 0; right: 0; width: 20px; height: 20px; background: linear-gradient(225deg, var(--paper) 48%, #e8dcc1 50%, #f8f0dd 80%); }
.note-paper-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: "Songti SC", "Iowan Old Style", Palatino, serif; font-size: 20px; line-height: 2; letter-spacing: 0.03em; color: #3d3428; outline: none; }
@media (max-width: 480px) {
  .note-paper { padding: 24px 22px 28px; }
  .note-paper-text { font-size: 18px; }
}

.key-hint-trigger { display: block; margin: 8px 0 20px; padding: 0; background: none; border-radius: 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
.key-hint-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.9; }
#key-hint-dialog .compose-actions { justify-content: flex-end; }

.note-reading-header { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.note-reading-header h1 { margin: 0; }
.note-reading-caption { margin: 10px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 0.06em; }
.note-reader .note-paper { margin: 0; }
.note-reader #cover-unlock > .muted { font-size: 14px; line-height: 1.85; margin-top: 0; }

.app-footer { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.legal-consent { display: flex; align-items: flex-start; gap: 10px; margin: 20px 0; font-size: 12px; line-height: 1.9; }
.legal-consent input { flex: 0 0 auto; width: 16px; height: 16px; margin: 4px 0 0; padding: 0; accent-color: var(--seal); }
.legal-consent a { color: var(--seal); text-underline-offset: 3px; }
#otp-form button:disabled, #verify-form button:disabled { background: #d4cec4; color: #777168; opacity: 1; cursor: not-allowed; }
.legal-page { margin: 12px auto 0; max-width: 850px; padding: 32px; }
.legal-page h1 { font-size: clamp(25px, 4vw, 36px); line-height: 1.5; }
.legal-page h2 { margin-top: 36px; font-size: 20px; }
.legal-page p, .legal-page td { font-size: 14px; line-height: 1.95; overflow-wrap: anywhere; }
.legal-version { color: var(--muted); }
.legal-page strong { font-weight: 600; }
.legal-page table { width: 100%; border-collapse: collapse; }
.legal-page th, .legal-page td { padding: 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.legal-page th { font-size: 14px; background: #eee7d8; }
.legal-operator { font-size: 14px; }
.legal-operator div { grid-template-columns: 88px minmax(0, 1fr); }
.legal-operator dd { overflow-wrap: anywhere; }
.legal-draft { padding: 16px; border: 1px solid #ddc8ac; border-radius: 8px; background: #f0e5d5; font-size: 14px; line-height: 1.9; }
@media (max-width: 480px) { .legal-page { padding: 24px 18px; } .legal-page th, .legal-page td { padding: 8px; } }
