/* SIGNAL component classes. Cards separate by hairline + tone step, never by
   shadow; only floating layers (dropdown, popover, modal) get elevation. */

/* ============================== App shell ============================== */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr 340px;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar topbar"
    "sidebar work panel";
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.app-shell.no-panel {
  grid-template-columns: 240px 1fr 0;
}
.app-shell.no-panel .right-panel {
  display: none;
}

/* ------------------------------ Sidebar ------------------------------ */

.sidebar {
  grid-area: sidebar;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
}
.sidebar-brand {
  height: 56px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin: 0;
  padding: 0 10px;
  box-sizing: border-box;
}
.sidebar-wordmark {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
  margin: 0;
  white-space: nowrap;
}

/* ============================ Logo lockup ============================= */

.logo-lockup-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
}
.logo-lockup {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}
.logo-lockup-mark {
  display: inline-flex;
  flex-shrink: 0;
  /* Optical center vs wordmark cap height */
  transform: translateY(1px);
}
.logo-lockup-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
.logo-lockup-wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
  margin: 0;
}
.logo-lockup.is-large .logo-lockup-mark {
  width: 32px;
  height: 32px;
}
.logo-lockup.is-large .logo-lockup-wordmark {
  font-size: 24px;
  letter-spacing: 0.06em;
}
.logo-lockup.is-compact .logo-lockup-wordmark {
  display: none;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--surface-3);
}
.nav-item.active {
  background: var(--surface-3);
  color: var(--text);
}
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
  flex-shrink: 0;
}
.sidebar-heading {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 0 10px 6px;
}
.sidebar-recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  overflow: hidden;
}
.sidebar-recent-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-recent-item:hover {
  background: var(--surface-3);
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  flex-shrink: 0;
}
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px;
  margin-bottom: 12px;
}
.plan-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}
.plan-card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin: 0;
}
.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 8px;
  border-radius: var(--radius-control);
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.account-row:hover {
  background: var(--surface-3);
}
.account-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}
.account-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-legal {
  display: flex;
  gap: 10px;
  padding: 8px 10px 0;
}
.sidebar-legal a {
  font-size: 12px;
  color: var(--text-3);
  text-decoration: none;
}
.sidebar-legal a:hover {
  color: var(--text-2);
}

/* ------------------------------ Top bar ------------------------------ */

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-spacer {
  flex: 1;
}
.topbar-search {
  position: relative;
  width: 320px;
  flex-shrink: 1;
  min-width: 160px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  cursor: pointer;
  text-align: left;
}
.topbar-search svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.topbar-search-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-search .kbd {
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--surface-2);
}
/* Must beat .icon-btn { display: inline-flex } — desktop keeps the search field only. */
.icon-btn.topbar-search-icon {
  display: none;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.topbar-bell {
  position: relative;
  display: inline-flex;
}
.topbar-bell.has-unread::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
}
.topbar-avatar {
  border: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
}

/* ---------------------------- Work + panel ---------------------------- */

.work-area {
  grid-area: work;
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior: none;
  min-height: 0;
  min-width: 0;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-content: flex-start;
}
/* Views size to their content — never stretch to fill and create empty scroll. */
.work-area > * {
  flex: 0 0 auto;
  max-width: 100%;
  min-width: 0;
}
.work-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.right-panel {
  grid-area: panel;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
.right-panel-scroll {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  padding: 20px 20px 28px;
  -webkit-overflow-scrolling: touch;
}
.panel-action-bar {
  border-top: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
}
.panel-action-meta {
  display: none;
}
.panel-action-slot {
  display: flex;
  gap: 10px;
  justify-content: stretch;
  width: 100%;
}
.panel-action-slot > .btn-block {
  width: 100%;
  height: 40px;
  justify-content: center;
}
.panel-action-slot > .btn:not(.btn-block) {
  width: auto;
}
.control-group {
  margin: 0 0 28px;
  padding: 0;
  border-bottom: 0;
}
.control-group:last-child {
  margin-bottom: 0;
}
.control-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}
.control-help {
  font-size: 12px;
  color: var(--text-3);
  margin: 6px 0 0;
}
.reset-values {
  display: block;
  margin-left: auto;
  font-size: 12px;
}

/* ============================== Controls ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  background: transparent;
  transition: background 0.12s ease;
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover:not(:disabled) {
  background: #27272a;
}
.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn-ghost {
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn-destructive {
  color: var(--destructive);
}
.btn-destructive:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
}
.btn-block {
  width: 100%;
}
.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn.sm {
  width: 28px;
  height: 28px;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn.sm svg {
  width: 16px;
  height: 16px;
}
.icon-btn.touch {
  width: 44px;
  height: 44px;
}
.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.input {
  height: 36px;
  width: 100%;
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.input::placeholder {
  color: var(--text-3);
}
.input:focus,
textarea.input:focus,
.select-trigger:focus-visible {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(10, 10, 11, 0.07);
}
textarea.input {
  height: auto;
  min-height: 72px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

/* Custom select — in-product dropdown, never native OS chrome */
.select {
  position: relative;
  width: 100%;
}
.select-trigger {
  height: 36px;
  width: 100%;
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}
.select-trigger svg {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  flex-shrink: 0;
}
.select.is-open .select-trigger {
  border-color: var(--text);
}
.select.is-disabled .select-trigger {
  opacity: 0.55;
  cursor: default;
}
.select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.select-option {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.select-option.has-leading {
  height: 40px;
}
.select-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-option:hover,
.select-option.is-active {
  background: var(--surface-2);
}

/* Slider */
.slider {
  width: 100%;
}
.slider-track-row {
  display: flex;
  align-items: center;
}
.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(
    to right,
    var(--text) 0%,
    var(--text) var(--slider-fill, 0%),
    var(--border) var(--slider-fill, 0%),
    var(--border) 100%
  );
  border-radius: 999px;
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-2);
  margin-top: -6px;
  box-shadow: var(--shadow-pop);
}
.slider input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--border);
  border-radius: 999px;
}
.slider input[type="range"]::-moz-range-progress {
  height: 2px;
  background: var(--text);
  border-radius: 999px;
}
.slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-pop);
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}
.slider-value {
  flex-shrink: 0;
  min-width: 1.5em;
  margin-left: 12px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}

/* Toggle */
.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  border: 0;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--shadow-pop);
  transition: transform 0.15s ease;
}
.toggle[aria-checked="true"] {
  background: var(--accent);
}
.toggle[aria-checked="true"]::after {
  transform: translateX(16px);
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}
.toggle-row-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

/* Chips */
.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

/* Status dot */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot-offline);
  flex-shrink: 0;
}
.status-dot.live {
  background: var(--dot-live);
}
.status-dot.paused {
  background: var(--dot-paused);
}

/* Neutral pill */
.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* =============================== Cards ================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.card-pad {
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.metric-card {
  flex: 1;
  min-width: 0;
  padding: 20px;
}
.metric-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin: 0;
}
.metric-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 0;
}
.metric-sub {
  display: none;
}
.metric-row {
  display: flex;
  gap: 16px;
}

/* Quota strip */
.quota-strip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: nowrap;
  min-width: 0;
}
.quota-strip[hidden] {
  display: none !important;
}
.quota-strip-items {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-width: 0;
}
.quota-strip-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.quota-strip-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  flex-shrink: 0;
}
.quota-strip-item strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.quota-strip-reset {
  font-size: 12px;
  color: var(--text-3);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================== List rows ============================= */

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.list-row:last-child {
  border-bottom: 0;
}
.list-row:hover {
  background: var(--surface-2);
}
.list-thumb {
  width: 40px;
  height: 71px;
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  overflow: hidden;
}
.list-thumb.wide {
  width: 71px;
  height: 40px;
}
.list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.list-thumb svg {
  width: 18px;
  height: 18px;
}
.list-main {
  flex: 1;
  min-width: 0;
}
.list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-meta {
  font-size: 12px;
  color: var(--text-3);
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.conv-bar {
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.conv-bar > span {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 999px;
}

/* Filter row above a list */
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 0;
}
.filter-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-3);
}

/* ============================ Chart card ============================== */

.chart-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 20px 16px;
  box-shadow: none;
}
.chart-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 32px;
}
.chart-card-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.chart-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
}
.chart-live[hidden] {
  display: none !important;
}
.chart-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
  flex-shrink: 0;
}
.chart-range.segmented button {
  height: 32px;
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0a0a0b;
  flex-shrink: 0;
}
.chart-legend-dash {
  width: 12px;
  height: 0;
  border-top: 2px dashed var(--text-3);
  flex-shrink: 0;
}
.chart-readout {
  margin-top: 20px;
  margin-bottom: 8px;
}
.chart-readout-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin: 0;
  line-height: 1.1;
}
.chart-readout-window {
  font-size: 12px;
  color: var(--text-3);
  margin: 4px 0 0;
}
.chart-plot {
  position: relative;
  height: 220px;
  width: 100%;
}
.chart-plot.is-loading {
  background: var(--surface-2);
  border-radius: 6px;
}
.chart-plot.is-loading canvas {
  opacity: 0;
}
.chart-plot canvas {
  display: block;
  width: 100% !important;
  height: 220px !important;
}
.chart-empty-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
  pointer-events: none;
}
.chart-empty-msg[hidden] {
  display: none !important;
}
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 120px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 10px 12px;
  pointer-events: none;
}
.chart-tip[hidden] {
  display: none !important;
}
.chart-tip-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.chart-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
}
.chart-tip-row span {
  color: var(--text-3);
}
.chart-tip-row strong {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ============================= Dropzone =============================== */

.dropzone {
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-panel);
  background: var(--surface-2);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
}
.dropzone.compact {
  min-height: 160px;
  padding: 20px;
}
.dropzone.dragover {
  border-color: var(--text);
  background: var(--surface-3);
}
.dropzone-glyph {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  margin-bottom: 6px;
}
.dropzone-glyph svg {
  width: 20px;
  height: 20px;
}
.dropzone-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.dropzone-sub {
  font-size: 13px;
  color: var(--text-3);
}
.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 160px;
  font-size: 13px;
  color: var(--text-3);
  margin: 8px 0;
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* =========================== Studio pieces ============================ */

.hero-card {
  border-radius: 14px;
  height: 200px;
  min-height: 200px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.hero-input-card {
  width: min(560px, 100%);
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  padding: 6px;
}
.hero-input-card input {
  border: 0;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 16px;
  background: transparent;
}
.hero-input-card input:focus {
  outline: none;
  box-shadow: none;
}
.hero-input-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding: 6px 6px 2px;
}

.template-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-top: 24px;
}
.studio-recent {
  margin-top: 48px;
}
.studio-recent h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}
.studio-recent-empty {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
  max-width: none;
}
.template-card {
  min-width: 0;
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
}
.template-card .template-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.template-card .template-img svg {
  width: 28px;
  height: 28px;
}
.template-text {
  margin-top: 12px;
  height: 52px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.template-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-card p {
  font-size: 13px;
  color: var(--text-3);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
}

/* Caption preview — compact stage, centered Title Card */
.caption-preview {
  margin-top: 8px;
}
.caption-preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.caption-preview-caption {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Title Card — white hook card, centered in the preview */
.cp-title-card {
  width: min(88%, 280px);
  box-sizing: border-box;
  background: #fff;
  color: #0a0a0b;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: Inter, "SF Pro Display", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.cp-title-line {
  display: block;
}
.cp-title-em {
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

.caption-style-thumb {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 2px;
  box-sizing: border-box;
}
.cst-title-card {
  display: block;
  width: 100%;
  background: #fff;
  color: #0a0a0b;
  font-size: 4px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  border-radius: 1px;
  padding: 1px 0;
}

/* Monitored roster cards */
.roster-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.roster-card {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
}
.roster-card:hover {
  background: var(--surface-3);
}
.roster-card-main {
  flex: 1;
  min-width: 0;
}
.roster-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.roster-card-status {
  font-size: 12px;
  font-weight: 500;
  margin: 2px 0 0;
}
.roster-card-status.is-live {
  color: var(--text);
}
.roster-card-status.is-offline,
.roster-card-status.is-paused {
  color: var(--text-3);
}
.roster-card-posts {
  font-size: 12px;
  color: var(--text-3);
  margin: 2px 0 0;
}
.roster-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
@media (hover: hover) and (pointer: fine) {
  .roster-card-actions {
    opacity: 0;
  }
  .roster-card:hover .roster-card-actions,
  .roster-card:focus-within .roster-card-actions {
    opacity: 1;
  }
}
.roster-pause-all {
  margin-top: 12px;
  width: 100%;
}

/* Connected accounts rows */
.account-conn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: 16px;
}
.account-platform-block {
  border-bottom: 1px solid var(--border);
}
.account-platform-block:last-child {
  border-bottom: 0;
}
.account-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.account-line--carousel {
  gap: 10px;
}
.account-platform-block .account-line:last-child,
.account-conn-card > .account-line:last-child {
  border-bottom: 0;
}
.account-line-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto;
}
.account-line-mid {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
}
.account-line-left .brand-mark {
  flex-shrink: 0;
  display: inline-flex;
  width: 16px;
  height: 16px;
  line-height: 0;
}
.account-line-left .brand-mark svg {
  display: block;
  width: 16px;
  height: 16px;
}
.account-line-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-line-name--platform {
  min-width: 72px;
}
.account-line-name--muted {
  font-weight: 500;
  color: var(--text-3);
}
.account-line-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.account-line-status {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.account-line--connect .account-line-right .btn {
  min-width: 88px;
}
.account-slot-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 4px;
}
.account-slot-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
  line-height: 1;
}
.account-conn-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-height: 56px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.account-conn-row:last-child {
  border-bottom: 0;
}
.account-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
}
.account-slot-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.account-slot-title .brand-mark {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  line-height: 0;
}
.account-slot-title .brand-mark svg {
  display: block;
  width: 18px;
  height: 18px;
}
.account-slot-title .account-conn-name {
  margin: 0;
  line-height: 1;
}
.account-slot-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.account-slot-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
  line-height: 1;
}
.account-slot-body {
  min-width: 0;
  width: 100%;
  padding-left: 28px; /* align under title text, past the logo */
}
.account-slot-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 72px;
}
.account-slot-empty .account-conn-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.account-slot-empty .account-conn-handle {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-3);
}
.account-slot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  min-height: 28px;
}
.account-page-chip {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  margin-top: 6px;
}
.account-page-chip:first-child {
  margin-top: 0;
}
.account-page-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.account-page-chip-meta {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.account-conn-row:hover .brand-mark--tiktok {
  color: #000000;
}
.account-conn-row.is-connected:hover .brand-mark--tiktok {
  color: #fe2c55;
}
.account-conn-row.is-connected:hover .brand-mark--instagram {
  color: #e1306c;
}
.account-conn-row.is-connected:hover .brand-mark--youtube {
  color: #ff0000;
}
.account-conn-left {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.account-conn-copy {
  min-width: 0;
}
.account-conn-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}
.account-conn-handle {
  font-size: 12px;
  color: var(--text-3);
  margin: 2px 0 0;
}
.account-conn-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  flex-shrink: 0;
}
.account-conn-status {
  width: 120px;
  text-align: right;
  font-size: 13px;
  color: var(--text-2);
  flex-shrink: 0;
}
.account-conn-action {
  width: 100px;
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.brand-mark {
  color: var(--text);
}
.brand-mark svg {
  display: block;
  width: 20px;
  height: 20px;
}

.platform-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}
.platform-line .brand-mark {
  flex-shrink: 0;
}
.platform-line.is-connected:hover .brand-mark--tiktok {
  color: #fe2c55;
}
.platform-line.is-connected:hover .brand-mark--instagram {
  color: #e1306c;
}
.platform-line.is-connected:hover .brand-mark--youtube {
  color: #ff0000;
}
.quota-strip-item .brand-mark {
  width: 14px;
  height: 14px;
}
.quota-strip-item .brand-mark svg {
  width: 14px;
  height: 14px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.thumb-grid.portrait {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.thumb-item {
  min-width: 0;
}
.thumb-media {
  position: relative;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.thumb-media.portrait {
  aspect-ratio: 9 / 16;
}
.thumb-angle {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 8px 0 0;
}
.thumb-title {
  font-size: 14px;
  font-weight: 500;
  margin: 2px 0 0;
}
.thumb-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.thumb-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  opacity: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-item:hover .thumb-check,
.thumb-check.checked {
  opacity: 1;
}
.thumb-check.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.thumb-check svg {
  width: 12px;
  height: 12px;
}

/* =========================== Empty / error ============================ */

.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}
.empty-state .btn {
  margin-top: 12px;
}
.error-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text);
}
.error-row .btn {
  margin-left: auto;
}

/* ============================== Skeleton ============================== */

.skeleton {
  background: var(--surface-2);
  border-radius: var(--radius-control);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* =============================== Modal ================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 11, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  width: min(960px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.narrow {
  width: min(440px, 100%);
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title-wrap {
  flex: 1;
  min-width: 0;
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-meta {
  font-size: 12px;
  color: var(--text-3);
  margin: 1px 0 0;
}
.modal-header .btn,
.modal-header .icon-btn {
  height: 32px;
}
.modal-body {
  flex: 1;
  min-height: 0;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body iframe,
.modal-body video {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: var(--surface-2);
  aspect-ratio: 16 / 9;
}
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.modal-footer .input {
  flex: 1 1 180px;
  min-width: 0;
}
.modal-plain-body {
  padding: 20px 18px;
  font-size: 14px;
  color: var(--text-2);
}

/* =============================== Toast ================================ */

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  max-width: 360px;
}

/* ============================ Editor shell ============================ */

.editor-shell {
  display: grid;
  grid-template-columns: 72px 300px 1fr 340px;
  grid-template-rows: 56px 1fr 56px 120px;
  grid-template-areas:
    "etop etop etop etop"
    "erail einspect estage eagent"
    "etransport etransport etransport etransport"
    "etimeline etimeline etimeline etimeline";
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.editor-topbar {
  grid-area: etop;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.editor-title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-rail {
  grid-area: erail;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
}
.rail-item {
  width: 56px;
  height: 48px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.rail-item svg {
  width: 18px;
  height: 18px;
}
.rail-item.active {
  background: var(--surface-3);
  color: var(--text);
}
.editor-inspector {
  grid-area: einspect;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}
.editor-stage {
  grid-area: estage;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
  padding: 20px;
}
.stage-preview {
  height: min(100%, 62vh);
  aspect-ratio: 9 / 16;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.stage-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.editor-agent {
  grid-area: eagent;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.agent-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}
.agent-composer {
  border-top: 1px solid var(--border);
  padding: 12px;
}
.agent-composer-box {
  background: var(--surface-2);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  padding: 8px;
}
.agent-composer textarea {
  border: 0;
  background: transparent;
  width: 100%;
  resize: none;
  min-height: 48px;
  font-size: 13px;
}
.agent-composer textarea:focus {
  outline: none;
  box-shadow: none;
}
.agent-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.send-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.send-btn svg {
  width: 14px;
  height: 14px;
}
.editor-transport {
  grid-area: etransport;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.play-btn svg {
  width: 16px;
  height: 16px;
}
.transport-time {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.editor-timeline {
  grid-area: etimeline;
  background: var(--surface);
  overflow-x: auto;
  padding: 8px 16px 12px;
  position: relative;
}
.timeline-ruler {
  display: flex;
  gap: 0;
  font-size: 11px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 8px;
}
.timeline-ruler span {
  flex: 0 0 80px;
  border-left: 1px solid var(--border);
  padding-left: 4px;
}
.timeline-lane {
  height: 44px;
  background: var(--surface-2);
  border-radius: var(--radius-control);
  margin-bottom: 6px;
  position: relative;
  overflow: hidden;
}
.timeline-clip {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  padding: 0 10px;
  overflow: hidden;
  white-space: nowrap;
}
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--text);
}
.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -3px;
  width: 7px;
  height: 7px;
  background: var(--text);
}

/* ============================= Overlays =============================== */

.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(10, 10, 11, 0.35);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 15vh;
}
.cmdk-overlay[hidden] {
  display: none !important;
}
.cmdk-panel {
  width: min(560px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.cmdk-input-row {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}
.cmdk-close {
  display: none;
  flex-shrink: 0;
  margin-left: auto;
}
.cmdk-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  font-size: 15px;
  background: transparent;
  color: var(--text);
  box-shadow: none !important;
}
.cmdk-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}
.cmdk-heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin: 8px 8px 4px;
  text-transform: uppercase;
}
.cmdk-row {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.cmdk-row:hover,
.cmdk-row.is-active {
  background: var(--surface-2);
}
.cmdk-thumb {
  width: 32px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}
.cmdk-label {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmdk-meta {
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
}
.cmdk-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
}

.notif-pop,
.account-pop {
  width: 380px;
  max-height: 480px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.notif-pop[hidden],
.account-pop[hidden] {
  display: none !important;
}
.notif-head {
  height: 48px;
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.notif-list {
  overflow-y: auto;
  flex: 1;
}
.notif-item {
  width: 100%;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.notif-item.is-unread {
  background: var(--surface-2);
}
.notif-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  margin-top: 7px;
  flex-shrink: 0;
}
.notif-dot-spacer {
  width: 6px;
  flex-shrink: 0;
}
.notif-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.notif-msg {
  font-size: 14px;
  color: var(--text);
}
.notif-item:not(.is-unread) .notif-msg {
  color: var(--text-2);
}
.notif-time {
  font-size: 12px;
  color: var(--text-3);
}
.notif-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
}
.account-pop {
  width: 260px;
  border-radius: 14px;
  padding: 6px;
  max-height: none;
}
.account-pop-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.account-pop-item {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
}
.account-pop-item:hover,
.account-pop-item:focus-visible {
  background: var(--surface-3);
  box-shadow: none;
  outline: none;
}
.account-pop-item.is-danger {
  color: #dc2626;
}
.account-pop-item svg,
.account-pop-item .icon {
  width: 20px;
  height: 20px;
  color: var(--text);
  flex-shrink: 0;
}
.account-pop-item.is-danger svg,
.account-pop-item.is-danger .icon {
  color: #dc2626;
}

.panel-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 11, 0.3);
  z-index: 80;
}
.panel-scrim[hidden] {
  display: none !important;
}

/* ============================= Responsive ============================= */

.panel-toggle-btn {
  display: none;
}
.app-shell.no-panel .panel-toggle-btn {
  display: none !important;
}

.work-area,
.work-stack {
  overflow-x: clip;
  max-width: 100%;
}

@media (max-width: 1279px) {
  .app-shell {
    grid-template-columns: 64px minmax(0, 1fr) 0;
  }
  .app-shell.no-panel {
    grid-template-columns: 64px minmax(0, 1fr) 0;
  }
  .sidebar {
    padding: 0 10px 16px;
    align-items: center;
  }
  .sidebar-brand {
    height: 56px;
    margin: 0;
    padding: 0;
    justify-content: center;
  }
  .sidebar-wordmark {
    display: block;
    font-size: 8px;
    letter-spacing: 0.04em;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
  }
  .nav-item span,
  .account-name,
  .sidebar-legal {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }
  .nav-item.active {
    background: var(--surface-3);
  }
  .account-row {
    justify-content: center;
    padding: 0;
  }
  .right-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    height: auto;
    max-height: none;
    z-index: 90;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    border-left: 1px solid var(--border);
    background: #fff;
    overflow: hidden;
  }
  .right-panel.open {
    transform: translateX(0);
  }
  .app-shell:not(.no-panel) .panel-toggle-btn {
    display: inline-flex;
  }
  .work-area {
    padding: 20px 24px;
  }
  .topbar {
    padding: 0 16px;
    gap: 8px;
  }
  .topbar-search {
    width: min(280px, 36vw);
    min-width: 140px;
  }
  .topbar-search .kbd {
    display: none;
  }
  .page-title {
    font-size: 20px;
    max-width: 40vw;
  }
  .template-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .card-header {
    flex-wrap: wrap;
  }
}

@media (max-width: 1023px) {
  .template-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric-card {
    padding: 16px;
  }
  .metric-value {
    font-size: 24px;
  }
  .quota-strip {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  .topbar {
    align-items: center;
  }
  .topbar-bell,
  .topbar-avatar,
  .panel-toggle-btn {
    flex-shrink: 0;
  }
  .topbar-bell .icon-btn {
    width: 36px;
    height: 36px;
  }
  .notif-pop,
  .account-pop {
    width: min(380px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }
  .cmdk-close {
    display: inline-flex;
  }
}

@media (max-width: 767px) {
  .app-shell,
  .app-shell.no-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 52px minmax(0, 1fr) calc(56px + env(safe-area-inset-bottom, 0px));
    grid-template-areas:
      "topbar"
      "work"
      "tabbar";
  }
  .sidebar {
    display: none;
  }
  .topbar {
    height: 52px;
    padding: 0 12px;
  }
  .page-title {
    font-size: 18px;
    max-width: none;
    flex: 1;
    min-width: 0;
  }
  .topbar-spacer {
    display: none;
  }
  .work-area {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .work-stack {
    gap: 16px;
  }
  .right-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: 88dvh;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    border-left: 0;
    border-top: 1px solid var(--border);
    overflow: hidden;
  }
  .right-panel.open {
    transform: translateY(0);
  }
  .right-panel::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-2);
    margin: 10px auto 0;
  }
  .tab-bar {
    grid-area: tabbar;
    display: flex;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--border);
    background: #fff;
    z-index: 50;
  }
  .tab-bar .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    height: 56px;
    width: auto;
    border-radius: 0;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-3);
    min-width: 0;
    padding: 0 2px;
  }
  .tab-bar .nav-item.active {
    color: var(--text);
    background: transparent;
  }
  .tab-bar .nav-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .topbar-search {
    display: none;
  }
  .icon-btn.topbar-search-icon {
    display: inline-flex;
  }
  .topbar-bell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .notif-pop {
    width: auto !important;
    max-width: none;
    left: 12px !important;
    right: 12px !important;
    top: calc(52px + env(safe-area-inset-top, 0px) + 6px) !important;
    max-height: min(70dvh, 480px);
    border-radius: 12px;
  }
  .account-pop {
    width: auto !important;
    max-width: none;
    left: 12px !important;
    right: 12px !important;
    top: calc(52px + env(safe-area-inset-top, 0px) + 6px) !important;
  }
  .metric-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .metric-card {
    padding: 12px;
  }
  .metric-label {
    font-size: 11px;
  }
  .metric-value {
    font-size: 20px;
    margin-top: 6px;
  }
  .template-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .hero-card {
    height: auto;
    min-height: 180px;
    padding: 16px;
  }
  .hero-input-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .hero-input-foot .btn {
    width: 100%;
  }
  .quota-strip {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 12px 14px;
  }
  .quota-strip-reset {
    margin-left: 0;
    width: 100%;
  }
  .list-row {
    flex-wrap: wrap;
  }
  .list-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .list-actions .btn {
    width: 100%;
    height: 40px;
  }
  .filter-row {
    min-height: 40px;
    overflow-x: auto;
  }
  .roster-card-actions {
    opacity: 1 !important;
  }
  .roster-card-actions .icon-btn {
    width: 44px;
    height: 44px;
  }
  .account-conn-row {
    height: auto;
    min-height: 56px;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .account-conn-right {
    width: 100%;
    justify-content: flex-end;
  }
  .account-conn-status {
    width: auto;
    margin-right: 8px;
  }
  .cmdk-overlay {
    padding-top: 0;
    align-items: stretch;
  }
  .cmdk-panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .cmdk-close {
    display: inline-flex;
  }
  .modal-card,
  .video-modal-panel,
  .ui-confirm-card {
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    max-height: 100dvh;
    border-radius: 14px 14px 0 0;
  }
  .editor-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 52px 1fr 56px 100px;
    grid-template-areas:
      "etop"
      "estage"
      "etransport"
      "etimeline";
  }
  .editor-rail,
  .editor-inspector,
  .editor-agent {
    display: none;
  }
}

@media (max-width: 430px) {
  .metric-row {
    grid-template-columns: 1fr;
  }
  .metric-value {
    font-size: 24px;
  }
  .template-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .list-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 768px) {
  .tab-bar {
    display: none;
  }
}
