:root {
  /* --- Color palette (light) --- */
  --color-bg-app: #e8edf4;
  --color-bg-surface: #f7faff;
  --color-bg-panel: #ffffff;
  --color-bg-panel-alt: #f3f7fd;
  --color-bg-toolbar: #eff4fc;
  --color-bg-deep: #e8edf4;

  --color-border: #d0d8e5;
  --color-border-strong: #91a5be;

  --color-text: #162133;
  --color-text-secondary: #516074;
  --color-text-muted: #5e7088;

  --color-accent: #2563eb;
  --color-accent-dark: #1d4ed8;
  --color-accent-darker: #1e40af;
  --color-accent-2: #12c583;
  --color-accent-3: #d946ef;
  --color-danger: #d9415f;
  --color-danger-hover: #d11b40;

  --color-topbar-bg: rgba(247, 250, 255, 0.9);
  --color-glow-a: rgba(37, 99, 235, 0.14);
  --color-glow-b: rgba(34, 163, 116, 0.12);
  --color-focus-ring: rgba(37, 99, 235, 0.18);

  --gradient-primary: linear-gradient(180deg, #4e92ff, #2563eb);
  --gradient-accent: linear-gradient(180deg, #3b89ff, #00c382);
  --gradient-magic: linear-gradient(180deg, #f43f5e, #d946ef);

  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  --shadow-xs: 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 6px 14px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 16px 34px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 34px rgba(15, 23, 42, 0.1);

  --space-xs: 2px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 999px;

  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-md: 13px;
  --font-size-base: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;
  --font-size-3xl: 24px;
  --font-size-4xl: 28px;

  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-heading: "Space Grotesk", "IBM Plex Sans", sans-serif;
  --font-mono: "JetBrains Mono", "Roboto Mono", monospace;

  --transition-fast: all 0.15s ease;
  --transition-base: all 0.2s ease;
  --transition-spring: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  --timeline-label-w: 140px;
}

/* Dark theme overrides */
:root[data-theme="dark"] {
  --color-bg-app: #0a111f;
  --color-bg-surface: #0f192d;
  --color-bg-panel: #131f34;
  --color-bg-panel-alt: #182843;
  --color-bg-toolbar: #111f37;
  --color-bg-deep: #0a111f;

  --color-border: #263852;
  --color-border-strong: #3f5576;

  --color-text: #e2ebfb;
  --color-text-secondary: #a3b9da;
  --color-text-muted: #97aac7;

  --color-accent: #5d92ff;
  --color-accent-dark: #4b82f1;
  --color-accent-darker: #325fd0;
  --color-accent-2: #32c489;
  --color-danger: #ff6c85;

  --color-topbar-bg: rgba(22, 36, 61, 0.9);
  --color-glow-a: rgba(93, 146, 255, 0.18);
  --color-glow-b: rgba(50, 196, 137, 0.12);
  --color-focus-ring: rgba(93, 146, 255, 0.24);

  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-lg: 0 20px 36px rgba(0, 0, 0, 0.38);
  --shadow-sm: 0 8px 14px rgba(0, 0, 0, 0.26);
  --shadow-xs: 0 2px 4px rgba(0, 0, 0, 0.16);
}

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

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

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: radial-gradient(circle at 10% 0%, var(--color-glow-a), transparent 42%), radial-gradient(circle at 90% 2%, var(--color-glow-b), transparent 34%), linear-gradient(180deg, var(--color-bg-surface) 0%, var(--color-bg-app) 100%);
}

h3,
h4 {
  margin: 0 0 10px;
  font-family: var(--font-heading);
  letter-spacing: 0.02em;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-3) 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* --- Button base --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  cursor: pointer;
  transition:
    opacity 0.2s ease,
    transform 0.15s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: 1px solid var(--color-accent);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
  border: 1px solid var(--color-danger);
}

.btn-danger:not(:disabled):hover {
  background: var(--color-danger-hover);
}

.btn-danger-outline {
  background: var(--color-bg-panel);
  border: 1px solid rgba(217, 65, 95, 0.4);
  color: var(--color-danger);
}

.btn-secondary {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-rounded {
  border-radius: var(--radius-full);
}

.btn:not(:disabled, .btn-primary, .btn-magic, .btn-danger, .btn-danger-outline, .btn-green):hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-panel-alt);
  box-shadow: var(--shadow-sm);
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  color: var(--color-text);
  background-color: var(--color-bg-panel);
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid transparent;
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

textarea {
  resize: vertical;
  min-height: 74px;
}

input[type="color"] {
  padding: 2px;
  min-height: 32px;
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--color-accent);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: linear-gradient(to right, var(--color-accent) var(--progress, 0%), var(--color-border) var(--progress, 0%));
  border-radius: var(--radius-full);
  outline: none;
  padding: 0;
  margin: 0;
  border: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--color-accent);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  margin-top: -1px;
  transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 4px var(--color-focus-ring);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--color-accent);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  border: none;
  transition: var(--transition-fast);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 4px var(--color-focus-ring);
}

input[type="range"]::-moz-range-track {
  background: transparent;
}

.range-with-value {
  flex-direction: row !important;
  align-items: center;
  gap: var(--space-1);
}

.range-with-value input[type="range"] {
  flex: 1;
}

.range-value-display {
  max-width: 35px;
  height: unset;
  text-align: center;
  color: var(--color-accent);
  font-weight: 600;
  font-size: var(--font-size-sm);
  border: none;
  background: transparent;
  padding: var(--space-2) 0;
  cursor: default;
  outline: none !important;
  box-shadow: none !important;
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 32px;
  background: var(--color-bg-panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235e7088' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 14 18 9'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
  cursor: pointer;
}

:root[data-theme="dark"] select {
  background: var(--color-bg-panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2397aac7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 14 18 9'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
}

/* Dropdown selects */
.dropdown-group select.dropdown-select {
  background: var(--color-bg-deep) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235e7088' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 14 18 9'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
  cursor: pointer;
}
:root[data-theme="dark"] .dropdown-group select.dropdown-select {
  background: var(--color-bg-deep) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2397aac7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 14 18 9'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
}

details summary {
  cursor: pointer;
}

.dark-textarea {
  background: var(--color-bg-deep);
  font-size: var(--font-size-md);
  min-height: 80px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.checkbox {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border-width: 0;
}

.checkbox-custom {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xs);
  background-color: var(--color-bg-panel);
  transition: var(--transition-base);
}

.checkbox:checked + .checkbox-custom {
  border-color: var(--color-accent);
  background-color: var(--color-accent);
}

.checkbox:checked + .checkbox-custom::after {
  content: "✓";
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  line-height: 1;
}

.checkbox:focus-visible + .checkbox-custom {
  box-shadow: 0 0 0 4px var(--color-focus-ring);
}

/* === Button variants === */

.btn-primary {
  color: white;
  background: var(--gradient-primary);
  border-color: var(--color-accent);
}
.btn-primary:not(:disabled):hover {
  opacity: 0.9;
}

.btn-danger-outline {
  background: var(--color-bg-panel);
  border: 1px solid rgba(217, 65, 95, 0.4);
  color: var(--color-danger);
}
.btn-danger-outline:not(:disabled):hover {
  color: white;
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-magic {
  background: var(--gradient-magic);
  border: 1px solid var(--color-accent-3);
  color: white;
  padding-block: 9px;
}
.btn-magic:not(:disabled):hover {
  opacity: 0.9;
}

.btn-green {
  background: var(--gradient-accent);
  border: 1px solid var(--color-accent-2);
  color: white;
}
.btn-green:not(:disabled):hover {
  opacity: 0.9;
}

/* Size modifiers */
.btn-lg {
  font-size: var(--font-size-base);
  padding: 10px 16px;
}

.btn-md {
  font-size: var(--font-size-md);
}

.btn-md i {
  font-size: var(--font-size-base);
}

.btn-sm {
  font-size: var(--font-size-sm);
}

.btn-xs {
  padding: 0 8px;
  height: 28px;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-full);
  gap: var(--space-1);
}

.editor-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.main-layout {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
}

/* === Topbar / Header === */

.app-header {
  position: relative;
  z-index: 100;
  height: 58px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  backdrop-filter: blur(24px) saturate(180%);
  border-radius: var(--radius-xl);
  background: var(--color-topbar-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  box-shadow: var(--shadow-inset), var(--shadow-sm);
}

.topbar-left {
  display: flex;
  height: 100%;
  align-items: center;
  gap: var(--space-3);
}

/* Brand / Logo */
.brand-block {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  user-select: none;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 35px;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

[data-theme="dark"] .brand-logo img {
  filter: invert(1) brightness(100%);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-title {
  font-weight: 700;
  font-size: var(--font-size-xl);
  letter-spacing: -0.02em;
}

.brand-kicker {
  font-size: var(--font-size-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.9;
  margin-top: 2px;
}

/* Topbar navigation menu */
.topbar-menu {
  display: flex;
  height: 100%;
  align-items: center;
  gap: var(--space-xs);
}

/* Menu dropdown */
.menu-dropdown {
  height: 100%;
  display: flex;
  align-items: center;
  position: relative;
}

.menu-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  padding: 6px var(--space-2);
  font-size: var(--font-size-md);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: var(--transition-fast);
}

.menu-trigger i {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
}

.menu-trigger .chev {
  font-size: var(--font-size-base);
  opacity: 0.7;
}

.menu-dropdown:hover .menu-trigger {
  background: var(--color-bg-surface);
  color: var(--color-accent);
}

.menu-dropdown:hover .menu-trigger i {
  color: var(--color-accent);
}

/* Dropdown panel */
.dropdown-content {
  position: absolute;
  top: calc(100% - 10px);
  left: 0;
  margin-top: var(--space-1);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  min-width: 200px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: var(--transition-spring);
  z-index: 50;
  pointer-events: none;
}

.menu-dropdown:hover .dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-content-wide {
  min-width: 280px;
  padding: var(--space-3);
}

.dropdown-header {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
  padding: 4px var(--space-2);
  letter-spacing: 0.05em;
}

.dropdown-item {
  justify-content: start;
  gap: 10px;
  width: 100%;
  padding: var(--space-2) 10px;
  background: transparent;
  border-color: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  color: var(--color-text);
}

.dropdown-item i {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
}

.dropdown-item:not(:disabled):hover {
  background: var(--color-bg-surface);
  color: var(--color-accent);
  border-color: transparent;
  box-shadow: none;
}

.dropdown-item:not(:disabled):hover i {
  color: var(--color-accent);
}

.dropdown-item-wrapper {
  position: relative;
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-1) 0;
}

.dropdown-group {
  margin-bottom: 10px;
}

.dropdown-group label,
.dropdown-label {
  display: block;
  font-size: var(--font-size-xs);
  margin-bottom: var(--space-1);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.dropdown-row {
  display: flex;
  gap: var(--space-2);
}

.dropdown-row .dropdown-group {
  flex: 1;
}

.dropdown-group .dropdown-input,
.dropdown-group .dropdown-select {
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-deep);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  color: var(--color-text);
}

.nav-projects-list {
  max-height: 250px;
  overflow-y: auto;
}

.nav-projects-list .dropdown-item {
  padding: var(--space-1) 10px;
}

/* Credits display */
.credits-display {
  gap: var(--space-2);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  padding: 4px 6px 4px var(--space-3);
  border-radius: var(--radius-full);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.credits-display .credit-icon {
  font-size: var(--font-size-lg);
  color: var(--color-accent);
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 4px var(--color-glow-a));
}

.credits-display .count {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}

/* Top-up button */
.btn-topup {
  font-size: var(--font-size-sm);
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-accent);
  border: 1px solid transparent;
  font-weight: 600;
}

.btn-topup:not(:disabled):hover {
  color: white;
  background: var(--gradient-primary);
  border-color: var(--color-accent);
}

.btn-topup i {
  font-size: var(--font-size-base);
}

/* Workspace mode badge */
.workspace-mode {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 14px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  pointer-events: auto;
  box-shadow: var(--shadow-xs);
}

.workspace-mode i {
  font-size: var(--font-size-base);
  font-weight: normal;
  color: var(--color-accent);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 33px;
  height: 33px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  transition: var(--transition-base);
  cursor: pointer;
}

.theme-toggle-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--color-bg-panel-alt);
  box-shadow: 0 0 10px var(--color-focus-ring);
  transform: translateY(-1px);
}

/* User avatar button */
.user-profile-btn {
  height: auto;
  width: auto;
  gap: 3px;
  border-radius: var(--radius-full);
  padding: var(--space-1);
}

.user-profile-name {
  font-size: var(--font-size-md);
  font-weight: 600;
  display: none;
  margin: 0 5px 0 2px;
}

.user-dropdown.not-logged-in .user-profile-name {
  display: block;
}

.menu-dropdown:hover .user-profile-btn,
.user-profile-btn:hover {
  box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.user-profile-gradient {
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
}

.user-profile-btn .profile-chevron {
  transition: transform 0.2s ease;
}

.user-dropdown:hover .profile-chevron {
  transform: rotate(180deg);
}

.user-dropdown .user-dropdown-content {
  right: 0;
  left: auto;
}

.user-dropdown .logout-btn,
.user-dropdown .logout-btn i {
  color: var(--color-danger) !important;
}

/* === Sidebar (left & right panels) === */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  position: relative;
  min-height: 0;
  overflow: visible;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.left-sidebar {
  width: 380px;
  flex-direction: row;
  animation: slideInLeft 0.35s ease;
}

.right-sidebar {
  width: 340px;
  flex-direction: row-reverse;
  animation: slideInRight 0.35s ease;
}

.sidebar.collapsed {
  width: 65px;
}

.sidebar.collapsed .sidebar-content {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.left-sidebar.collapsed .btn-collapse .icon-wrap i {
  transform: rotate(180deg);
}

.right-sidebar.collapsed .btn-collapse .icon-wrap i {
  transform: rotate(0deg);
}

.right-sidebar .btn-collapse .icon-wrap i {
  transform: rotate(180deg);
}

/* Tab navigation bar */
.sidebar-tabs {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 65px;
  gap: var(--space-1);
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  align-items: center;
  padding-bottom: var(--space-2);
}

.sidebar.collapsed .sidebar-tabs {
  border-radius: var(--radius-xl);
}

.sidebar-tabs .tabs-divider {
  width: 100%;
  height: 1px;
  background: var(--color-border);
  margin: var(--space-1) 0;
  opacity: 0.6;
}

.sidebar-tabs .nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px var(--space-1);
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-family: inherit;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-base);
}

.sidebar-tabs .nav-item .icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  font-weight: normal;
  transition: transform var(--transition-base);
}

.sidebar-tabs .nav-item .tab-label {
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  font-size: var(--font-size-xs);
  transition: var(--transition-base);
}

.sidebar-tabs .nav-item:hover {
  background: var(--color-bg-app);
  color: var(--color-text);
}

.sidebar-tabs .nav-item:hover .icon-wrap {
  transform: scale(1.1);
}

.sidebar:not(.collapsed) .sidebar-tabs .nav-item.active {
  color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

.sidebar-tabs .active-indicator {
  position: absolute;
  left: -3px;
  top: 50%;
  transform: translateY(-50%) scaleX(0);
  width: 3px;
  height: 70%;
  background: var(--color-accent);
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: right;
}

.sidebar:not(.collapsed) .sidebar-tabs .nav-item.active .active-indicator {
  transform: translateY(-50%) scaleX(1);
}

.sidebar:not(.collapsed) .sidebar-tabs .nav-item.tab-ai.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.15) 0%, rgba(217, 70, 239, 0.05) 100%);
  color: var(--color-accent);
}

.sidebar-tabs .nav-item.tab-ai {
  border-radius: var(--radius-xl) 0 0 0;
}

.sidebar.collapsed .nav-item.tab-ai:hover,
.sidebar.collapsed .nav-item.tab-ai.active {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.sidebar-tabs .nav-item.tab-inspector {
  border-radius: 0 var(--radius-xl) 0 0;
}

.sidebar.collapsed .sidebar-tabs .nav-item.tab-inspector.active {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.sidebar-tabs .nav-item.tab-ai .icon-wrap i {
  background: -webkit-linear-gradient(45deg, var(--color-accent), var(--color-accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  font-size: 22px;
  -webkit-text-fill-color: transparent;
}

.sidebar-tabs .nav-item.tab-ai.active .active-indicator {
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent-3));
}

.right-sidebar .sidebar-tabs {
  border-right: none;
  border-left: 1px solid var(--color-border);
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
}

.right-sidebar .sidebar-tabs .active-indicator {
  left: auto;
  right: -3px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  transform-origin: left;
}

/* Sidebar body */
.sidebar-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--color-bg-panel);
  opacity: 1;
  transition: opacity 0.3s 0.25s ease;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-content {
  opacity: 0;
  transition: opacity 0.1s ease;
}

.left-sidebar .sidebar-content {
  width: 308px;
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
}

.right-sidebar .sidebar-content {
  width: 278px;
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

/* Panel views */
.panel-view {
  display: none;
  height: 100%;
  flex-direction: column;
  animation: fadeIn 0.15s ease-out;
}

.panel-view.active {
  display: flex;
}

.panel-header {
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-panel-alt);
  border-radius: 0 var(--radius-xl) 0 0;
}

.right-sidebar .panel-header {
  border-radius: 0;
}

.panel-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
}

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-panel);
}

/* === Media View === */

.search-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-input-wrapper i {
  position: absolute;
  left: 10px;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  padding: 8px 8px 8px 34px;
  border-radius: var(--radius-md);
  background: var(--color-bg-deep);
  border: 1px solid transparent;
  font-size: var(--font-size-md);
}

/* Sort dropdown */
.sort-dropdown-wrapper {
  position: relative;
}

.sort-trigger i {
  font-size: 15px;
}

.sort-select-hidden {
  display: none;
}

.custom-sort-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  min-width: 140px;
  padding: var(--space-1);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: var(--transition-spring);
}

.sort-dropdown-wrapper:hover .custom-sort-menu,
.sort-dropdown-wrapper:focus-within .custom-sort-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sort-menu-header {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 700;
  padding: 6px 12px var(--space-1);
  letter-spacing: 0.03em;
}

.sort-option {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.sort-option:hover {
  background: var(--color-bg-surface);
  color: var(--color-accent);
}

.sort-option.active {
  color: var(--color-accent);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
}

.sort-dropdown-wrapper.closed .custom-sort-menu {
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  pointer-events: none;
}

/* Upload drop zone */
.upload-zone {
  margin: var(--space-3);
  padding: 24px var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  background: var(--color-bg-surface);
  transition: var(--transition-base);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-accent);
  background: var(--color-bg-deep);
  transform: translateY(-1px);
}

.upload-graphic {
  width: 44px;
  height: 44px;
  background: var(--color-glow-a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 22px;
}

.upload-text {
  text-align: center;
}

.upload-text .primary-text {
  display: block;
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.upload-text .secondary-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Section divider */
.section-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-surface);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.section-title {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

.count-badge {
  font-size: var(--font-size-xs);
  padding: 2px var(--space-2);
  background: var(--color-bg-panel);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-weight: 600;
  border: 1px solid var(--color-border);
}

/* Media card grid */
.media-grid {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  align-content: start;
}

.media-grid .file-item {
  position: relative;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  padding: 7px;
  flex-direction: column;
  transition: var(--transition-base);
  cursor: pointer;
}

.media-grid .file-item:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.media-grid .file-item img,
.media-grid .file-item video {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  max-height: 100px;
  object-fit: cover;
}

.media-grid .file-item .audio-thumb,
.media-grid .file-item .file-thumb {
  height: 78px;
  display: grid;
  place-items: center;
  font-size: var(--font-size-3xl);
  border-radius: var(--radius-md);
  background: var(--color-bg-deep);
}

[data-theme="dark"] .media-grid .file-item .audio-thumb,
[data-theme="dark"] .media-grid .file-item .file-thumb {
  background: var(--color-bg-panel-alt);
}

.media-grid .file-item .asset-label {
  font-size: var(--font-size-sm);
  padding: 7px 0 5px 3px;
  font-weight: 500;
  color: var(--color-text);
  margin-top: auto;
}

.media-grid .file-item .asset-usage {
  margin-top: 2px;
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 500;
  width: fit-content;
  color: var(--color-text-muted);
  background: var(--color-bg-deep);
  border-radius: var(--radius-full);
  padding: 2px var(--space-2);
}

.media-grid .file-item.used .asset-usage {
  background: #e7f6ee;
  color: #166534;
}

.media-grid .file-item .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  font-size: 10px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
}

.media-grid .file-item:hover .delete-btn {
  opacity: 1;
}

/* Empty state placeholder */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state.small {
  padding: var(--space-5) 0;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--space-4);
  background: var(--color-bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 6px;
}

.empty-state p {
  font-size: var(--font-size-md);
  margin: 0;
  opacity: 0.8;
  max-width: 200px;
  line-height: 1.5;
}

.scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
}

.control-group {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: var(--shadow-inset), var(--shadow-xs);
}

.group-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: var(--space-1);
  letter-spacing: 0.03em;
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

.input-wrapper label {
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
  font-weight: 500;
}

.input-wrapper input:not([type="range"], .range-value-display),
.input-wrapper select:not([type="range"], .range-value-display) {
  font-size: var(--font-size-md);
  padding: 0 var(--space-2);
  height: 32px;
  background-color: var(--color-bg-panel);
}

.color-input input[type="color"] {
  padding: 2px;
}

.segmented-control {
  display: flex;
  overflow-x: auto;
  position: relative;
  background: var(--color-bg-deep);
  padding: var(--space-1);
  border-radius: var(--radius-md);
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  border: 1px solid var(--color-border);
  --mask-start: black;
  --mask-end: black;
  -webkit-mask-image: linear-gradient(to right, var(--mask-start), black 30px, black calc(100% - 25px), var(--mask-end));
  mask-image: linear-gradient(to right, var(--mask-start), black 30px, black calc(100% - 25px), var(--mask-end));
}

.segment-btn {
  flex: 1;
  white-space: nowrap;
  background: transparent;
  border: none;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  cursor: pointer;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  display: flex;
  justify-content: center;
  align-items: center;
}

.segment-btn:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.03);
}

.segment-btn.active {
  background: var(--color-bg-panel);
  color: var(--color-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.bg-tab-content {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.bg-tab-content.active {
  display: block;
}

.background-panel .section-divider {
  border-bottom: 0;
  margin-bottom: 0;
}

.playback-panel .input-wrapper {
  flex-direction: row;
  align-items: center;
}

.timeline-group {
  flex: 1;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.list-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.projects-list {
  max-height: 400px;
}

/* === Layers / Asset List === */

.asset {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 10px;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: var(--transition-base);
}

.asset:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.asset .thumb {
  width: 36px;
  height: 36px;
  background: var(--color-bg-deep);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  position: relative;
}

.asset .meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.asset .meta strong {
  font-size: var(--font-size-md);
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.asset .meta small {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: capitalize;
}

.asset .badge {
  font-size: var(--font-size-xs);
  padding: 2px 6px;
  background: var(--gradient-primary);
  border: 1px solid var(--color-accent);
  color: white;
  border-radius: var(--radius-xs);
  font-weight: 600;
  margin-left: auto;
}

.asset .actions button {
  padding: 5px 10px;
  font-size: var(--font-size-sm);
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.asset .actions button:hover {
  background: var(--color-bg-surface);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* === Projects View === */

.pm-project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  gap: var(--space-3);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  cursor: default;
  transition: var(--transition-base);
}

.pm-project-item:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.pm-project-item.active {
  border-color: var(--color-accent);
  background: var(--color-bg-surface);
}

.pm-project-info {
  display: flex;
  flex-direction: column;
}

.pm-project-name {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
  word-break: break-word;
}

.pm-project-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.project-actions {
  display: flex;
  gap: 6px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.pm-project-item:hover .project-actions {
  opacity: 1;
}

.pm-load-btn,
.pm-delete-btn {
  padding: 5px 10px;
  font-size: var(--font-size-sm);
  height: 24px;
  border-radius: var(--radius-sm);
}

.pm-delete-btn {
  color: var(--color-danger);
  border-color: transparent;
  background: transparent;
}

.pm-delete-btn:hover {
  background: rgba(217, 65, 95, 0.1);
  border-color: rgba(217, 65, 95, 0.2);
}

/* === Caption List Items === */
.caption-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-3);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: var(--transition-base);
  font-size: var(--font-size-md);
  color: var(--color-text);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.caption-item:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-panel-alt);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.caption-item.active {
  border-color: var(--color-accent);
  background: var(--color-bg-surface);
}

.caption-item .time {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.caption-item .text {
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

.caption-item .meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: flex;
  gap: 8px;
  margin-top: 2px;
  opacity: 0.8;
  font-weight: 500;
}

/* === Inspector Panel === */

.filter-group {
  gap: var(--space-1);
}

.filter-group .group-label {
  margin-bottom: var(--space-3);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--space-2);
}

.filter-row .filter-label {
  flex: 0 0 100%;
  font-weight: 500;
  color: var(--color-text-muted);
}

.filter-row input[type="range"] {
  flex: 1;
}

.srt-wrapper {
  position: relative;
  width: 100%;
}

input[type="file"].custom-file-input {
  padding: 6px;
}

.center-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
  position: relative;
  min-height: 0;
}

/* === AI Studio Panel === */

.ai-tab {
  display: none;
}

.ai-tab.active {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  animation: fadeIn 0.2s ease-out;
}

.ai-style-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.ai-style-chip {
  padding: 6px var(--space-2);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: var(--transition-base);
}

.ai-style-chip:hover:not(.active) {
  background: var(--color-bg-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.ai-style-chip.active,
.ai-style-chip.active:hover {
  color: white;
  background: var(--gradient-primary);
  border-color: var(--color-accent);
}

.ai-negative-wrap {
  border-top: 1px dashed var(--color-border);
  padding-top: var(--space-2);
}

.ai-config-panel {
  border-top: 1px solid var(--color-border);
}

.ai-params-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: var(--space-3);
  align-items: flex-end;
}

.ai-params-row .input-wrapper.flex-center {
  height: 32px;
}

.ai-params-row .checkbox-label {
  font-size: var(--font-size-sm);
}

.ai-generate-btn {
  padding-inline: var(--space-5);
}

.ai-gen-meta {
  gap: 5px;
  font-size: var(--font-size-md);
  color: var(--color-text-muted);
}

.ai-jobs-list {
  min-height: 40px;
  font-size: var(--font-size-md);
  color: var(--color-text-muted);
}

.ai-jobs-list.empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Jobs Queue Items */
.ai-job-item {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  transition: var(--transition-fast);
}

.ai-job-item:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-xs);
}

.ai-job-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.ai-job-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.ai-job-status {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  width: fit-content;
  margin-top: var(--space-1);
  border-radius: var(--radius-full);
}

.ai-job-status--pending {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}
.ai-job-status--running {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}
.ai-job-status--succeeded {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}
.ai-job-status--failed {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* === Video Workspace === */

.video-workspace {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-height: 0;
}

/* Canvas stage*/
.vw-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0c0c0c;
  background-image: linear-gradient(45deg, #141414 25%, transparent 25%), linear-gradient(-45deg, #141414 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #141414 75%), linear-gradient(-45deg, transparent 75%, #141414 75%);
  background-size: 18px 18px;
  background-position:
    0 0,
    0 9px,
    9px -9px,
    -9px 0;
  border-radius: var(--space-3);
  overflow: hidden;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--color-border),
    var(--shadow-lg);
}

.vw-canvas-wrap {
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 10px 40px rgba(0, 0, 0, 0.55);
}

canvas#viewer {
  display: block;
  width: 100%;
  height: 100%;
}

/* === Viwer Control Bar === */

.vw-bar {
  flex-shrink: 0;
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 5px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.vw-playback-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 var(--space-3);
  background: linear-gradient(to bottom, var(--color-bg-panel), var(--color-bg-surface));
  border-bottom: 1px solid var(--color-border);
}

.vw-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

.vw-group.center {
  justify-content: center;
}
.vw-group.right {
  justify-content: flex-end;
}

.vw-tools-section {
  display: flex;
  overflow-x: auto;
  align-items: center;
  scrollbar-width: none;
  justify-content: space-between;
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--color-bg-panel-alt);
}

.vw-tool-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* Play/stop button  */
.vw-play-main {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border-color: var(--color-accent);
  background: var(--gradient-primary);
  color: #fff;
  font-size: var(--font-size-2xl);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vw-play-main:not(:disabled):hover {
  border: 1px solid var(--color-accent);
  background: var(--gradient-primary);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.vw-play-main.is-playing {
  background: var(--color-text);
  color: var(--color-bg-surface);
  border-color: var(--color-border);
}

.vw-play-main.is-playing:not(:disabled):hover {
  background: var(--color-text);
  color: var(--color-bg-surface);
  border-color: var(--color-border);
}

.vw-btn-icon {
  height: 32px;
  min-width: 32px;
  flex-shrink: 0;
  padding: 0 var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  gap: var(--space-2);
  font-size: var(--font-size-md);
  font-weight: 600;
  transition: var(--transition-spring);
}

.vw-skip-btn {
  width: 32px;
  border-radius: var(--radius-full);
}

.vw-skip-btn:not(:disabled):hover {
  transform: scale(1.05);
}

.vw-btn-icon i {
  font-size: 15px;
}

.vw-btn-icon:hover {
  background: var(--color-bg-panel);
  color: var(--color-accent);
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}

.vw-tool-btn {
  height: 28px;
  padding: 0 10px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border-color: transparent;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
  gap: var(--space-2);
  transition: var(--transition-fast);
}

.vw-tool-btn i {
  font-size: var(--font-size-md);
}

.vw-tool-btn:hover {
  background: var(--color-bg-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.vw-toggle-btn {
  height: 28px;
  width: 28px;
  border-radius: var(--radius-sm);
  border-color: transparent;
  background: transparent;
  color: var(--color-text-muted);
  transition: var(--transition-fast);
}

.vw-toggle-btn:not(:disabled):hover {
  color: var(--color-text);
  background: var(--color-bg-panel);
}

.vw-toggle-btn.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-accent);
  border-color: rgba(37, 99, 235, 0.2);
}

.vw-divider {
  width: 1px;
  height: 16px;
  background: var(--color-border);
  margin: 0 2px;
}

/* Timecode display */
.vw-timecode {
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-accent);
  background: var(--color-bg-deep);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  letter-spacing: 0.05em;
  text-align: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.vw-select-pill {
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--space-2) 0 10px;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.vw-select-pill:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-surface);
}

.vw-select-pill .icon {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
}

.vw-select-pill .label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: var(--transition-fast);
}

.vw-select-pill:hover .label {
  color: var(--color-text);
}

.vw-select-pill .chev {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-left: auto;
}

.vw-select-pill select {
  position: absolute;
  inset: 0;
  opacity: 0;
  font-size: var(--font-size-base);
  cursor: pointer;
  width: 100%;
}

/* Toggle chip */
.toggle-chip {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-panel);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  transition: var(--transition-fast);
}

.toggle-chip:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-surface);
  color: var(--color-text);
}

.toggle-chip .checkbox-custom {
  width: 13px;
  height: 13px;
}

/* === Timeline === */

.tl-workspace {
  flex-shrink: 0;
  height: 260px;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--space-3);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tl-workspace.collapsed {
  height: 46px;
  min-height: 46px;
}

.tl-workspace.collapsed .tl-body {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.btn-tl-collapse {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--color-text-muted);
}

.btn-tl-collapse:hover {
  color: var(--color-accent);
}

.btn-tl-collapse i {
  font-size: var(--font-size-xl);
  transition: transform 0.5s ease;
}

.tl-workspace.collapsed .btn-tl-collapse i {
  transform: rotate(180deg);
}

/* Timeline header bar */
.tl-header {
  flex-shrink: 0;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 46px;
  background: var(--color-bg-panel);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-3);
}

.tl-header__left,
.tl-header__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tl-header__left {
  min-width: 0;
  transition: opacity 0.3s ease;
}

.tl-header__right {
  transition: opacity 0.3s ease;
}

.tl-workspace.collapsed .tl-header__right {
  opacity: 0;
  pointer-events: none;
}

.tl-header__title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tl-header__title i {
  font-size: 15px;
  color: var(--color-accent);
}

.tl-header__title h3 {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text);
}

.tl-vsep {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  flex-shrink: 0;
}

.tl-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.tl-zoom i {
  font-size: var(--font-size-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: var(--transition-base);
}

.tl-zoom i:hover {
  color: var(--color-accent);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}

.tl-zoom i:active {
  transform: translateY(0);
  background: var(--color-bg-deep);
}

.tl-zoom input[type="range"] {
  width: 88px;
  height: 3px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.tl-add-track {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 3px 3px 3px 0;
}

.tl-type-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.tl-type-select {
  border: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: 3px 15px 3px 10px;
  box-shadow: none !important;
}

.tl-type-select option {
  font-size: var(--font-size-md);
}

.tl-type-wrap .tl-type-select {
  background: var(--color-bg-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2397aac7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 14 18 9'/%3E%3C/svg%3E") no-repeat right 10px center / 14px !important;
}

.btn.tl-btn-add {
  gap: var(--space-1);
  height: 24px;
  padding: 0 10px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
}

.tl-btn-del {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

/* Timeline scroll body */
.tl-body {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  background: var(--color-bg-deep);
  position: relative;
}

.tl-canvas {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

/* Time ruler */
.tl-ruler {
  position: sticky;
  top: 0;
  height: 26px;
  background: linear-gradient(to bottom, var(--color-bg-panel), var(--color-bg-surface));
  border-bottom: 1px solid var(--color-border);
  user-select: none;
  overflow: hidden;
}

.ruler-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--color-text-muted);
  margin-top: 10px;
}

.ruler-tick span {
  position: absolute;
  bottom: calc(100% - 6px);
  left: 4px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Tracks container */
.tl-tracks {
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 100%;
}

/* Track / Clip Elements */
.track {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 48px;
  border-bottom: 1px solid var(--color-border);
  transition: opacity 0.15s;
}

.track:last-child {
  border-bottom: none;
}
.track.muted {
  opacity: 0.45;
}
.track.locked {
  background: repeating-linear-gradient(135deg, transparent, transparent 6px, color-mix(in srgb, var(--color-border) 50%, transparent) 6px, color-mix(in srgb, var(--color-border) 50%, transparent) 7px);
}

.track .label {
  width: var(--timeline-label-w);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-2);
  background: linear-gradient(to bottom, var(--color-bg-surface), var(--color-bg-panel));
  border-right: 1px solid var(--color-border);
  z-index: 5;
  position: sticky;
  left: 0;
  gap: var(--space-1);
}

.track .label-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  letter-spacing: 0.02em;
}

.track-tools {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.track-lock-btn,
.track-mute-btn {
  width: 21px;
  height: 21px;
  padding: 0;
  border-radius: var(--radius-xs);
  border-color: var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.track-lock-btn:hover,
.track-mute-btn:hover {
  color: var(--color-text);
}

.btn.track-lock-btn.active {
  color: #fff;
  background: var(--color-accent-3);
  border-color: var(--color-accent-3);
}
.btn.track-mute-btn.active {
  color: #fff;
  background: var(--color-accent);
  border-color: var(--color-accent);
}

/* Strip (clip area) */
.stripline {
  flex: 1;
  position: relative;
  overflow: visible;
}

/* Playhead */
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ffdf75;
  z-index: 30;
  transform: translateX(-50%);
}

.playhead::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  cursor: ew-resize;
  background: #ffdf75;
  transform: rotate(45deg);
}

/* Clips */
.clip {
  position: absolute;
  top: 4px;
  height: calc(100% - 8px);
  border-radius: 5px;
  overflow: hidden;
  cursor: grab;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.15s;
  min-width: 16px;
  user-select: none;
}

.clip:active {
  cursor: grabbing;
}

.clip.video {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
}
.clip.audio {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
}
.clip.overlay {
  background: linear-gradient(180deg, #7c3aed 0%, #6d28d9 100%);
}
.clip.caption {
  background: linear-gradient(180deg, #ea580c 0%, #c2410c 100%);
}

.clip.selection {
  border-color: rgba(255, 255, 255, 0.65);
  box-shadow:
    0 0 0 2px var(--color-accent),
    0 2px 8px rgba(0, 0, 0, 0.35);
  z-index: 10;
}

/* Resize handles */
.handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  background: rgba(255, 255, 255, 0.25);
  opacity: 0;
  transition: opacity 0.15s;
  cursor: ew-resize;
  z-index: 5;
}

.clip:hover .handle,
.clip.selection .handle {
  opacity: 1;
}

.handle.left {
  left: 0;
  border-radius: 4px 0 0 4px;
}
.handle.right {
  right: 0;
  border-radius: 0 4px 4px 0;
}

/* Frame thumbnails strip */
.frames {
  display: flex;
  align-items: stretch;
  height: 100%;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
  border-radius: 4px;
}

.frame {
  flex-shrink: 0;
  overflow: hidden;
}
.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.82;
}

.text-clip {
  display: flex;
  align-items: center;
  padding: 0 var(--space-2);
  height: 100%;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kf-lane {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12px;
  pointer-events: none;
}

.kf-diamond {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #facc15;
  border: 1.5px solid rgba(0, 0, 0, 0.4);
  transform: rotate(45deg);
  top: 2px;
  border-radius: 1px;
  pointer-events: none;
}

/* === Loading Screen === */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  background: rgba(10, 17, 31, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.25s ease;
}

.loading-screen.visible {
  display: flex;
}

.loading-screen .loader {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(from 0deg, var(--color-accent), var(--color-accent-3) 90deg, rgba(255, 255, 255, 0.15) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 0);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.loading-screen .message {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.01em;
  text-align: center;
  max-width: 280px;
  line-height: 1.5;
}

/* === Toast Notifications === */
.toast-container {
  pointer-events: none;
  position: fixed;
  top: var(--space-3);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0 var(--space-3);
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  border-left-width: 4px;
  background-color: var(--color-bg-panel-alt);
  padding: var(--space-3);
  color: var(--color-text);
  opacity: 0;
  max-width: 370px;
  transform: translateY(-8px) scale(0.95);
  filter: blur(2px) saturate(0.9);
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0) saturate(1);
}

.toast.hide {
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  filter: blur(2px) saturate(0.9);
}

.toast-icon {
  display: inline-flex;
  height: 32px;
  width: 32px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
}

.toast.toast-success .toast-icon svg path {
  fill: var(--color-accent-2);
}

.toast.toast-warning .toast-icon svg path {
  fill: #f59e0b;
}

.toast.toast-error .toast-icon svg path {
  fill: var(--color-danger);
}

.toast.toast-info .toast-icon svg path {
  fill: var(--color-accent);
}

.toast-text {
  flex: 1;
  font-size: var(--font-size-base);
  font-weight: 500;
}

.toast-close {
  display: flex;
  height: 35px;
  width: 35px;
  flex-shrink: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  transition: var(--transition-base);
}

.toast-close:hover {
  background-color: var(--color-bg-surface);
  color: var(--color-text);
}

.toast.toast-success {
  border-left-color: var(--color-accent-2);
}

.toast.toast-warning {
  border-left-color: #f59e0b;
}

.toast.toast-error {
  border-left-color: var(--color-danger);
}

.toast.toast-info {
  border-left-color: var(--color-accent);
}

/* === Utility Classes === */

.link {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}
.link:hover {
  color: var(--color-accent-2);
  text-decoration: underline;
}

.hidden {
  display: none !important;
}
.w-full {
  width: 100%;
}
.h-full {
  height: 100%;
}

.text-secondary {
  color: var(--color-text-secondary);
}
.text-muted {
  color: var(--color-text-muted);
}
.text-accent {
  color: var(--color-accent);
}
.text-danger {
  color: var(--color-danger);
}

.flex {
  display: flex;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.flex-row {
  display: flex;
  flex-direction: row;
}
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.items-end {
  align-items: flex-end;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.justify-end {
  justify-content: flex-end;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-1 {
  flex: 1;
  min-width: 0;
}
.flex-shrink-0 {
  flex-shrink: 0;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-1 {
  gap: var(--space-1);
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.gap-4 {
  gap: var(--space-4);
}
.gap-5 {
  gap: var(--space-5);
}
.gap-6 {
  gap: var(--space-6);
}

.mt-auto {
  margin-top: auto !important;
}
.mt-1 {
  margin-top: var(--space-1);
}
.mt-2 {
  margin-top: var(--space-2);
}
.mt-3 {
  margin-top: var(--space-3);
}
.mt-4 {
  margin-top: var(--space-4);
}

.mb-1 {
  margin-bottom: var(--space-1);
}
.mb-2 {
  margin-bottom: var(--space-2);
}
.mb-3 {
  margin-bottom: var(--space-3);
}
.mb-4 {
  margin-bottom: var(--space-4);
}

.text-xs {
  font-size: var(--font-size-xs);
}
.text-sm {
  font-size: var(--font-size-sm);
}
.text-md {
  font-size: var(--font-size-md);
}
.text-base {
  font-size: var(--font-size-base);
}
.text-lg {
  font-size: var(--font-size-lg);
}
.text-xl {
  font-size: var(--font-size-xl);
}
.text-3xl {
  font-size: var(--font-size-3xl);
}
.text-center {
  text-align: center;
}
.text-left,
.text-start {
  text-align: left;
}

.font-normal {
  font-weight: 400;
}
.font-medium {
  font-weight: 500;
}
.font-semibold {
  font-weight: 600;
}
.font-bold {
  font-weight: 700;
}
.font-extrabold {
  font-weight: 800;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
}

.input-sm {
  min-height: auto;
  height: 36px;
}
.textarea-sm {
  min-height: 60px;
}

.thin-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* === Keyframe Animations === */

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === Responsive === */

@media (max-width: 1024px) {
  #topbar {
    padding: 0 10px;
    gap: var(--space-3);
  }

  .topbar-center {
    display: none;
  }
  .topbar-left {
    gap: var(--space-3);
  }
  .topbar-right {
    gap: var(--space-2);
  }

  .btn-collab {
    padding: 0 var(--space-2);
  }

  .left-sidebar {
    order: 2;
    width: 100%;
  }
  .right-sidebar {
    order: 3;
    width: 100%;
    flex-direction: row;
  }

  .sidebar-tabs .btn-collapse {
    display: none;
  }
  .sidebar-tabs .nav-item.tab-inspector {
    border-radius: var(--radius-xl) 0 0 0;
  }
  .right-sidebar .sidebar-tabs {
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  }
  .right-sidebar .sidebar-content {
    border-radius: 0 var(--radius-xl) 0 0;
  }
  .right-sidebar .panel-header {
    border-radius: 0 var(--radius-xl) 0 0;
  }

  .main-layout {
    display: flex;
    flex-direction: column;
    overflow: visible;
    height: auto;
  }

  .editor-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: auto;
  }
}

@media (max-width: 768px) {
  html,
  body {
    overflow: auto;
  }

  .menu-trigger span,
  .btn-collab span,
  .vw-btn-icon span {
    display: none;
  }

  .menu-trigger {
    padding: 6px;
  }
  .menu-trigger .chev {
    display: none;
  }

  .menu-trigger i {
    font-size: var(--font-size-lg);
  }

  .sidebar {
    height: 60vh;
    min-height: 400px;
  }

  .sidebar-tabs .tabs-divider {
    display: none;
  }

  .ai-params-row {
    align-items: start;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }

  .ai-params-row .input-wrapper.flex-center {
    align-items: start;
  }

  .ai-params-row .checkbox-label {
    align-items: start;
    flex-direction: row;
  }

  .toast-container {
    inset: 0;
    left: 0;
    top: 0;
    max-width: 100%;
    padding: var(--space-2);
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .grid-3 {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}
