:root {
  --linen: #d4c6b0;
  --paper: #fbf6ec;
  --ink: #2b2218;
  --muted: #7a6c5c;
  --rule: #d8cbb8;
  --seal: #8a3324;
  --seal-dark: #6e2418;
  --ok: #2f5d3a;
  --err: #8a3324;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top, #efe4d2 0%, var(--linen) 55%, #cbb89a 100%);
}

.desk {
  width: min(620px, calc(100% - 32px));
  margin: 40px auto 64px;
  background: var(--paper);
  padding: 36px 36px 40px;
  border-radius: 4px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 18px 40px rgba(70, 48, 24, 0.22);
}

.mast { margin-bottom: 28px; }
.mast-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.text-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--seal);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.mark {
  margin: 0 0 6px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--seal);
}
h1 {
  margin: 0 0 8px;
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 500;
  font-size: 30px;
}
.about-link {
  margin-left: 6px;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--seal);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.auth-heading {
  margin: 0 0 8px;
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 500;
  font-size: 24px;
}
.auth-switch-wrap {
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 4px 10px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--seal);
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
}
input, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 10px 12px;
}
textarea {
  font-family: Georgia, "Iowan Old Style", serif;
  line-height: 1.5;
  resize: vertical;
}
input:focus, textarea:focus {
  outline: 2px solid rgba(138, 51, 36, 0.25);
  border-color: var(--seal);
}
input[readonly] {
  background: #f3eee4;
  color: var(--ink);
}
.secret-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.secret-field input { flex: 1; }
.secret-field .ghost { margin-top: 0; }

.seal, .ghost {
  appearance: none;
  font: inherit;
  cursor: pointer;
  border-radius: 3px;
  padding: 10px 18px;
}
.seal {
  margin-top: 18px;
  background: var(--seal);
  color: #fbf6ec;
  border: 0;
}
.seal:hover { background: var(--seal-dark); }
.ghost {
  margin-top: 18px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.confirm {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  background: #fffdf8;
}
.confirm p { margin: 0 0 4px; }
.confirm .row { margin-top: 0; }
.confirm .seal, .confirm .ghost { margin-top: 10px; }

.error, .ok { margin: 12px 0 0; font-size: 14px; }
.error { color: var(--err); }
.ok { color: var(--ok); }

.hint { color: var(--muted); line-height: 1.45; }
.about p {
  margin: 0 0 14px;
  line-height: 1.55;
}
.about p:last-child { margin-bottom: 0; }
.token-label {
  margin: 20px 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.token {
  margin: 0;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 28px;
  letter-spacing: 0.08em;
}

.letter .meta {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}
.letter .meta strong {
  color: var(--ink);
  font-weight: 600;
}
.letter-body {
  margin: 20px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 18px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.item-list li {
  display: flex;
  gap: 8px;
  align-items: stretch;
  border-bottom: 1px solid var(--rule);
}
.item-main {
  appearance: none;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  text-align: left;
  background: none;
  border: 0;
  padding: 12px 4px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.item-date { font-size: 12px; color: var(--muted); }
.item-from { font-size: 14px; }
.item-subject { font-size: 15px; font-family: Georgia, "Iowan Old Style", serif; }
.item-del {
  appearance: none;
  background: none;
  border: 0;
  color: var(--seal);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 0 6px;
}

.admin-invite-row {
  margin: 12px 0 0;
}
.admin-invite-row .ghost {
  margin-top: 0;
}
.admin-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}
.admin-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.admin-name {
  margin: 0 0 4px;
  font-weight: 600;
}
.admin-flag {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--seal);
}
.admin-counts {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.admin-actions label {
  margin: 0;
}
.admin-actions input {
  width: 140px;
}
.admin-actions .seal,
.admin-actions .ghost {
  margin-top: 0;
}

@media (max-width: 520px) {
  .desk { padding: 24px 20px 32px; margin-top: 20px; }
  h1 { font-size: 24px; }
  .token { font-size: 22px; }
}
