/* S4, N2: one column on a phone, a sidebar on a wide screen; system font; light and dark. */
:root {
  --bg: #f4f5f3;
  --panel: #ffffff;
  --ink: #1b1f1c;
  --muted: #5d655f;
  --line: #d9ddd9;
  --nav: #23302a;
  --nav-ink: #e9ede9;
  --nav-active: #3a4c42;
  --accent: #2f7d5b;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --warn-bg: #fff4e0;
  --warn-ink: #7a4b00;
  --err-bg: #fdecea;
  --err-ink: #8b1a12;
  --ok-bg: #e7f4ec;
  --ok-ink: #1d5a3c;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131614;
    --panel: #1c211e;
    --ink: #e8ece9;
    --muted: #9aa39d;
    --line: #2f3632;
    --nav: #0e1210;
    --nav-ink: #d6dcd7;
    --nav-active: #2a3a31;
    --accent: #4fb182;
    --accent-ink: #0b1a12;
    --warn-bg: #3a2b0a;
    --warn-ink: #ffd58a;
    --err-bg: #3b1512;
    --err-ink: #ffb4ad;
    --ok-bg: #12301f;
    --ok-ink: #9fe0bd;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; max-width: 100%; overflow-x: hidden; }
body { min-height: 100dvh; display: grid; grid-template-rows: auto auto auto 1fr; }

/* The header wraps: on a narrow phone the buttons drop to a second line rather than push the
   page wider than the screen. */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 12px 16px; background: var(--nav); color: var(--nav-ink); }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 auto; }
.title { font-weight: 700; font-size: 18px; }
.actions { margin-left: auto; }
.target { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--nav-active); text-transform: uppercase; letter-spacing: .04em; }
.actions { display: flex; gap: 8px; }

.nav { display: flex; gap: 4px; padding: 6px 8px; background: var(--nav); position: sticky; bottom: 0; }
.nav a { flex: 1; text-align: center; padding: 10px 6px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; font-weight: 600; font-size: 15px; }
.nav a.active { background: var(--nav-active); }

.message { margin: 12px 16px 0; padding: 10px 14px; border-radius: 8px; font-size: 15px; }
.message.ok { background: var(--ok-bg); color: var(--ok-ink); }
.message.warn { background: var(--warn-bg); color: var(--warn-ink); }
.message.error { background: var(--err-bg); color: var(--err-ink); }

main { padding: 12px 16px 24px; display: grid; gap: 12px; align-content: start; }
h1 { font-size: 22px; margin: 4px 0 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.card[hidden] { display: none; }
.card h2 { font-size: 16px; margin: 0; color: var(--muted); font-weight: 600; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row > * { min-width: 0; }
main, .card { min-width: 0; }
.row .label { color: var(--muted); }
.state { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 14px; text-transform: capitalize; }
.state.down { background: var(--line); }
.state.starting, .state.stopping { background: var(--warn-bg); color: var(--warn-ink); }
.state.up { background: var(--ok-bg); color: var(--ok-ink); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; word-break: break-all; }
.muted { color: var(--muted); font-size: 14px; }

button { font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; min-height: 44px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.danger { color: var(--danger); }
button:disabled { opacity: .45; cursor: default; }
button.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); min-height: 44px; width: 100%; }
form.inline { display: flex; gap: 8px; }
form.inline input { flex: 1; min-width: 0; }
ul.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
ul.list li:first-child { border-top: 0; }

@media (min-width: 800px) {
  body { grid-template-columns: 220px 1fr; grid-template-rows: auto auto 1fr; }
  .top { grid-column: 1 / -1; }
  .nav { grid-row: 2 / span 2; flex-direction: column; justify-content: flex-start; padding: 12px 10px; position: static; }
  .nav a { flex: 0; text-align: left; padding: 12px 14px; }
  .message { grid-column: 2; }
  main { grid-column: 2; max-width: 900px; }
}

/* F6: mail. The list is tappable lines, the message is its text as text. */
.mail-link { display: flex; flex-direction: column; gap: 0.15rem; text-decoration: none; color: inherit; width: 100%; }
.mail-subject { font-weight: 600; }
.mail-text { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0.5rem 0; }
