:root {
  --ink: #1b1712;
  --muted: #6d6458;
  --paper: #f1ebe1;
  --card: #fffaf2;
  --navy: #162033;
  --navy-2: #1e2c45;
  --gold: #c49a45;
  --gold-2: #e8d7a8;
  --line: #e2d8c6;
  --danger: #8f2d2d;
  --ok: #2c6a4a;
  --shadow: 0 18px 50px rgba(22, 32, 51, 0.12);
  --sans: "Segoe UI", "Avenir Next", "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  display: grid;
  grid-template-columns: 260px 1fr;
}

a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; }

.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, #101828 100%);
  color: #f4eee4;
  min-height: 100vh;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}
.brand strong { display: block; font-size: 15px; letter-spacing: 0.04em; }
.brand em { font-style: normal; font-family: var(--serif); color: var(--gold-2); font-size: 18px; }
.mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--gold); color: var(--navy);
  font-weight: 700; letter-spacing: 0.04em;
}
.compose-btn {
  display: block; text-align: center; text-decoration: none;
  background: var(--gold); color: var(--navy); font-weight: 700;
  padding: 11px 14px; border-radius: 999px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  text-decoration: none; color: #d9d0c3;
  padding: 10px 12px; border-radius: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar nav a.active, .sidebar nav a:hover { background: var(--navy-2); color: #fff; }
.sidebar nav b {
  background: var(--gold); color: var(--navy);
  min-width: 22px; height: 22px; border-radius: 999px;
  display: grid; place-items: center; font-size: 12px;
}
.sidebar nav span { color: #8b8376; font-size: 12px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; color: #9aa3b5; }
.side-foot a { color: var(--gold-2); text-decoration: none; }

.main { padding: 36px 42px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 28px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.16em; font-size: 11px; color: var(--muted); }
h1 { margin: 6px 0 0; font-family: var(--serif); font-size: 34px; font-weight: 600; }
.lead { max-width: 70ch; color: var(--muted); }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 10px; background: #efe6d4; }
.flash.ok { background: #dceee3; color: var(--ok); }
.flash.error, .bad { color: var(--danger); }
.flash.error { background: #f6e1e1; }

.search input, input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card);
  border-radius: 10px; padding: 10px 12px; font: inherit; color: inherit;
}
.search { min-width: 280px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 9px 16px; text-decoration: none; font: inherit; cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.danger { color: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.mail-list { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.mail-row {
  display: grid; grid-template-columns: 220px 1fr 170px;
  gap: 16px; padding: 14px 18px; text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: #faf4ea; }
.mail-row.unread .subj, .mail-row.unread .who { font-weight: 700; }
.who { color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subj { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.when { color: var(--muted); font-size: 13px; text-align: right; }

.empty, .card, .msg, .compose, .notes, .table-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; box-shadow: var(--shadow);
}
.empty h2, .card h2, .notes h2 { font-family: var(--serif); margin-top: 0; }
.muted { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips span { background: var(--gold-2); color: var(--navy); border-radius: 999px; padding: 3px 8px; font-size: 12px; }

.meta { display: grid; gap: 8px; margin: 0 0 18px; }
.meta div { display: grid; grid-template-columns: 70px 1fr; gap: 10px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.body-frame { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-height: 280px; background: #fff; }
.mail-frame { width: 100%; min-height: 360px; border: 0; background: #fff; }
.plain { white-space: pre-wrap; overflow: auto; font-size: 13px; }

.compose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compose-grid .full, label.full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hint { color: var(--muted); font-size: 14px; }
.html-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}
.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font: inherit;
}
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.file-btn {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.file-btn input { display: none; }
.html-source {
  width: 100%;
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #1b1712;
  color: #f4eee4;
  resize: vertical;
}
.html-preview {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.html-preview-xl,
.html-source-xl {
  min-height: calc(100vh - 280px);
  height: calc(100vh - 280px);
}
.page-head.compact { margin-bottom: 16px; }
.page-head.compact h1 { font-size: 26px; }
.subject-line { color: var(--ink); margin: 6px 0 10px; }
.sticky-actions {
  position: sticky;
  bottom: 12px;
  background: var(--card);
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  margin-top: 16px;
}

.editor-tools { display: flex; gap: 6px; margin-bottom: 8px; }
.editor-tools button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.editor {
  min-height: 240px; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; background: #fff; outline: none;
}
.var-box { margin: 12px 0; padding: 12px; background: #faf4ea; border-radius: 12px; }
.var-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }

.dns { width: 100%; border-collapse: collapse; }
.dns th, .dns td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dns .val { display: block; max-width: 520px; word-break: break-all; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.pill { background: var(--navy); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.pill.ok { background: var(--ok); }
.pill.warn { background: #8a5a12; }
.notes { margin-top: 22px; }
.notes h2 { font-size: 22px; }

.login-body {
  display: grid; place-items: center; grid-template-columns: 1fr;
  background:
    radial-gradient(900px 400px at 20% 0%, rgba(196,154,69,0.25), transparent),
    var(--navy);
}
.login-card {
  width: min(420px, 92vw); background: var(--card); color: var(--ink);
  padding: 32px; border-radius: 20px; box-shadow: var(--shadow);
}
.login-brand { margin-bottom: 8px; }
.login-brand .mark { background: var(--gold); }
.login-lead { color: var(--muted); }

@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; position: relative; }
  .mail-row { grid-template-columns: 1fr; }
  .compose-grid { grid-template-columns: 1fr; }
  .main { padding: 22px; }
}
