:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #626a78;
  --line: #dfe3ea;
  --accent: #5b3df5;
  --accent-text: #ffffff;
  --live: #0b7a3b;
  --live-bg: #dcf5e6;
  --pending: #8a5a00;
  --pending-bg: #fdefc8;
  --problem: #b3261e;
  --problem-bg: #fde4e1;
  --off: #535b69;
  --off-bg: #e8ebf0;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #e9ebf0;
    --muted: #9aa3b2;
    --line: #2a2f39;
    --accent: #8f7bff;
    --accent-text: #0f1115;
    --live: #5fe39a;
    --live-bg: #12351f;
    --pending: #f6c860;
    --pending-bg: #3a2c08;
    --problem: #ff8e86;
    --problem-bg: #43160f;
    --off: #a4acba;
    --off-bg: #252a33;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.account { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.account form { margin: 0; }
.email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card > h2 { margin-bottom: 0.75rem; }
.card.narrow { max-width: 24rem; margin: 2rem auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }

.hero { padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 36rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.points { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.points p { color: var(--muted); margin: 0.35rem 0 0; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.9rem 0 0.3rem; }

input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, .button {
  display: inline-block;
  padding: 0.6rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}
.button.secondary, button.small {
  color: var(--text);
  background: transparent;
  border-color: var(--line);
}
button.small { padding: 0.3rem 0.65rem; font-size: 0.85rem; font-weight: 500; }
button.link {
  padding: 0;
  color: var(--accent);
  background: none;
  border: 0;
  font-weight: 500;
  text-decoration: underline;
}
button.danger, button.link.danger { color: var(--problem); }
form > button[type="submit"]:not(.link):not(.small) { margin-top: 1.1rem; }

.hint, .switch, .detail, .server, .count, .empty { color: var(--muted); font-size: 0.9rem; }
.hint { margin: 0.5rem 0; }
.detail { overflow-wrap: anywhere; }

.error {
  margin: 0 0 0.5rem;
  padding: 0.6rem 0.75rem;
  color: var(--problem);
  background: var(--problem-bg);
  border-radius: 8px;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.live { color: var(--live); background: var(--live-bg); }
.badge.pending { color: var(--pending); background: var(--pending-bg); }
.badge.problem { color: var(--problem); background: var(--problem-bg); }
.badge.off { color: var(--off); background: var(--off-bg); }

code {
  font: 0.9rem/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}

.settings { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1rem; margin: 0.75rem 0; }
.settings dt { font-weight: 600; }
.settings dd { margin: 0; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.6rem; min-width: 0; }
.secret summary { cursor: pointer; color: var(--accent); }
.secret[open] summary { margin-bottom: 0.25rem; }
form.inline { margin: 0.25rem 0; }

.destinations { list-style: none; margin: 0; padding: 0; }
.destinations li {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr) auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}
.destinations li:first-child { border-top: 0; }
.who, .state { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.who strong { overflow-wrap: anywhere; }
.state { align-items: flex-start; }
.controls { display: flex; gap: 0.4rem; }
.controls form { margin: 0; }

.add { display: grid; gap: 0 1rem; grid-template-columns: 1fr 1fr; }
.add > div:nth-of-type(3), .add > button { grid-column: 1 / -1; }
.add > button { justify-self: start; }

@media (max-width: 40rem) {
  .destinations li { grid-template-columns: 1fr; }
  .add { grid-template-columns: 1fr; }
  .settings { grid-template-columns: 1fr; gap: 0.2rem; }
  .settings dd { margin-bottom: 0.6rem; }
}

.top nav { display: flex; gap: 1rem; margin-right: auto; margin-left: 1.5rem; }
.top nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.top nav a:hover { text-decoration: underline; }
header.top > nav:last-child { margin-right: 0; margin-left: auto; }

.plan-line { margin: 0.75rem 0 0; padding-top: 0.75rem; border-top: 1px solid var(--line); font-size: 0.9rem; color: var(--muted); }
.plan-line strong { color: var(--text); }

h3 { font-size: 1rem; margin: 0; }
.plans { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); margin: 0.75rem 0; }
.plan { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.plan.current { border-color: var(--accent); }
.plan p { margin: 0; }
.plan form { margin-top: auto; padding-top: 0.6rem; }
.price { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.per { font-size: 0.85rem; font-weight: 400; color: var(--muted); }

.orders { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.orders th, .orders td { text-align: left; padding: 0.5rem 0.75rem 0.5rem 0; border-top: 1px solid var(--line); vertical-align: top; }
.orders thead th { border-top: 0; color: var(--muted); font-weight: 600; }
.orders a { text-decoration: none; }

@media (max-width: 40rem) {
  .top { flex-wrap: wrap; }
  .top nav { margin-left: 0; }
  .orders th:first-child, .orders td:first-child { display: none; }
}
