:root {
  --forest: #1f3b2a; --forest-2: #2d5238; --sage-soft: #e7ecd9; --gold: #c99a3c; --gold-soft: #f3e5c3;
  --cream: #faf7f0; --paper: #fff; --ink: #22261f; --muted: #5b6157; --line: #e3ded1; --red: #a33a2b;
  --radius: 12px; --shadow: 0 1px 2px rgba(31,59,42,.06), 0 6px 18px rgba(31,59,42,.07);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font: 16px/1.55 "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--forest-2); }
h1 { font-size: 26px; margin: 0 0 6px; color: var(--forest); line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 12px; color: var(--forest); }
.wrap { width: min(1000px, 100% - 32px); margin-inline: auto; }
main.wrap { padding: 24px 0 64px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.bar { background: var(--paper); border-bottom: 3px solid var(--gold); }
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding: 8px 0; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--forest); font-weight: 700; }
.brand img { height: 34px; width: auto; }
.brand span { border-left: 1px solid var(--line); padding-left: 12px; }
nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
nav a, button.link {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--forest); text-decoration: none;
  padding: 6px 12px; border-radius: 999px; background: none; border: 0; cursor: pointer;
}
nav a:hover, button.link:hover { background: var(--sage-soft); }
nav form { margin: 0; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card.narrow { max-width: 420px; margin: 48px auto; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; color: var(--forest); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: 15px; }
input[type=text], input[type=email], input[type=password], input[type=search], textarea {
  font: inherit; font-weight: 400; color: var(--ink); width: 100%;
  padding: 9px 12px; border: 1px solid #cfc8b8; border-radius: 8px; background: #fff;
}
textarea { resize: vertical; }
input[type=file] { font: inherit; font-weight: 400; font-size: 14px; padding: 10px; border: 1px dashed #cfc8b8; border-radius: 8px; background: #fbfaf5; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }

.btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  padding: 8px 18px; border-radius: 999px; border: 1.5px solid var(--forest); background: var(--forest); color: #fff;
}
.btn:hover { background: var(--forest-2); }
.btn.ghost { background: transparent; color: var(--forest); }
.btn.ghost:hover { background: var(--sage-soft); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 15px; }
.flash.ok { background: var(--sage-soft); color: var(--forest); }
.flash.error { background: #f8e1dc; color: var(--red); }
.flash.info { background: var(--gold-soft); color: #5b4515; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { text-decoration: none; padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 15px; color: var(--forest); }
.tabs a.on { background: var(--forest); color: #fff; }
.tabs a b { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 12px; text-align: center; }
.search { display: flex; gap: 8px; flex: 1; max-width: 420px; }

.list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: grid; grid-template-columns: 220px 1fr auto; gap: 14px; align-items: baseline;
  padding: 12px 16px; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.row:first-child { border-top: 0; }
.row:hover { background: #fbfaf5; }
.row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .who em { font-style: normal; color: var(--muted); font-size: 13px; }
.row .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .subj strong { font-weight: 500; }
.row .snip { color: var(--muted); }
.row .when { color: var(--muted); font-size: 14px; white-space: nowrap; }
.row.unread .who, .row.unread .subj strong { font-weight: 700; color: var(--forest); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-right: 8px; vertical-align: middle; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); margin: 0; }

.thread-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.thread-head form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.tag { background: var(--sage-soft); color: var(--forest); padding: 1px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.tag.spam { background: #f8e1dc; color: var(--red); }

.msg { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.msg.out { border-left: 4px solid var(--gold); background: #fffdf7; }
.msg header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.msg .meta { font-size: 13px; color: var(--muted); }
.msg time { font-size: 14px; color: var(--muted); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.orig { margin-top: 12px; }
.orig summary { cursor: pointer; font-size: 14px; color: var(--forest-2); font-weight: 600; }
.orig iframe { width: 100%; height: 480px; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; background: #fff; }
.atts { list-style: none; padding: 12px 0 0; margin: 12px 0 0; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 8px 20px; }
.reply { margin-top: 24px; }
.sig-note { display: grid; gap: 4px; }
.sig-note pre { margin: 0; font: inherit; font-size: 15px; color: var(--ink); background: #fbfaf5; border-left: 3px solid var(--gold); padding: 8px 12px; border-radius: 0 8px 8px 0; white-space: pre-wrap; }
.atts li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.att-btn { font-size: 13px; font-weight: 600; text-decoration: none; padding: 3px 12px; border-radius: 999px; border: 1.5px solid var(--forest); color: var(--forest); }
.att-btn:hover { background: var(--sage-soft); }
.modal { display: none; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; padding: 3vh 3vw; }
.modal:target { display: flex; }
.modal-bg { position: absolute; inset: 0; background: rgba(20, 30, 24, .72); }
.modal-box { position: relative; width: min(1100px, 100%); height: 100%; background: #fff; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--cream); }
.modal-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; color: var(--forest); }
.modal-actions { display: flex; gap: 14px; font-size: 14px; font-weight: 600; }
.modal-actions a { text-decoration: none; }
.modal-close { color: var(--red) !important; }
.modal-body { flex: 1; width: 100%; border: 0; }
.modal-body.img { display: flex; align-items: center; justify-content: center; background: #2b2f2c; overflow: auto; }
.modal-body.img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.status { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 14px; color: var(--muted); }
.status .good { color: var(--forest-2); font-weight: 600; }
.status .bad, .status.bad { color: var(--red); font-weight: 600; }

@media (max-width: 700px) {
  .row { grid-template-columns: 1fr auto; }
  .row .subj { grid-column: 1 / -1; grid-row: 2; }
  .brand span { display: none; }
  .search { max-width: none; }
}
