/* ---------- theme ---------- */
/* Dark is the default. The toggle sets data-theme="light" on <html>. */
:root {
  --bg: #14101f;
  --bg-2: #1b1530;
  --panel: #1d1830;
  --panel-2: #262040;
  --line: #342c55;
  --text: #ece9f5;
  --muted: #9a92b8;
  --accent: #8b7bf0;
  --accent-2: #b28cf5;
  --accent-ink: #fff;
  --good: #47d39a;
  --bad: #ff6b6b;
  --warn: #ffb648;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

:root[data-theme="light"] {
  --bg: #f4f2fa;
  --bg-2: #ece8f7;
  --panel: #fff;
  --panel-2: #f2eff9;
  --line: #ded7ee;
  --text: #191428;
  --muted: #655d80;
  --accent: #6c5ce7;
  --accent-2: #8b5cf6;
  --good: #14a06b;
  --shadow: 0 2px 10px rgba(80, 60, 140, .10);
}

* { box-sizing: border-box; }

/* Several rules set display:flex, which would otherwise beat the UA
   stylesheet's rule for the `hidden` attribute. Keep `hidden` authoritative. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 16px 48px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.view { max-width: 760px; margin: 0 auto; }
.centered { display: flex; min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: center; }

/* Login fills the screen: full-bleed, so cancel the body's side padding. */
#login-view {
  /* full-bleed: cancel both the body's side padding and .view's max-width */
  max-width: none;
  margin: 0 -16px;
  padding: 0;
  width: calc(100% + 32px);
}

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 1; }
.brand .mark { border-radius: 8px; flex: none; display: block; }
.brand .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: Pacifico, "Snell Roundhand", "Brush Script MT", cursive;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: .2px;
  background: linear-gradient(100deg, var(--accent) 0%, var(--accent-2) 60%, #e3a7ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 2px;
}
.brand-btn { background: none; border: 0; padding: 0; cursor: pointer; }
/* login lockup: icon on the left, name in two lines beside it */
.brand-lg {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}
.brand-lg .mark {
  width: 90px; height: 90px; border-radius: 21px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.brand-lg .name {
  font-size: 30px;
  line-height: 1.12;
  white-space: normal;
  text-align: left;
  overflow: visible;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 16px 2px 12px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }

/* ---------- cards & forms ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  box-shadow: var(--shadow);
}
.centered .card { max-width: 380px; }
.card h1 { font-size: 19px; margin: 0 0 4px; }

/* Login: an animated nav strip on top, then the photo filling everything
   below it. `.centered .login-card` beats `.centered .card`'s max-width,
   which is declared just above this. */
.centered .login-card { max-width: none; }
.login-card {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  gap: 0;
  display: flex;
  flex-direction: column;
}

/* ---- the nav strip ---- */
.login-nav {
  position: relative;
  overflow: hidden;
  flex: none;
  padding: calc(20px + env(safe-area-inset-top)) 22px 20px;
  background: #170f2b;
  border-bottom: 1px solid rgba(178, 140, 245, .28);
}
/* drifting aurora */
.login-nav::before {
  content: "";
  position: absolute;
  inset: -60%;
  background:
    radial-gradient(38% 55% at 20% 40%, rgba(139, 123, 240, .60), transparent 62%),
    radial-gradient(34% 50% at 72% 58%, rgba(226, 120, 255, .50), transparent 62%),
    radial-gradient(42% 58% at 48% 18%, rgba(78, 196, 255, .38), transparent 66%),
    radial-gradient(30% 45% at 88% 25%, rgba(255, 190, 120, .26), transparent 64%);
  filter: blur(14px);
  animation: aurora 22s ease-in-out infinite alternate;
  will-change: transform;
}
/* twinkling stars */
.login-nav::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.6px 1.6px at 8% 28%, #fff, transparent 60%),
    radial-gradient(1.2px 1.2px at 19% 68%, #ffe9b8, transparent 60%),
    radial-gradient(1.7px 1.7px at 33% 22%, #fff, transparent 60%),
    radial-gradient(1.1px 1.1px at 46% 74%, #cfe6ff, transparent 60%),
    radial-gradient(1.5px 1.5px at 58% 34%, #fff, transparent 60%),
    radial-gradient(1.2px 1.2px at 69% 66%, #f3d6ff, transparent 60%),
    radial-gradient(1.8px 1.8px at 81% 26%, #fff, transparent 60%),
    radial-gradient(1.1px 1.1px at 92% 60%, #cfe6ff, transparent 60%),
    radial-gradient(1.3px 1.3px at 27% 48%, #fff, transparent 60%),
    radial-gradient(1.4px 1.4px at 63% 12%, #fff, transparent 60%);
  animation: twinkle 5.5s ease-in-out infinite alternate;
}
.login-nav .brand { position: relative; z-index: 1; }

@keyframes aurora {
  0%   { transform: translate3d(-5%, -3%, 0) rotate(0deg)  scale(1.05); }
  50%  { transform: translate3d(5%, 3%, 0)   rotate(7deg)  scale(1.18); }
  100% { transform: translate3d(-2%, 4%, 0)  rotate(-6deg) scale(1.10); }
}
@keyframes twinkle {
  0%   { opacity: .35; }
  50%  { opacity: .95; }
  100% { opacity: .5; }
}
/* Respect people who ask for less motion -- keep the look, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  .login-nav::before, .login-nav::after { animation: none; }
}

/* ---- the photo area below the nav ---- */
.login-body {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  padding: 24px 22px calc(26px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.login-body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("dachshund.jpg") center 30% / cover no-repeat;
}
/* scrim: light at the top so the dog reads, heavier behind the fields */
.login-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(20, 16, 31, .10) 0%,
    rgba(20, 16, 31, .28) 42%,
    rgba(20, 16, 31, .82) 78%,
    rgba(20, 16, 31, .93) 100%
  );
}
:root[data-theme="light"] .login-body::after {
  background: linear-gradient(
    180deg,
    rgba(244, 242, 250, .12) 0%,
    rgba(244, 242, 250, .34) 42%,
    rgba(244, 242, 250, .86) 78%,
    rgba(244, 242, 250, .95) 100%
  );
}

.login-fields {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}
.login-nav .brand-lg { max-width: 460px; margin: 0 auto; }

/* fields need a touch more body over a photo */
.login-card input {
  background: color-mix(in srgb, var(--panel-2) 90%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.login-card label { color: var(--text); font-weight: 500; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input[type=text], input[type=email], input[type=password], input[type=number] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 11px 12px;
  width: 100%;
  /* 16px stops iOS Safari zooming the page when a field is focused.
     Anything smaller and mobile jumps in every time you tap an input. */
  font-size: 16px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input::placeholder { color: var(--muted); opacity: .75; }

.row { display: flex; gap: 12px; }
.row > label { flex: 1; min-width: 0; }
.lbl { white-space: nowrap; }

button { font: inherit; cursor: pointer; border-radius: 9px; }
button:disabled { opacity: .55; cursor: not-allowed; }

.primary {
  background: linear-gradient(100deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--accent-ink);
  border: 0; padding: 12px 16px; font-weight: 600; font-size: 15px;
}
.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); padding: 8px 14px;
}
.link { background: none; border: 0; color: var(--accent-2); padding: 4px; font-size: 13px; }
.btn-sm {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; padding: 5px 11px; border-radius: 7px; white-space: nowrap; line-height: 1.2;
}
.btn-sm:hover { border-color: var(--accent); color: var(--text); }

.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-2); }
:root[data-theme="dark"] .i-sun, :root:not([data-theme="light"]) .i-sun { display: block; }
:root[data-theme="dark"] .i-moon, :root:not([data-theme="light"]) .i-moon { display: none; }
:root[data-theme="light"] .i-sun { display: none; }
:root[data-theme="light"] .i-moon { display: block; }

.segmented { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg { flex: 1; background: none; border: 0; color: var(--muted); padding: 10px; font-weight: 600; font-size: 14px; }
.seg.active {
  background: linear-gradient(100deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--accent-ink);
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--bad); font-size: 13px; margin: 0; }

.checkline { flex-direction: row; align-items: center; gap: 9px; font-size: 14px; color: var(--text); }
.checkline input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.checkline span { color: var(--muted); }

/* clearable number fields */
.clearable { position: relative; display: block; }
.clearable input { padding-right: 36px; }
.clearable input::-webkit-outer-spin-button,
.clearable input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.clearable input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.clear {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; line-height: 1; font-size: 15px;
  border: 0; background: var(--line); color: var(--text);
  border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0;
}
.clear:hover { background: var(--bad); color: #fff; }

.status {
  margin: 14px 0 0; padding: 12px 14px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; background: var(--panel); font-size: 13.5px;
}
.status.bad { border-left-color: var(--bad); }
.status.warn { border-left-color: var(--warn); }

/* ---------- results ---------- */
.results-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 2px 8px; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }

.result {
  display: block;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px;
  box-shadow: var(--shadow);
}
.result .body { min-width: 0; }
/* the sub-line and the add button share a row */
.result .subrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 6px;
}
.result .subrow .sub { min-width: 0; font-size: 12.5px; color: var(--muted); }
.result .name { font-size: 14px; line-height: 1.4; word-break: break-word; }
.result .meta {
  margin-top: 6px; font-size: 12.5px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
}
.seed { color: var(--good); font-weight: 600; }
.badge {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; font-size: 11px;
}
.badge.free { color: var(--good); border-color: var(--good); }

/* add button: a pill with a word and an icon */
.add {
  flex: none; height: 38px; border-radius: 19px;
  border: 0; padding: 0 15px; gap: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 2px 8px rgba(139, 123, 240, .35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.add:hover:not(:disabled) { transform: scale(1.07); }
.add:active:not(:disabled) { transform: scale(.95); }
.add svg { display: block; flex: none; }
.add .w { line-height: 1; }
.add.busy { background: var(--panel-2); color: var(--muted); box-shadow: none; }
.add.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.add.done {
  background: none; color: var(--good);
  border: 1.5px solid var(--good); box-shadow: none; cursor: default;
}
.add.failed { background: none; color: var(--bad); border: 1.5px solid var(--bad); box-shadow: none; }

.row-note { margin-top: 6px; font-size: 12px; }
.row-note.ok { color: var(--good); }
.row-note.bad { color: var(--bad); }
.row-note.warn { color: var(--warn); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0 8px; }

/* IPT status: a dot plus a label, where the label drops out on narrow screens */
.ipt-pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ipt-pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.ipt-pill.connected .dot { background: var(--good); box-shadow: 0 0 6px var(--good); }
.ipt-pill.disconnected .dot { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.ipt-pill.connected { color: var(--good); }
.ipt-pill.disconnected { color: var(--warn); }

@media (max-width: 560px) {
  .row { flex-direction: column; }
  .topbar { padding-top: 12px; gap: 8px; flex-wrap: nowrap; }
  .topbar-right { gap: 10px; flex: none; }
  .brand { min-width: 0; }
  .brand .name { font-size: 16px; }
  .brand .mark { width: 24px; height: 24px; }
  .brand-lg .name { font-size: 26px; }
  .brand-lg .mark { width: 108px; height: 108px; border-radius: 25px; }
  .link { font-size: 12.5px; white-space: nowrap; padding: 2px; }
  .btn-sm { font-size: 11.5px; padding: 4px 9px; }
  .icon-btn { width: 28px; height: 28px; }
  /* the coloured dot says it instead */
  .ipt-pill .txt { display: none; }
}
