/* Shell and shared components. Tokens come from tokens.css; page styles live in the page css
   files and are scoped under .page-<name>. The class vocabulary is listed in the foundation notes. */

/* ---------- utilities ---------- */

.muted { color: var(--muted-foreground); }
.text-xs { font-size: var(--text-xs); line-height: 1rem; }
.text-sm { font-size: var(--text-sm); line-height: 1.25rem; }
.text-destructive { color: var(--destructive); }
.text-accent { color: var(--accent-text); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.spacer { flex: 1; }
.stack { display: grid; gap: 0.75rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { font-size: var(--text-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.025em; color: var(--muted-foreground); }
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1rem; }
@media (min-width: 768px) { .container { padding-inline: 1.5rem; } }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-md);
}
.skip:focus { top: 0.5rem; }

/* ---------- shell ---------- */

.app-shell {
  position: relative; isolation: isolate; min-height: 100dvh; display: flex; flex-direction: column;
  background: color-mix(in oklab, var(--muted) 40%, var(--background));
}
.app-shell::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 31px, var(--grid-line) 31px, var(--grid-line) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, var(--grid-line) 31px, var(--grid-line) 32px);
  mask-image: radial-gradient(90% 75% at 50% 30%, #000 35%, transparent 100%);
}
.app-shell::after {
  content: ""; position: absolute; inset-inline: 0; top: 0; height: 42rem; z-index: -1; pointer-events: none;
  background-image: radial-gradient(55% 45% at 50% 32%, var(--glow), transparent 75%);
}

.site-header {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
  background: color-mix(in oklab, var(--background) 70%, transparent);
}
@supports (backdrop-filter: blur(1px)) {
  .site-header { background: color-mix(in oklab, var(--background) 60%, transparent); backdrop-filter: blur(var(--blur)); }
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; height: var(--header-height); }
.header-spacer { flex: 1; }
.brand { display: flex; align-items: center; border-radius: var(--radius-md); }
.brand img { height: 39.5pt; width: auto; }
.brand .logo-dark { display: none; }
html[data-theme="dark"] .brand .logo-light { display: none; }
html[data-theme="dark"] .brand .logo-dark { display: block; }
.header-nav { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 0.25rem; }
.nav-btn { gap: 0.375rem; border-radius: var(--radius-lg); color: var(--muted-foreground); }
.nav-btn:hover, .nav-btn[aria-current="page"], .nav-btn[aria-expanded="true"] { color: var(--foreground); }
.nav-btn[aria-current="page"], .nav-btn[aria-expanded="true"], .nav-btn[data-active="true"] { background: var(--accent); color: var(--foreground); }
.nav-signout { border-radius: var(--radius-full); color: var(--muted-foreground); }
.nav-signout:hover { color: var(--foreground); }
.nav-menu { position: relative; display: inline-flex; }
.nav-label { display: none; }
@media (min-width: 1024px) { .nav-label { display: inline; } }
@media (max-width: 767px) {
  .header-row { gap: 0.5rem; }
  .header-spacer { display: none; }
  .brand img { height: 2rem; }
  .header-nav { gap: 0; }
}

.site-main { flex: 1; outline: none; }
.page { outline: none; }
.page-narrow { width: 100%; max-width: 56rem; margin-inline: auto; padding: 2rem 1rem; }
.page-reader { width: 100%; max-width: 48rem; margin-inline: auto; padding: 2rem 1rem; }
.page-header { display: grid; gap: 0.25rem; margin-bottom: 1.5rem; }
.page-title { font-size: var(--text-2xl); line-height: 2rem; font-weight: 600; letter-spacing: -0.025em; outline: none; }
.page-lede { font-size: var(--text-sm); color: var(--muted-foreground); }
.section-title { font-size: var(--text-xl); line-height: 1.75rem; font-weight: 600; letter-spacing: -0.025em; }
.page-error { max-width: 40rem; margin: 3rem auto; padding-inline: 1rem; display: grid; gap: 1rem; }

.site-footer { border-top: 1px solid color-mix(in oklab, var(--border) 60%, transparent); }
.footer-inner {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem; padding-block: 0.75rem;
  text-align: center; font-size: var(--text-xs); color: var(--muted-foreground);
}

/* ---------- button ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; flex-shrink: 0;
  white-space: nowrap; border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: var(--text-sm); line-height: 1.25rem; font-weight: 500; text-decoration: none;
  height: 2.25rem; padding: 0.5rem 1rem; color: inherit; background: transparent;
  transition: all var(--duration) var(--ease); outline: none;
}
.btn:has(> svg) { padding-inline: 0.75rem; }
.btn svg { width: 1rem; height: 1rem; pointer-events: none; }
.btn:focus-visible { border-color: var(--ring); box-shadow: var(--ring-shadow); outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }
.btn[aria-invalid="true"] { border-color: var(--destructive); }

.btn-sm { height: 2rem; gap: 0.375rem; padding: 0.25rem 0.75rem; }
.btn-sm:has(> svg) { padding-inline: 0.625rem; }
.btn-lg { height: 2.5rem; padding-inline: 1.5rem; }
.btn-lg:has(> svg) { padding-inline: 1rem; }
.btn-icon, .btn-icon:has(> svg) { width: 2.25rem; height: 2.25rem; padding: 0; }
.btn-icon.btn-sm, .btn-icon.btn-sm:has(> svg) { width: 2rem; height: 2rem; padding: 0; }

.btn-default { background: var(--primary); color: var(--primary-foreground); }
.btn-default:hover { background: color-mix(in oklab, var(--primary) 90%, transparent); }
.btn-accent { background: var(--primary-accent); color: var(--primary-foreground); border-radius: var(--radius-lg); }
.btn-accent:hover { background: color-mix(in oklab, var(--primary-accent) 90%, transparent); }
html[data-theme="dark"] .btn-accent { color: var(--primary-accent-foreground); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary) 80%, transparent); }
.btn-outline { border-color: var(--border); background: var(--background); box-shadow: var(--shadow-xs); }
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }
html[data-theme="dark"] .btn-outline { background: color-mix(in oklab, var(--input) 30%, transparent); border-color: var(--input); }
html[data-theme="dark"] .btn-outline:hover { background: color-mix(in oklab, var(--input) 50%, transparent); }
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }
html[data-theme="dark"] .btn-ghost:hover { background: color-mix(in oklab, var(--accent) 50%, transparent); }
.btn-destructive { background: var(--destructive); color: #fff; }
.btn-destructive:hover { background: color-mix(in oklab, var(--destructive) 90%, transparent); }
.btn-destructive:focus-visible { box-shadow: 0 0 0 3px color-mix(in oklab, var(--destructive) 20%, transparent); }
html[data-theme="dark"] .btn-destructive { background: color-mix(in oklab, var(--destructive) 60%, transparent); }
.btn-link { color: var(--primary); }
.btn-link:hover { text-decoration: underline; }
.btn.text-destructive:hover { background: color-mix(in oklab, var(--destructive) 10%, transparent); color: var(--destructive); }
.btn-inline { height: auto; padding: 0 0.25rem; font-size: var(--text-xs); color: var(--accent-text); }
.btn-inline:hover { text-decoration: underline; }

.spinner { width: 1rem; height: 1rem; animation: spin 1s linear infinite; }

/* ---------- card, panel, alert ---------- */

.card {
  display: flex; flex-direction: column; gap: 1.5rem; padding-block: 1.5rem;
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}
.card-header { display: grid; gap: 0.375rem; padding-inline: 1.5rem; align-items: start; }
.card-header:has(.card-action) { grid-template-columns: 1fr auto; }
.card-action { grid-column: 2; grid-row: 1 / span 2; justify-self: end; }
.card-title { font-weight: 600; line-height: 1; }
.card-description { font-size: var(--text-sm); color: var(--muted-foreground); }
.card-content { padding-inline: 1.5rem; }
.card-footer { display: flex; align-items: center; padding-inline: 1.5rem; }

.panel {
  display: grid; gap: 0.75rem; padding: 1rem; background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}
.panel-title { font-size: var(--text-sm); font-weight: 600; }
.alert {
  display: grid; gap: 0.25rem; padding: 1rem; border-radius: var(--radius-xl);
  border: 1px solid color-mix(in oklab, var(--destructive) 50%, transparent);
  background: color-mix(in oklab, var(--destructive) 10%, transparent);
  font-size: var(--text-sm); color: var(--destructive);
}
.alert-info { border-color: var(--border); background: var(--card); color: var(--foreground); }
.empty-state { display: grid; justify-items: center; gap: 0.5rem; padding: 3rem 1rem; text-align: center; color: var(--muted-foreground); font-size: var(--text-sm); }

/* ---------- badge and chip ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 0.25rem; border-radius: var(--radius-full);
  padding: 0.125rem 0.5rem; font-size: var(--text-xs); line-height: 1rem; font-weight: 500;
  background: var(--muted); color: var(--muted-foreground); white-space: nowrap;
}
.badge-accent {
  gap: 0.375rem; padding: 0.25rem 0.75rem; color: var(--accent-text);
  border: 1px solid color-mix(in oklab, var(--primary-accent) 20%, transparent);
  background: color-mix(in oklab, var(--primary-accent) 5%, transparent);
}
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--foreground); }
.badge-success { background: color-mix(in oklab, var(--success) 14%, transparent); color: var(--success); }
.badge-warning { background: color-mix(in oklab, var(--warning) 16%, transparent); color: var(--warning); }
.badge-destructive { background: color-mix(in oklab, var(--destructive) 12%, transparent); color: var(--destructive); }

.chip {
  display: inline-flex; align-items: center; gap: 0.375rem; border-radius: var(--radius-full);
  border: 1px solid var(--border); padding: 0.375rem 0.75rem; font-size: var(--text-sm); line-height: 1.25rem;
  color: var(--muted-foreground); background: transparent; list-style: none;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}
button.chip:hover { border-color: color-mix(in oklab, var(--primary-accent) 40%, transparent); color: var(--foreground); }
.chip[aria-selected="true"], .chip[aria-pressed="true"] {
  border-color: var(--primary-accent); color: var(--accent-text);
  background: color-mix(in oklab, var(--primary-accent) 5%, transparent);
}
.chip:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; box-shadow: var(--accent-ring); }

/* ---------- inputs ---------- */

.input, .textarea, .select {
  width: 100%; min-width: 0; border: 1px solid var(--input); border-radius: var(--radius-md);
  background-color: transparent; box-shadow: var(--shadow-xs); font-size: var(--text-base);
  transition: color var(--duration) var(--ease), box-shadow var(--duration) var(--ease); outline: none;
}
.input { height: 2.25rem; padding: 0.25rem 0.75rem; }
.textarea { min-height: 4rem; padding: 0.5rem 0.75rem; field-sizing: content; resize: vertical; }
.select {
  height: 2.25rem; padding: 0.375rem 2rem 0.375rem 0.75rem; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted-foreground) 50%),
    linear-gradient(135deg, var(--muted-foreground) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select option { background: var(--popover); color: var(--popover-foreground); }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { border-color: var(--focus-ring); box-shadow: var(--ring-shadow); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--destructive); box-shadow: 0 0 0 3px color-mix(in oklab, var(--destructive) 20%, transparent);
}
.input:disabled, .textarea:disabled, .select:disabled { cursor: not-allowed; opacity: 0.5; }
html[data-theme="dark"] :is(.input, .textarea, .select) { background-color: color-mix(in oklab, var(--input) 30%, transparent); }
@media (min-width: 768px) { .input, .textarea, .select { font-size: var(--text-sm); } }

.field { display: grid; gap: 0.375rem; align-content: start; }
.label { font-size: var(--text-sm); font-weight: 500; line-height: 1.25rem; }
.hint { font-size: var(--text-xs); color: var(--muted-foreground); }
.field-error { font-size: var(--text-sm); color: var(--destructive); }
.checkbox { display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--text-sm); }
.checkbox input { width: 1rem; height: 1rem; accent-color: var(--primary-accent); }
.field-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }

/* ---------- tabs (role tablist, tab, tabpanel) ---------- */

.tabs { display: flex; flex-direction: column; gap: 0.5rem; }
.tab-list {
  display: inline-flex; align-items: center; width: fit-content; max-width: 100%; height: 2.25rem; padding: 3px;
  border-radius: var(--radius-lg); background: var(--muted); color: var(--muted-foreground); overflow-x: auto;
}
.tab {
  display: inline-flex; flex: 1; align-items: center; justify-content: center; gap: 0.375rem; height: 100%;
  padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; white-space: nowrap; color: var(--foreground); text-decoration: none;
  transition: color var(--duration) var(--ease), box-shadow var(--duration) var(--ease); outline: none;
}
.tab svg { width: 1rem; height: 1rem; }
.tab[aria-selected="true"] { background: var(--background); box-shadow: var(--shadow-sm); }
.tab:focus-visible { border-color: var(--ring); box-shadow: var(--ring-shadow); outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.tab:disabled { opacity: 0.5; pointer-events: none; }
html[data-theme="dark"] .tab { color: var(--muted-foreground); }
html[data-theme="dark"] .tab[aria-selected="true"] { color: var(--foreground); border-color: var(--input); background: color-mix(in oklab, var(--input) 30%, transparent); }
.tab-panel { flex: 1; outline: none; }
.tab-list-pills { height: auto; width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 0.375rem; padding: 0; background: transparent; overflow: visible; }

/* ---------- menu and popover ---------- */

.popover, .menu {
  z-index: 50; min-width: 8rem; overflow-x: hidden; overflow-y: auto; padding: 0.25rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-md);
  animation: enter var(--duration) ease;
}
.menu-anchor { position: absolute; top: 100%; right: 0; z-index: 50; padding-top: 0.5rem; }
.menu-label { padding: 0.375rem 0.5rem; font-size: var(--text-sm); font-weight: 500; }
.menu-item {
  position: relative; display: flex; width: 100%; align-items: center; gap: 0.5rem; padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm); font-size: var(--text-sm); text-align: left; text-decoration: none;
  cursor: default; user-select: none; outline: none; color: inherit;
}
.menu-item svg { width: 1rem; height: 1rem; color: var(--muted-foreground); }
.menu-item:hover, .menu-item:focus-visible, .menu-item:focus { background: var(--accent); color: var(--accent-foreground); }
.menu-item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.menu-item[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.menu-item-destructive { color: var(--destructive); }
.menu-item-destructive svg { color: currentColor; }
.menu-item-destructive:hover, .menu-item-destructive:focus { background: color-mix(in oklab, var(--destructive) 10%, transparent); color: var(--destructive); }
.menu-item-stacked { flex-direction: column; align-items: flex-start; gap: 0.125rem; }
.menu-separator { height: 1px; margin: 0.25rem -0.25rem; background: var(--border); border: 0; }
.menu-shortcut { margin-left: auto; font-size: var(--text-xs); letter-spacing: 0.1em; color: var(--muted-foreground); }
.menu-footnote { padding: 0 0.5rem 0.25rem; font-size: var(--text-xs); color: var(--muted-foreground); }

/* ---------- dialog (native dialog element, square corners as in the reference) ---------- */

.dialog {
  width: min(32rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 1.5rem; margin: auto;
  border: 1px solid var(--border); border-radius: 0; background: var(--background); color: var(--foreground);
  box-shadow: var(--shadow-lg); overflow-y: auto;
}
.dialog[open] { animation: fade-in var(--duration-slow) ease; }
.dialog::backdrop { background: rgb(0 0 0 / 0.3); backdrop-filter: blur(var(--blur)); }
.dialog-body { display: grid; gap: 1rem; }
.dialog-header { display: grid; gap: 0.375rem; text-align: center; }
@media (min-width: 640px) { .dialog-header { text-align: left; } }
.dialog-title { font-size: var(--text-lg); font-weight: 600; line-height: 1.2; letter-spacing: -0.025em; }
.dialog-description { font-size: var(--text-sm); color: var(--muted-foreground); }
.dialog-footer { display: flex; flex-direction: column-reverse; gap: 0.5rem; }
@media (min-width: 640px) { .dialog-footer { flex-direction: row; justify-content: flex-end; align-items: center; } }
.dialog-wide { width: min(64rem, calc(100vw - 2rem)); }
@media (max-width: 480px) { .dialog { padding: 1rem; } }

/* ---------- skeleton ---------- */

.skeleton { display: block; height: 1rem; border-radius: var(--radius-md); background: var(--accent); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.skeleton-stack { display: grid; gap: 0.5rem; }

/* ---------- toast ---------- */

.toaster {
  position: fixed; z-index: 100; bottom: 1rem; right: 1rem; left: 1rem;
  display: grid; justify-items: end; gap: 0.5rem; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 0.75rem; width: min(22rem, 100%);
  padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); animation: enter-up var(--duration-slow) ease;
}
.toast-message { flex: 1; }
.toast-error { border-color: color-mix(in oklab, var(--destructive) 50%, var(--border)); }

/* ---------- tooltip ---------- */

.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; translate: -50% 0; z-index: 60;
  width: max-content; max-width: 16rem; padding: 0.375rem 0.625rem; border-radius: var(--radius-md);
  font-size: var(--text-xs); line-height: 1rem; background: var(--primary); color: var(--primary-foreground);
  box-shadow: var(--shadow-md); opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--duration) var(--ease);
}
.tooltip-wrap:hover .tooltip, .tooltip-wrap:focus-within .tooltip { opacity: 1; visibility: visible; }

/* ---------- table ---------- */

.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--muted-foreground); background: color-mix(in oklab, var(--muted) 50%, transparent); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); }
.table :is(th, td).num { text-align: right; }

/* ---------- settings dialog ---------- */

.key-row { display: flex; gap: 0.5rem; }
.key-row .input { flex: 1; }

/* The release stage, shown beside the logo while the product is not generally available. */
.stage-badge {
  margin-inline-start: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.6875rem;
}
@media (max-width: 520px) {
  .stage-badge { display: none; }
}
