/* VibeStack Account - the whole stylesheet.
 *
 * The shared VibeStack look (the same tokens as VibeStack Dev and VibeStack Host): Inter served from
 * /assets/fonts (nothing is loaded from elsewhere), a top bar, rounded cards with a soft shadow,
 * pills, buttons, forms with a focus ring and coloured messages. Light mode is Catppuccin Latte, dark
 * mode is Tokyo Night; the page follows the computer's own setting (prefers-color-scheme), so there
 * is no theme switch. Tables turn into stacked cards on a narrow screen. The patterns that later
 * pages must reuse are listed in docs/PRODUCT.md, "Shared UI patterns".
 */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* Catppuccin Latte, Dev's light theme */
  --bg: #eff1f5;
  --surface: #ffffff;
  --surface-sunken: #e6e9ef;
  --text: #4c4f69;
  --muted: #5c5f77;
  --border: #ccd0da;
  --border-strong: #b4b9c8;
  --accent: #8839ef;
  --accent-text: #7a2fd8;
  --on-accent: #ffffff;
  --good: #40a02b;
  --good-text: #2b7a1a;
  --bad: #d20f39;
  --bad-text: #bf0d35;
  --warn: #df8e1d;
  --warn-text: #8a5300;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-small: 8px;
  --gap: 20px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 6px 18px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.1), 0 10px 26px rgba(0, 0, 0, 0.1);

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Tokyo Night, Dev's dark theme */
    --bg: #1a1b26;
    --surface: #1f2335;
    --surface-sunken: #24283b;
    --text: #c0caf5;
    --muted: #959dcb;
    --border: #2f3549;
    --border-strong: #414868;
    --accent: #7aa2f7;
    --accent-text: #7aa2f7;
    --on-accent: #1a1b26;
    --good: #9ece6a;
    --good-text: #9ece6a;
    --bad: #f7768e;
    --bad-text: #f7768e;
    --warn: #e0af68;
    --warn-text: #e0af68;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 10px 26px rgba(0, 0, 0, 0.3);
  }
}

:root {
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --success-soft: color-mix(in srgb, var(--good) 12%, var(--surface));
  --danger-soft: color-mix(in srgb, var(--bad) 12%, var(--surface));
  --warning-soft: color-mix(in srgb, var(--warn) 14%, var(--surface));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

code,
pre,
kbd {
  font-family: var(--mono);
}

a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

main:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
}

/* ---------------------------------------------------------------- top bar -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  transform: rotate(45deg);
  font-size: 0;
}

.nav {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-small);
}

.nav a:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

.nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-sunken);
  font-weight: 600;
}

/* The user menu: it opens on hover and on keyboard focus (and closes on Escape: app.js). */
.user-menu {
  position: relative;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.user-button:hover,
.user-menu:focus-within .user-button {
  background: var(--surface-sunken);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
}

.caret {
  color: var(--muted);
  font-size: 11px;
}

.user-menu .menu {
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 190px;
  padding: 6px;
  margin-top: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.12s, transform 0.12s, visibility 0.12s;
}

/* A small bridge, so the menu stays open while the mouse moves down to it. */
.user-menu .menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}

.user-menu:hover .menu,
.user-menu:focus-within .menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.user-menu.is-dismissed .menu {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
}

.user-menu .menu a,
.user-menu .menu button.link {
  display: flex;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-small);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.user-menu .menu a:hover,
.user-menu .menu button.link:hover {
  background: var(--surface-sunken);
}

.user-menu .menu form {
  margin: 4px 0 0;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* ----------------------------------------------------------------- layout -- */

.container {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-head .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lede {
  color: var(--muted);
  margin: 0 0 28px;
  max-width: 62ch;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}

h3 {
  font-size: 0.95rem;
  margin: 0 0 6px;
}

.section {
  margin: 0 0 28px;
}

.section h2 + .hint,
.section h2 + p {
  margin-top: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
  max-width: 68ch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 16px;
}

.card.tight {
  padding: 16px 18px;
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.empty .actions {
  margin-top: 18px;
  justify-content: center;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

@media (max-width: 780px) {
  .split {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ facts -- */

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: 10px 20px;
}

.facts dt {
  color: var(--muted);
  font-size: 0.9rem;
  padding-top: 1px;
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .facts {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .facts dd {
    margin-bottom: 12px;
  }
}

.mono {
  font-family: var(--mono);
  font-size: 0.86rem;
}

.key {
  display: block;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 12rem;
  overflow: auto;
}

/* ----------------------------------------------------------------- tables -- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.table caption {
  text-align: left;
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 10px;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-sunken);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table .nowrap {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table thead {
    display: none;
  }

  .table tr {
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
  }

  .table tr:last-child {
    border-bottom: 0;
  }

  .table td {
    border: 0;
    display: flex;
    gap: 14px;
    padding: 6px 16px;
  }

  .table td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    color: var(--muted);
    font-size: 0.85rem;
  }
}

/* ---------------------------------------------------------------- badges --- */

/* A state word as a pill with a dot: green is up, red is down, amber is moving or running,
   grey is idle, the accent colour marks a pass-through. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface-sunken);
  color: var(--muted);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.badge.is-up {
  background: var(--success-soft);
  color: var(--good-text);
}

.badge.is-down {
  background: var(--danger-soft);
  color: var(--bad-text);
}

.badge.is-idle {
  background: var(--surface-sunken);
  color: var(--muted);
}

.badge.is-moving {
  background: var(--warning-soft);
  color: var(--warn-text);
}

.badge.accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* --------------------------------------------------------------- messages -- */

.message {
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.message.ok {
  background: var(--success-soft);
  border-color: transparent;
  color: var(--good-text);
}

.message.error {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--bad-text);
}

.message.warning {
  background: var(--warning-soft);
  border-color: transparent;
  color: var(--warn-text);
}

.message p {
  margin: 0;
}

.message .note {
  color: inherit;
}

.message .card {
  color: var(--text);
}

.message .card .note {
  color: var(--muted);
}

.message p + p {
  margin-top: 6px;
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
}

.note strong {
  color: var(--text);
}

.mt-2 {
  margin-top: 14px;
}

.mt-3 {
  margin-top: 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------- buttons --- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-small);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s, border-color 0.15s;
}

.button:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.button.primary:hover {
  color: var(--on-accent);
  filter: brightness(1.08);
}

/* What undoes or removes something: red outline and red text, not filled. */
.button.danger-outline {
  background: transparent;
  border-color: var(--bad);
  color: var(--bad-text);
}

.button.danger-outline:hover {
  background: var(--danger-soft);
  border-color: var(--bad);
  color: var(--bad-text);
}

.button.danger {
  background: var(--bad);
  border-color: var(--bad);
  color: var(--on-accent);
}

.button.danger:hover {
  color: var(--on-accent);
  filter: brightness(1.08);
}

.button.small {
  padding: 5px 10px;
  font-size: 0.88rem;
}

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button[disabled]:hover {
  border-color: var(--border-strong);
  color: var(--text);
  filter: none;
}

.button.primary[disabled]:hover {
  border-color: var(--accent);
  color: var(--on-accent);
}

.button.danger-outline[disabled]:hover {
  background: transparent;
  border-color: var(--bad);
  color: var(--bad-text);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ----------------------------------------------------------------- forms --- */

.form {
  display: grid;
  gap: 16px;
  max-width: 34rem;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 600;
  font-size: 0.92rem;
}

.field .help {
  color: var(--muted);
  font-size: 0.85rem;
}

.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field textarea {
  font-family: var(--mono);
  font-size: 0.86rem;
  min-height: 6rem;
  resize: vertical;
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: var(--surface-sunken);
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 16px;
}

/* A field whose value has a fixed part after it, like the domain of a subdomain:
   the box takes the room and the part that is not typed sits beside it. */
.field-row.subdomain {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-row.subdomain input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.field-row.subdomain .suffix {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  white-space: nowrap;
}

.form .actions {
  margin-top: 4px;
}

/* ---------------------------------------------------------------- footer --- */

.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 18px 20px;
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}

/* ---------------------------------------------------------------- narrow --- */

/* The sign-in page: one rounded card in the middle of the page. */
.card.auth {
  max-width: 28rem;
  margin: 8vh auto 0;
}

.auth-note {
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 600px) {
  .user-name {
    display: none;
  }

  .user-button {
    padding-right: 8px;
  }
}

@media (max-width: 560px) {
  .container {
    padding: 22px 16px 44px;
  }

  .topbar-inner {
    padding: 12px 16px;
  }

  .card {
    padding: 18px 16px;
  }

  .page-head h1 {
    font-size: 1.35rem;
  }

  .page-head .actions {
    margin-left: 0;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }

  .button:active {
    transform: none;
  }
}

/* The suite list on the start page: one line per product. */
.suite {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.suite li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.suite strong {
  min-width: 9rem;
}

/* Long addresses, keys and paths wrap instead of making the page scroll sideways. */
.mono,
.table td,
.message,
.hint,
.note {
  overflow-wrap: anywhere;
}

/* Backup codes and the QR code (My account). */
.codes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 8px;
}

.codes li {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 8px 12px;
}

.qr {
  background: #fff;
  padding: 8px;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
}

/* The second row of links in the admin area, and the search box above a list. */
.subnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 8px 0 20px;
  border-bottom: 1px solid var(--border);
}

.subnav a {
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav a:hover {
  color: var(--text);
}

.subnav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.searchbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 16px;
}

.searchbar .field {
  flex: 1 1 14rem;
}

.table form {
  margin: 0;
}

.inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
