/* MedusaXD Claude — design system
   Dark, low-chrome interface in the Linear/Vercel idiom: near-black surfaces,
   one violet accent, hairline borders, and type doing most of the work. */

:root {
  --bg: #09090b;
  --surface: #121215;
  --surface-2: #17171b;
  --surface-3: #1e1e24;
  --border: #26262e;
  --border-strong: #34343e;

  --text: #ededf0;
  --text-dim: #a1a1ac;
  --text-faint: #6e6e7a;

  --accent: #7c5cff;
  --accent-hover: #8f73ff;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --accent-ring: rgba(124, 92, 255, 0.35);

  --danger: #ff5f5f;
  --danger-soft: rgba(255, 95, 95, 0.12);
  --success: #3ddc97;
  --success-soft: rgba(61, 220, 151, 0.12);
  --warn: #ffb84d;
  --warn-soft: rgba(255, 184, 77, 0.12);

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 16px;

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

  --sidebar-w: 248px;
  --tabbar-h: 60px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
}
h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 1.15rem;
}
h3 {
  font-size: 0.98rem;
}
p {
  margin: 0;
}
a {
  color: var(--accent);
  text-decoration: none;
}

::selection {
  background: var(--accent-ring);
}

/* Scrollbars — thin and unobtrusive, visible only against content. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Utilities ─────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
.muted {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
}
.mono {
  font-family: var(--mono);
}
.small {
  font-size: 0.82rem;
}
.tiny {
  font-size: 0.74rem;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.col {
  display: flex;
  flex-direction: column;
}
.gap-sm {
  gap: 8px;
}
.gap-md {
  gap: 14px;
}
.gap-lg {
  gap: 22px;
}
.grow {
  flex: 1;
  min-width: 0;
}
.wrap {
  flex-wrap: wrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.center {
  display: grid;
  place-items: center;
}

/* ── Brand ─────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), #4d2ee0);
  box-shadow: 0 3px 12px rgba(124, 92, 255, 0.35);
  flex: none;
}
.brand-mark svg {
  width: 17px;
  height: 17px;
  display: block;
}
.brand-name {
  font-size: 0.97rem;
}
.brand-name b {
  font-weight: 650;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 520;
  padding: 9px 15px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  /* Comfortable thumb target on phones. */
  min-height: 40px;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    opacity 0.14s ease,
    transform 0.06s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: #43434f;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 580;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: transparent;
}

.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(255, 95, 95, 0.2);
  border-color: transparent;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.79rem;
  min-height: 32px;
  border-radius: var(--r-sm);
}
.btn-block {
  width: 100%;
}
.btn-icon {
  padding: 0;
  width: 36px;
  min-height: 36px;
  flex: none;
}

/* ── Forms ─────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.label {
  font-size: 0.79rem;
  font-weight: 550;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}
.input,
.select,
.textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-family: inherit;
  /* 16px keeps iOS Safari from zooming the viewport on focus. */
  font-size: 16px;
  min-height: 42px;
  transition:
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}
.textarea {
  resize: vertical;
  line-height: 1.5;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b96' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
}
.checkbox input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.form-error {
  color: var(--danger);
  font-size: 0.83rem;
  background: var(--danger-soft);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  border: 1px solid rgba(255, 95, 95, 0.22);
}

/* ── Cards & surfaces ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card-tight {
  padding: 14px;
}

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-faint);
}

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.71rem;
  font-weight: 560;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: transparent;
}
.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: currentColor;
  flex: none;
}
.dot-pulse {
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

/* ── App shell ─────────────────────────────────────────────────── */
#app {
  min-height: 100dvh;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.sidebar-head {
  padding: 4px 8px 14px;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-md);
  color: var(--text-dim);
  font-size: 0.89rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
  transition:
    background 0.14s ease,
    color 0.14s ease;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(12px);
  min-height: 58px;
}
.page {
  padding: 22px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
}
.page-wide {
  max-width: none;
}

/* ── Server cards ──────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  cursor: pointer;
  transition:
    border-color 0.14s ease,
    background 0.14s ease,
    transform 0.1s ease;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}
.server-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.server-card:active {
  transform: scale(0.995);
}
.server-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* ── Stats ─────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 15px;
}
.stat-value {
  font-size: 1.7rem;
  font-weight: 620;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ── Tables (admin) ────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.table-scroll {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
th {
  text-align: left;
  font-weight: 560;
  color: var(--text-dim);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover {
  background: var(--surface-2);
}

/* Card-style rows replace the table on narrow screens. */
.user-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Workspace (chat / terminal / files) ───────────────────────── */
.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tabs {
  display: flex;
  gap: 3px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 520;
  color: var(--text-dim);
  padding: 12px 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.14s ease;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Chat ──────────────────────────────────────────────────────── */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.msg {
  display: flex;
  gap: 11px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}
.msg-avatar {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 650;
  margin-top: 2px;
}
.msg-user .msg-avatar {
  background: var(--surface-3);
  color: var(--text-dim);
}
.msg-assistant .msg-avatar {
  background: linear-gradient(140deg, var(--accent), #4d2ee0);
  color: #fff;
}
.msg-body {
  min-width: 0;
  flex: 1;
}
.msg-role {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.62;
}
.msg-text code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 5px;
}
.msg-text pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 9px 0;
}
.msg-text pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.84em;
  line-height: 1.6;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-family: var(--mono);
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
  margin: 3px 4px 3px 0;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}
.typing span {
  width: 5px;
  height: 5px;
  border-radius: 99px;
  background: var(--text-faint);
  animation: bounce 1.3s ease-in-out infinite;
}
.typing span:nth-child(2) {
  animation-delay: 0.16s;
}
.typing span:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 22px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.composer-inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  gap: 9px;
  align-items: flex-end;
}
.composer .textarea {
  max-height: 190px;
  min-height: 44px;
  border-radius: var(--r-md);
}

/* ── Terminal ──────────────────────────────────────────────────── */
.term {
  flex: 1;
  overflow-y: auto;
  background: #060608;
  padding: 15px 18px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #d4d4dc;
  margin: 0;
}
.term-cmd {
  color: var(--accent-hover);
  font-weight: 600;
}
.term-err {
  color: var(--danger);
}
.term-exit-ok {
  color: var(--success);
}
.term-exit-bad {
  color: var(--danger);
}
.term-input-bar {
  display: flex;
  gap: 9px;
  padding: 11px 18px;
  padding-bottom: max(11px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
}
.term-prompt {
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
  flex: none;
}
.term-input {
  font-family: var(--mono);
  font-size: 16px;
}

/* ── Files ─────────────────────────────────────────────────────── */
.file-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--mono);
  font-size: 0.79rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.crumbs::-webkit-scrollbar {
  display: none;
}
.crumb {
  background: none;
  border: none;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 5px;
  white-space: nowrap;
}
.crumb:hover {
  background: var(--surface-2);
  color: var(--text);
}
.crumb:last-child {
  color: var(--text);
  font-weight: 600;
}

.file-list {
  flex: 1;
  overflow-y: auto;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}
.file-row:hover {
  background: var(--surface-2);
}
.file-icon {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--text-faint);
}
.file-icon.dir {
  color: var(--accent);
}
.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.89rem;
}
.file-size {
  font-size: 0.76rem;
  color: var(--text-faint);
  font-family: var(--mono);
  flex: none;
}
.file-actions {
  display: flex;
  gap: 3px;
  flex: none;
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fade 0.16s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 460px;
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: rise 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal-wide {
  max-width: 780px;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}
.modal-head {
  padding: 17px 19px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-body {
  padding: 19px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-foot {
  padding: 15px 19px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

/* ── Toasts ────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(370px, calc(100vw - 32px));
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
  animation: slide 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow-wrap: anywhere;
}
.toast-error {
  border-left-color: var(--danger);
}
.toast-success {
  border-left-color: var(--success);
}
@keyframes slide {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ── Auth screen ───────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
  /* Faint violet bloom so the sign-in page isn't a flat black rectangle. */
  background:
    radial-gradient(800px 420px at 50% -8%, rgba(124, 92, 255, 0.13), transparent 70%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 384px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.auth-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.auth-head .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
}
.auth-head .brand-mark svg {
  width: 25px;
  height: 25px;
}

/* ── Loading ───────────────────────────────────────────────────── */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 99px;
  animation: spin 0.65s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-3) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ── Mobile tab bar ────────────────────────────────────────────── */
.tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(18, 18, 21, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner {
  display: flex;
  height: var(--tabbar-h);
}
.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 550;
  cursor: pointer;
  padding: 6px 2px;
}
.tabbar-item svg {
  width: 20px;
  height: 20px;
}
.tabbar-item.active {
  color: var(--accent-hover);
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .tabbar {
    display: block;
  }
  .main {
    /* Reserve room so the fixed tab bar never covers the last row. */
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  }
  .page {
    padding: 16px;
  }
  .topbar {
    padding: 11px 16px;
  }
  .tabs,
  .file-toolbar {
    padding-left: 16px;
    padding-right: 16px;
  }
  .chat-log {
    padding: 16px;
  }
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .file-row {
    padding-left: 16px;
    padding-right: 16px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .toasts {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
    left: 12px;
    right: 12px;
    max-width: none;
  }
  /* The workspace owns the full viewport on phones, so its own composer sits
     above the tab bar rather than the page scrolling behind it. */
  .workspace-page {
    padding-bottom: 0;
  }
  .table-desktop {
    display: none;
  }
}

@media (min-width: 861px) {
  .user-cards {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
