/* ============================================================
   aft.page — app / dashboard chrome (docs/BRAND.md)
   Same black/white tokens as styles.css.
   ============================================================ */

:root {
  color-scheme: dark;
  --void: #000000;
  --panel: #0a0a0a;
  --line: #27272a;
  --line-bright: #3f3f46;
  --ink: #fafafa;
  --quiet: #a1a1aa;
  --faint: #52525b;

  --cta: #ffffff;
  --cta-ink: #000000;
  --cta-hover: #e4e4e7;

  --beacon: var(--cta);
  --beacon-deep: var(--cta-hover);
  --beacon-bright: #22c55e;
  --beacon-dim: color-mix(in srgb, var(--ink) 8%, transparent);
  --beacon-ink: var(--cta-ink);

  --good: #22c55e;
  --warn: #eab308;
  --danger: #ff6b6b;
  --ok: var(--good);
  --err: var(--danger);
  --live: var(--good);

  --bg: var(--void);
  --bg-raised: var(--panel);
  --bg-inset: #050505;

  --font-sans: "Geist Variable", "Geist", "Segoe UI", system-ui, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "Geist Mono Variable", "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --page: 1180px;
  --page-gutter: 2.5rem;
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--void);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

code {
  font-family: var(--font-mono);
  font-size: 0.82em;
}

/* —— App header (quiet product rail) —— */
header.app-header,
body > header {
  display: block;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: var(--void);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(var(--page), calc(100% - var(--page-gutter)));
  margin: 0 auto;
  padding: 1.35rem clamp(1.25rem, 3vw, 2.25rem);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.app-brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.app-brand-wrap > a,
.app-brand {
  color: inherit;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.app-brand-wrap > a span,
.app-brand span {
  color: var(--good);
  font-family: var(--font-sans);
  font-weight: 600;
}

.nav-beta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--quiet);
  border: 1px solid var(--line);
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}

header .nav-right {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.4rem;
  font-size: 0.92rem;
  align-items: center;
}

header .nav-right a {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--quiet);
  text-decoration: none;
}

header .nav-right a:hover {
  color: var(--ink);
}

header .nav-right a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

header .nav-right a.app-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.95rem;
  border-radius: 0.5rem;
  background: var(--cta);
  border: 1px solid var(--cta);
  color: var(--cta-ink);
  font-size: 0.88rem;
  font-weight: 600;
}

header .nav-right a.app-cta:hover {
  background: var(--cta-hover);
  border-color: var(--cta-hover);
  color: var(--cta-ink);
}

main.app-main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

h1 {
  font-family: var(--font-sans);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.sub,
.crumb {
  color: var(--quiet);
  font-size: 0.95rem;
}

.crumb {
  font-size: 0.82rem;
  margin: 0 0 0.85rem;
}

.crumb a {
  color: var(--quiet);
  text-decoration: none;
}

.crumb a:hover {
  color: var(--ink);
}

/* —— Buttons —— */
a.btn,
button.btn,
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--beacon-ink);
  background: var(--beacon);
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.12s ease, transform 0.12s ease;
}

a.btn:hover,
button.btn:hover:not(:disabled),
.btn:hover:not(:disabled) {
  background: var(--cta-hover);
  border-color: var(--cta-hover);
}

a.btn:active,
button.btn:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: scale(0.98);
}

a.btn.ghost,
button.btn.ghost,
a.btn.btn-ghost,
button.btn.btn-ghost,
.btn.ghost,
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-bright);
}

a.btn.ghost:hover,
button.btn.ghost:hover:not(:disabled),
a.btn.btn-ghost:hover:not(:disabled),
button.btn.btn-ghost:hover:not(:disabled),
.btn.ghost:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  border-color: var(--beacon);
  background: transparent;
}

a.btn.btn-primary,
button.btn.btn-primary,
.btn-primary {
  background: var(--beacon);
  border-color: var(--beacon);
  color: var(--beacon-ink);
}

a.btn.btn-claim,
button.btn.btn-claim,
.btn-claim {
  background: var(--beacon);
  border-color: var(--beacon);
  color: var(--beacon-ink);
}

a.btn.btn-claim:hover,
button.btn.btn-claim:hover:not(:disabled),
.btn-claim:hover:not(:disabled) {
  background: var(--cta-hover);
  border-color: var(--cta-hover);
}

button.btn:disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

a.primary,
.login a.primary,
.denied a.primary,
.missing a.primary {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.45rem 0.85rem;
  border-radius: 0.5rem;
  background: var(--beacon);
  color: var(--beacon-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

a.primary:hover,
.login a.primary:hover {
  background: var(--cta-hover);
}

/* —— Forms —— */
.field {
  margin-bottom: 1.15rem;
}

.field label,
.field .label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--quiet);
  font-weight: 600;
  margin: 0 0 0.45rem;
}

.field .hint {
  font-size: 0.8rem;
  color: var(--quiet);
  margin: 0.4rem 0 0;
}

.field input[type="text"],
.field input[type="email"],
.field textarea,
.invite-form input,
.invite-form select,
input[type="text"],
input[type="email"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-family: var(--font-sans);
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  background: var(--bg-inset);
  color: var(--ink);
}

.field input:focus,
.field textarea:focus,
.invite-form input:focus,
.invite-form select:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--beacon);
  box-shadow: 0 0 0 3px var(--beacon-dim);
}

.field textarea {
  min-height: 12rem;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* —— Segmented control —— */
.seg,
.view-toggle,
.visibility-toggle {
  display: inline-flex;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-inset);
  padding: 0.15rem;
  gap: 0.1rem;
}

.seg button,
.view-toggle button,
.visibility-toggle button {
  font: inherit;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
}

.seg button[aria-pressed="true"],
.view-toggle button[aria-pressed="true"],
.visibility-toggle button[aria-pressed="true"] {
  background: var(--beacon);
  color: var(--beacon-ink);
}

/* —— Pills —— */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line-bright);
  font-weight: 600;
}

.pill.private {
  border-color: var(--beacon);
  color: var(--beacon-bright);
}

.pill.current {
  border-color: var(--good);
  color: var(--good);
}

/* —— Tables —— */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--quiet);
  font-weight: 550;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* —— Empty / login / loading —— */
.empty,
.login,
.loading,
.denied,
.missing {
  border: 1px dashed var(--line-bright);
  padding: 1.25rem;
  border-radius: 0.5rem;
  color: var(--quiet);
}

.loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-style: solid;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

.spinner {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  border: 2px solid var(--ink);
  border-right-color: transparent;
  animation: app-spin 0.65s linear infinite;
  flex-shrink: 0;
}

.skeleton-list {
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
}

.skeleton-row {
  height: 2.6rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--ink) 4%, transparent) 0%,
    color-mix(in srgb, var(--ink) 10%, transparent) 50%,
    color-mix(in srgb, var(--ink) 4%, transparent) 100%
  );
  background-size: 200% 100%;
  animation: app-shimmer 1.1s ease-in-out infinite;
}

/* —— Menus —— */
.menu {
  position: relative;
  display: inline-flex;
}

.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 0.5rem;
  border: 1px solid var(--line-bright);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.menu-btn:hover,
.menu-btn[aria-expanded="true"] {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.menu-panel {
  position: fixed;
  min-width: 10rem;
  background: #18181b;
  border: 1px solid var(--line-bright);
  border-radius: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75);
  padding: 0.3rem;
  z-index: 10000;
  display: none;
}

.menu-panel.open {
  display: block;
}

.menu-panel a {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 550;
}

.menu-panel a:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

/* —— Panels / messages —— */
.panel {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 1rem 1.05rem 1.1rem;
  margin-bottom: 1rem;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  animation: app-fade-up 0.3s ease both;
}

.panel h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--quiet);
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.msg {
  margin-top: 0.65rem;
  font-size: 0.85rem;
  color: var(--quiet);
}

.msg.ok {
  color: var(--good);
}

.msg.err {
  color: var(--danger);
}

.msg.pending {
  color: var(--quiet);
}

.fade-in {
  animation: app-fade-up 0.3s ease both;
}

@keyframes app-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes app-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes app-fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 640px) {
  .app-header-inner {
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
  }

  header .nav-right {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .skeleton-row,
  tbody tr,
  .who,
  .fade-in,
  a.btn,
  button.btn,
  .btn,
  .panel {
    animation: none !important;
    transition: none !important;
    opacity: 1;
    transform: none;
  }
}
