@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin-standard-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/newsreader-latin-standard-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #171513;
  --brown: #704b37;
  --paper: #ffffff;
  --wash: #f6f5f3;
  --hover: #efedea;
  --select: #ebe4df;
  --rule: #dcdad6;
  --grey: #5c5955;
  --soft: #8a8681;
  --danger: #9b2c1c;
  --ok: #2f6b3a;
  --radius: 6px;
  --sans: 'Inter', Arial, Helvetica, sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
#app { min-height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brown); }
.boot { padding: 40px; color: var(--grey); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--paper); cursor: pointer;
  font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2c2925; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
a.btn { text-decoration: none; color: inherit; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.input, textarea.input, select.input {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--rule);
  border-radius: var(--radius); background: #fff; outline: none;
}
textarea.input { height: auto; padding: 10px 11px; resize: vertical; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23, 21, 19, 0.08); }
.error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.note { color: var(--grey); font-size: 13px; }

/* ---------- sign-in screens ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--wash); }
.gate-card {
  width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--rule);
  border-radius: 12px; padding: 32px 28px 26px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { height: 22px; width: auto; }
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.gate .brand { justify-content: center; margin-bottom: 6px; }
.gate h1 { font-size: 15px; font-weight: 600; text-align: center; margin: 0 0 22px; color: var(--grey); letter-spacing: 0.02em; }
.gate .btn.primary { width: 100%; height: 40px; margin-top: 4px; }
.gate-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--soft); }
.gate-foot a { color: var(--grey); }

/* ---------- application shell ---------- */
.shell { display: grid; grid-template-columns: 216px minmax(300px, 400px) 1fr; height: 100vh; }
.side { border-right: 1px solid var(--rule); background: var(--wash); display: flex; flex-direction: column; min-height: 0; }
.side-top { padding: 16px 14px 10px; }
.side .brand-name { font-size: 17px; }
.side .brand img { height: 18px; }
.side-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--soft); margin: 4px 0 0 30px; }
.compose-btn { margin: 12px 14px 8px; width: calc(100% - 28px); height: 38px; }
.nav { list-style: none; margin: 0; padding: 4px 8px; }
.nav button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 0; background: transparent; padding: 7px 10px; border-radius: var(--radius); cursor: pointer; text-align: left;
}
.nav button:hover { background: var(--hover); }
.nav button.on { background: var(--select); font-weight: 600; }
.nav .count { font-size: 12px; color: var(--grey); font-weight: 600; }
.side-bottom { margin-top: auto; padding: 10px 14px 14px; border-top: 1px solid var(--rule); }
.who { font-size: 13px; margin-bottom: 8px; }
.who strong { display: block; font-weight: 600; }
.who span { color: var(--soft); font-size: 12px; }
.side-links { display: flex; flex-wrap: wrap; gap: 4px; }

.list-pane { border-right: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--rule); display: flex; gap: 8px; align-items: center; }
.list-head h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.search { padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.search .input { height: 34px; }
.list { flex: 1; overflow-y: auto; }
.item {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #eceae6;
  background: #fff; padding: 11px 14px 11px 18px; cursor: pointer; position: relative;
}
.item:hover { background: #faf9f7; }
.item.on { background: var(--select); }
.item.unread::before {
  content: ''; position: absolute; left: 7px; top: 17px; width: 6px; height: 6px; border-radius: 50%; background: var(--brown);
}
.item-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item-from { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread .item-from, .item.unread .item-subj { font-weight: 700; }
.item-date { font-size: 12px; color: var(--soft); white-space: nowrap; }
.item-subj { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #3a3733; }
.item-meta { font-size: 12px; color: var(--soft); margin-top: 2px; }
.empty { padding: 40px 20px; text-align: center; color: var(--soft); }
.more { padding: 12px; text-align: center; }

.read-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.back { display: none; }
.reader { flex: 1; overflow-y: auto; padding: 22px 28px 40px; }
.reader h1 { font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1.25; margin: 0 0 16px; letter-spacing: -0.01em; }
.hdr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; font-size: 13px; margin-bottom: 18px; }
.hdr .k { color: var(--soft); }
.hdr .from strong { font-weight: 600; }
.hdr .when { color: var(--soft); grid-column: 3; grid-row: 1; white-space: nowrap; }
.banner { border: 1px solid var(--rule); background: var(--wash); border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.banner.warn { border-color: #e2c4bd; background: #fbf3f1; color: #6d241a; }
.body-frame { width: 100%; border: 0; display: block; min-height: 120px; }
.body-text { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.55; margin: 0; font-family: var(--sans); }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--rule); }
.att {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 6px 10px; text-decoration: none; color: var(--ink); font-size: 13px; max-width: 280px;
}
.att:hover { background: var(--hover); }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--soft); white-space: nowrap; }
.placeholder { display: grid; place-items: center; height: 100%; color: var(--soft); }

/* ---------- compose and dialogs ---------- */
.overlay { position: fixed; inset: 0; background: rgba(23, 21, 19, 0.35); display: grid; place-items: center; padding: 20px; z-index: 10; }
.dialog { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18); }
.dialog.narrow { max-width: 460px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.dialog-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.dialog-body { padding: 16px 18px; overflow-y: auto; }
.dialog-foot { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--rule); }
.dialog-foot .spacer { flex: 1; }
.crow { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.crow label { font-size: 13px; color: var(--grey); }
.crow .input { height: 34px; }
.compose-body { width: 100%; min-height: 260px; font-size: 14px; line-height: 1.55; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--wash); border: 1px solid var(--rule); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px; }
.chip button { border: 0; background: transparent; cursor: pointer; padding: 0 4px; color: var(--grey); }
.link-btn { border: 0; background: none; color: var(--grey); cursor: pointer; font-size: 12px; padding: 0 4px; text-decoration: underline; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eceae6; vertical-align: middle; }
.table th { font-size: 12px; color: var(--soft); font-weight: 500; }
.linkbox { display: flex; gap: 6px; margin-top: 8px; }
.linkbox .input { font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: var(--radius); font-size: 13px; z-index: 20; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ---------- small screens: one pane at a time ---------- */
.menu-btn { display: none !important; }
.shell > * { min-width: 0; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .shell.show-side .side { display: flex; position: fixed; inset: 0 25% 0 0; z-index: 5; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .shell.reading .list-pane { display: none; }
  .shell:not(.reading) .read-pane { display: none; }
  .back { display: inline-flex; }
  .menu-btn { display: inline-flex !important; }
  .reader { padding: 18px 16px 32px; }
  .reader h1 { font-size: 21px; }
  .hdr { grid-template-columns: auto 1fr; }
  .hdr .when { grid-column: 1 / -1; grid-row: auto; order: 99; margin-top: 4px; }
  .crow { grid-template-columns: 52px 1fr; }
}
