/* Layout only. Components (buttons, inputs, badges, alerts, tabs, modal,
   toast) come from Tucano; colors, radii and font come from its CSS
   variables so light and dark themes stay consistent. Spacing follows a
   4px scale (--sp-*). */

:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --sidebar-w: 300px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--tuc-font, system-ui, sans-serif);
  font-size: var(--tuc-text, 14px);
  line-height: 1.5;
  background: var(--tuc-bg, #f7f7f8);
  color: var(--tuc-fg, #111);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }

.card {
  background: var(--tuc-elevated, #fff);
  border: var(--tuc-border-width, 1px) solid var(--tuc-border, #e5e7eb);
  border-radius: var(--tuc-radius, 12px);
  padding: var(--sp-5);
}
.muted { color: var(--tuc-muted, #6b7280); }
.tuc-hint { margin: var(--sp-1) 0 0; }
.tuc-alert { margin-bottom: var(--sp-4); }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.brand strong { font-size: 15px; }
.brand__logo {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px;
  border-radius: 10px; background: var(--tuc-accent, #2563eb); color: var(--tuc-accent-fg, #fff);
  font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
}
.brand--big { margin-bottom: var(--sp-6); }
.brand--big .brand__logo { width: 44px; height: 44px; border-radius: 12px; font-size: 14px; }

/* ---- login ---- */
.login { min-height: 100%; display: grid; place-items: center; padding: var(--sp-6); }
.login__card {
  width: min(420px, 100%); display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-8); box-shadow: var(--tuc-shadow, 0 12px 40px rgba(0, 0, 0, .08));
}
.login__card .tuc-label { margin-top: var(--sp-4); }
.login__card .tuc-alert { margin: var(--sp-4) 0 0; }
.login__card .tuc-btn { margin-top: var(--sp-5); }
.login__note { text-align: center; margin-top: var(--sp-3); }

/* ---- app shell ---- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; }
.sidebar {
  display: flex; flex-direction: column; gap: var(--sp-4); height: 100vh; position: sticky; top: 0;
  padding: var(--sp-5); background: var(--tuc-elevated, #fff);
  border-right: var(--tuc-border-width, 1px) solid var(--tuc-border, #e5e7eb);
}
.sidebar .brand { padding-bottom: var(--sp-4); border-bottom: 1px solid var(--tuc-border, #e5e7eb); }
.sidebar .brand .tuc-badge { margin-left: auto; }
.sidebar .tuc-menu__section { margin: var(--sp-2) 0 0; }
.sidebar .tuc-menu { flex: 1; min-height: 0; overflow-y: auto; margin: 0 calc(var(--sp-2) * -1); padding: 0 var(--sp-2); }
.sidebar__count { color: var(--tuc-muted, #6b7280); font-weight: 400; }
.sidebar__empty { text-align: center; padding: var(--sp-6) 0; }
.sidebar__license { margin: 0; text-align: center; font-size: 11px; }
.sidebar__license a { color: inherit; text-decoration: none; }
.sidebar__license a:hover { text-decoration: underline; }
.sidebar__footer {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2);
  padding-top: var(--sp-4); border-top: 1px solid var(--tuc-border, #e5e7eb);
}
.sidebar__footer .tuc-btn { padding-inline: 8px; }
.sidebar__footer .tuc-btn:last-child { margin-left: auto; }

.menu-item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; text-align: left; cursor: pointer; }
.menu-item__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--tuc-muted, #9ca3af); }
.menu-item__text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.menu-item__text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item__text small { color: var(--tuc-muted, #6b7280); font-family: var(--mono); font-size: 11px; }

.dot--connected { background: var(--tuc-success, #16a34a); }
.dot--pairing, .dot--connecting { background: var(--tuc-warning, #d97706); }
.dot--logged_out { background: var(--tuc-danger, #dc2626); }

.content { padding: var(--sp-8); min-width: 0; }
.content > section { max-width: 1100px; }
.empty { display: grid; place-items: center; text-align: center; gap: var(--sp-2); padding: 120px 0; color: var(--tuc-muted, #6b7280); }
.empty__icon { font-size: 40px; opacity: .35; }
.empty h2 { color: var(--tuc-fg, #111); font-size: 17px; }

/* ---- detail ---- */
.detail__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding-bottom: var(--sp-4); margin-bottom: var(--sp-2);
}
.detail__heading { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.detail__heading h2 { font-size: 22px; }
.detail__id { display: flex; align-items: center; gap: var(--sp-2); color: var(--tuc-muted, #6b7280); }
.detail__id code {
  padding: 2px 8px; border-radius: var(--tuc-radius-sm, 6px); background: var(--tuc-subtle, #f1f1f3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.detail__header .tuc-badge { font-size: 13px; }
.tuc-tabs__panel { padding-top: var(--sp-5); }

.actions-bar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.actions-bar #disconnect { margin-left: auto; }
.pair-options { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.option { display: flex; flex-direction: column; gap: var(--sp-3); }
.option .tuc-hint { flex: 1; margin: 0; }
.option > .tuc-btn { align-self: flex-start; }
.option form { display: flex; gap: var(--sp-2); }
.option form .tuc-input { flex: 1; min-width: 0; }

.pairing { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-6); align-items: start; }
.pairing__card { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.pairing__qr { background: #fff; padding: var(--sp-3); border-radius: var(--tuc-radius-md, 8px); }
.pairing__qr img { display: block; width: 240px; height: 240px; image-rendering: pixelated; }
.pairing__code { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; }
.pairing__code span { font-family: var(--mono); font-size: 32px; letter-spacing: .12em; font-weight: 600; }
.pairing__card .tuc-hint { text-align: center; max-width: 280px; }
.pairing__steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: var(--sp-2); }

.send { display: flex; flex-direction: column; gap: var(--sp-4); }
.send__actions { display: flex; justify-content: flex-end; }
.section-title {
  font-size: 12px; font-weight: 600; color: var(--tuc-muted, #6b7280); margin: var(--sp-6) 0 var(--sp-2);
  text-transform: uppercase; letter-spacing: .06em;
}
.tuc-table code { font-size: 12px; }
.hint-warn { color: var(--tuc-warning, #d97706); }

.props { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4) var(--sp-6); margin: 0; }
.props > div { min-width: 0; }
.props dt { font-size: 12px; font-weight: 600; color: var(--tuc-muted, #6b7280); text-transform: uppercase; letter-spacing: .04em; }
.props dd { margin: 2px 0 0; word-break: break-all; }
.skeleton-label { width: 60%; height: 12px; }
.skeleton-value { width: 40%; height: 16px; margin-top: 4px; }

.danger-zone { padding: 0; }
.danger-zone__row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); }
.danger-zone__row + .danger-zone__row { border-top: 1px solid var(--tuc-border, #e5e7eb); }
.danger-zone__row .tuc-hint { margin-top: 2px; }

.field-row { display: flex; gap: var(--sp-2); }
.field-row .tuc-input { flex: 1; min-width: 0; font-family: var(--mono); }
.secret {
  padding: var(--sp-3); border-radius: var(--tuc-radius-md, 8px); background: var(--tuc-subtle, #f1f1f3);
  word-break: break-all; margin-top: var(--sp-3); font-size: 13px;
}
/* The modal backdrop's tinted radial glow bands visibly on dark screens
   (large low-contrast gradient in 8-bit color). Keep the dim + blur, drop the
   glow. Same selectors as Tucano's tone rules so this wins by source order. */
.tuc-modal::backdrop, .tuc-modal.is-danger::backdrop, .tuc-modal.is-success::backdrop, .tuc-modal.is-warning::backdrop,
.tuc-drawer::backdrop, .tuc-drawer.is-danger::backdrop, .tuc-drawer.is-success::backdrop, .tuc-drawer.is-warning::backdrop {
  --tuc-glow-color: transparent;
}
.tuc-modal__body .tuc-label { margin-top: var(--sp-3); }
.tuc-modal__body .tuc-label:first-child { margin-top: 0; }
.tuc-modal__body .tuc-alert { margin-bottom: 0; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--tuc-border, #e5e7eb); }
  .sidebar .tuc-menu { max-height: 240px; }
  .content { padding: var(--sp-5) var(--sp-4); }
  .detail__header { flex-direction: column; align-items: flex-start; }
  .pairing, .pair-options { grid-template-columns: 1fr; }
  .option form { flex-direction: column; }
  .danger-zone__row { flex-direction: column; align-items: flex-start; }
}
