/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 12px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #d9a441, #8a6420);
  display: flex; align-items: center; justify-content: center;
  color: #16130a; font-weight: 700; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  border-radius: var(--r-control); color: var(--dim); font-weight: 500;
  background: none; border: 0; font-size: 14px; cursor: pointer; width: 100%;
  text-align: left; transition: background 150ms ease-out, color 150ms ease-out;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active { color: var(--text); background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.nav-badge { margin-left: auto; font-size: 12px; color: var(--dim); }
.nav-badge.warn { color: var(--amber); font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }

.topbar {
  height: 58px; flex-shrink: 0; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  background: var(--bg); position: sticky; top: 0; z-index: 20;
}
.topbar-search {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-control);
  padding: 7px 12px; width: 340px; color: var(--dim); cursor: pointer; font-size: 13px;
}
.kbd {
  font-size: 11px; border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 6px; color: var(--dim); margin-left: auto;
}
.sync { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); }
.sync-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--success); }
.sync-dot.busy { background: var(--amber); }
.main-col { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }
.page { padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: var(--r-control); font-weight: 600; font-size: 13px;
  border: 1px solid var(--border); color: var(--text); background: var(--surface-2);
  cursor: pointer; transition: border-color 150ms ease-out, background 150ms ease-out;
  min-height: 36px;
}
.btn:hover { border-color: var(--border-strong); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.icon-only { padding: 8px; }
.input, select.input, textarea.input {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-control);
  color: var(--text); padding: 8px 12px; font-size: 13px; min-height: 36px;
}
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--focus); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--dim); letter-spacing: 0.02em; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--dim);
}
.badge.ok { color: var(--success); border-color: #2c4a38; }
.badge.warn { color: var(--amber); border-color: var(--amber-border); }
.badge.bad { color: var(--danger); border-color: var(--danger-border); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-surface); }

/* ---------- Table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-surface); overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; }
.data th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--dim); padding: 10px 14px;
  border-bottom: 1px solid var(--border); user-select: none;
}
.data td { padding: 10px 14px; border-bottom: 1px solid var(--row-border); vertical-align: middle; }
.data tr.row { cursor: pointer; transition: background 120ms ease-out; }
.data tr.row:hover { background: rgba(255,255,255,0.02); }
.data tr:last-child td { border-bottom: 0; }
.thumb {
  width: 80px; height: 45px; border-radius: var(--r-control); flex-shrink: 0;
  background-size: cover; background-position: center;
  border: 1px solid rgba(255,255,255,0.06); background-color: var(--surface-2);
}
.star-btn { background: none; border: 0; cursor: pointer; color: var(--faint); padding: 4px; border-radius: 4px; }
.star-btn.on { color: var(--accent); }
.star-btn:hover { color: var(--accent-hover); }

/* ---------- Overlays ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(5,7,9,0.55); z-index: 40; animation: fade-in 150ms ease-out; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 96vw;
  background: var(--surface); border-left: 1px solid var(--border-strong);
  box-shadow: -24px 0 60px rgba(0,0,0,0.5); z-index: 41;
  display: flex; flex-direction: column; animation: slide-in 180ms ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-tabs { display: flex; gap: 4px; padding: 8px 22px 0; border-bottom: 1px solid var(--border); }
.drawer-tab {
  padding: 8px 14px; font-weight: 500; font-size: 13px; color: var(--dim);
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
}
.drawer-tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.drawer-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; flex-grow: 1; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 12px; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-surface);
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45); animation: toast-in 180ms ease-out;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.error { border-color: var(--danger-border); color: var(--danger); }
.toast .undo { color: var(--accent); background: none; border: 0; font-weight: 700; cursor: pointer; font-size: 13px; }

.palette-scrim { position: fixed; inset: 0; background: rgba(5,7,9,0.6); z-index: 60; display: flex; justify-content: center; padding-top: 14vh; }
.palette {
  width: 560px; max-width: 92vw; max-height: 420px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-overlay); display: flex; flex-direction: column;
  animation: toast-in 140ms ease-out;
}
.palette input {
  background: none; border: 0; border-bottom: 1px solid var(--border);
  padding: 14px 18px; font-size: 15px; color: var(--text); outline: none; width: 100%;
}
.palette-list { overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border-radius: var(--r-control); cursor: pointer; font-size: 13px; color: var(--text);
}
.palette-item.selected { background: var(--surface-2); }
.palette-item .hint { margin-left: auto; color: var(--dim); font-size: 12px; }

.banner {
  display: flex; align-items: center; gap: 10px; border-radius: var(--r-surface);
  padding: 12px 16px; font-size: 13px;
}
.banner.warn { background: var(--amber-bg); border: 1px solid var(--amber-border); color: var(--amber); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 20px; color: var(--dim); text-align: center; }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-control); }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.2); border-top-color: currentColor; border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Loop trimmer (hover preview): track, window, handles, playhead, labels */
.trim { display: flex; flex-direction: column; gap: 6px; }
.trim-track {
  position: relative; height: 36px; margin: 22px 7px 22px; border-radius: 6px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border);
  touch-action: none; user-select: none; cursor: pointer;
}
.trim-window {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 28%, transparent); border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent);
  cursor: grab;
}
.trim-window:active { cursor: grabbing; }
.trim-length {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 5px;
  font-size: 12px; font-weight: 600; color: var(--accent); pointer-events: none; white-space: nowrap;
}
.trim-handle {
  position: absolute; top: -3px; bottom: -3px; width: 14px; margin-left: -7px; padding: 0; z-index: 2;
  background: var(--accent); border: 0; border-radius: 4px; cursor: ew-resize;
}
.trim-handle::after { content: ''; position: absolute; top: 10px; bottom: 10px; left: 6px; width: 2px; background: var(--accent-ink); opacity: 0.55; border-radius: 1px; }
.trim-handle:hover { background: var(--accent-hover); }
.trim-handle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.trim-playhead { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--text); opacity: 0.85; pointer-events: none; z-index: 1; }
.trim-label { position: absolute; top: 100%; margin-top: 4px; font-size: 11px; color: var(--dim); white-space: nowrap; pointer-events: none; }
.trim-label.in { transform: translateX(-100%); padding-right: 9px; }
.trim-label.out { padding-left: 9px; }
.trim-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-top: -4px; }
.trim-note { font-size: 12px; color: var(--amber); }
.trim-hint { font-size: 12px; color: var(--dim); }
.trim .kbd { margin-left: 4px; }
