/* ============================================================
   Media AI Box — Cinema Atelier 2026
   Cool arctic paper, deep teal signal, architectural type.
   ============================================================ */

:root {
  /* Atmosphere */
  --bg: #e4eaf1;
  --bg-2: #f3f6fa;
  --surface: #fbfcfe;
  --surface-2: #eef2f7;
  --surface-hover: #e6ecf3;
  --surface-pressed: #dce4ee;
  --overlay: rgba(243, 246, 250, 0.78);
  --nav-bg: #f3f6fa;

  /* Border / divider */
  --border: rgba(14, 28, 48, 0.1);
  --border-strong: rgba(14, 28, 48, 0.18);
  --divider: rgba(14, 28, 48, 0.08);

  /* Text — deep ink */
  --text: #0a1628;
  --text-2: #2a3a4d;
  --text-3: #5a6b7d;
  --text-muted: #7a8b9c;
  --text-on-accent: #ffffff;

  /* Accent — deep teal signal */
  --accent: #0a6b76;
  --accent-hover: #085a63;
  --accent-pressed: #064a52;
  --accent-bright: #12a3b0;
  --accent-soft: rgba(10, 107, 118, 0.1);
  --accent-soft-2: rgba(10, 107, 118, 0.18);
  --ember: #e86d2f;
  --ember-soft: rgba(232, 109, 47, 0.12);

  /* Semantic */
  --green: #1f9d63;
  --orange: #e86d2f;
  --red: #d64545;
  --purple: #6b5b95;
  --indigo: #3d5a80;
  --pink: #c45c7a;
  --teal: #12a3b0;

  /* Shadows — cool depth */
  --shadow-xs: 0 1px 2px rgba(14, 28, 48, 0.05);
  --shadow-sm:
    0 2px 10px rgba(14, 28, 48, 0.06), 0 1px 2px rgba(14, 28, 48, 0.04);
  --shadow-md:
    0 10px 28px rgba(14, 28, 48, 0.08), 0 2px 6px rgba(14, 28, 48, 0.04);
  --shadow-lg:
    0 28px 56px -14px rgba(14, 28, 48, 0.16), 0 6px 12px rgba(14, 28, 48, 0.05);
  --shadow-focus: 0 0 0 4px rgba(10, 107, 118, 0.2);

  /* Radius — architectural */
  --r-xs: 5px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 26px;
  --r-pill: 999px;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 28px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  /* Layout */
  --nav-w: 248px;
  --topbar-h: 56px;

  /* Type */
  --font-ui: "Outfit", "Rubik", system-ui, sans-serif;
  --font-display: "Outfit", "Rubik", system-ui, sans-serif;

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  /* Atmosphere */
  --bg: #0c121d;
  --bg-2: #111a27;
  --surface: #172130;
  --surface-2: #121b28;
  --surface-hover: #202c3d;
  --surface-pressed: #293749;
  --overlay: rgba(12, 18, 29, 0.82);
  --nav-bg: #0f1723;

  /* Border / divider */
  --border: rgba(223, 235, 247, 0.1);
  --border-strong: rgba(223, 235, 247, 0.2);
  --divider: rgba(223, 235, 247, 0.08);

  /* Text */
  --text: #edf4fa;
  --text-2: #c9d5e2;
  --text-3: #94a6b9;
  --text-muted: #718397;
  --text-on-accent: #ffffff;

  /* Accent */
  --accent: #20a7b2;
  --accent-hover: #2dbac5;
  --accent-pressed: #168d97;
  --accent-bright: #42c5cf;
  --accent-soft: rgba(32, 167, 178, 0.14);
  --accent-soft-2: rgba(32, 167, 178, 0.24);
  --ember: #f1854d;
  --ember-soft: rgba(241, 133, 77, 0.15);

  /* Semantic colors keep enough contrast on the dark surfaces. */
  --green: #45c98a;
  --orange: #f2925f;
  --red: #f06d72;
  --purple: #a998d4;
  --indigo: #7898c4;
  --pink: #df83a0;
  --teal: #42c5cf;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 28px 60px -12px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 0 4px rgba(32, 167, 178, 0.25);

  color-scheme: dark;
}

/* ===== Reset / Base ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  letter-spacing: -0.015em;
}

button,
input,
textarea,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(14, 28, 48, 0.16);
  border-radius: 12px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(14, 28, 48, 0.28);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(223, 235, 247, 0.18);
  border-color: var(--bg);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(223, 235, 247, 0.3);
}

::selection {
  background: var(--accent-soft-2);
  color: var(--text);
}

/* ===== Locale direction ===== */
html[dir="ltr"] body,
html[dir="ltr"] input,
html[dir="ltr"] textarea,
html[dir="ltr"] select {
  direction: ltr;
}

html[dir="ltr"] [data-icon="back"] svg,
html[dir="ltr"] [data-icon="chevron-right"].directional-icon svg {
  transform: rotate(180deg);
}

/* A few feature panels predate logical CSS properties and explicitly pin
   themselves to RTL.  The higher-specificity locale rule lets the same panels
   follow the English document direction while Hebrew-content fields can still
   opt into RTL with their own dir/is-he marker. */
html[dir="ltr"] :is(
    .add-local-modal,
    .audio-chooser-track,
    .auto-soundtrack-modal,
    .vfx-studio--inline,
    .clip-audio-editor,
    .overlay-modal,
    .logo-modal,
    .render-progress,
    .template-studio,
    .transition-grid,
    .export-modal,
    .export-fn-row,
    .vfx-modal,
    .slip-modal,
    .sub-modal,
    .enh-modal,
    .pwa-install-banner
  ) {
  direction: ltr;
  text-align: left;
}

html[dir="ltr"] :is(
    .generate-btn-with-price .video-generate-btn,
    .ws-action-dock .generate-btn-with-price .ws-run-btn,
    .ws-action-body > .generate-btn-with-price .ws-run-btn,
    .ws-wan-panel > .generate-btn-with-price .ws-run-btn,
    .ws-lipsync-footer .generate-btn-with-price .ws-run-btn,
    .ws-restyle-footer .generate-btn-with-price .ws-run-btn
  ) {
  direction: ltr;
}

/* Fixed-color brand and authentication artwork must remain legible on the
   darker shell; their teal-to-ember AI accent is intentionally unchanged. */
[data-theme="dark"] :is(.brand-mark-svg, .login-mark-svg) > g[stroke] {
  stroke: var(--text);
}

[data-theme="dark"] :is(.splash-base, .login-base) {
  stroke: var(--text);
}

[data-theme="dark"] :is(.splash-track, .login-track) {
  stroke: rgba(237, 244, 250, 0.12);
}

[data-theme="dark"] .ystudia-logo,
[data-theme="dark"] .login-ystudia {
  filter: brightness(0) invert(1);
  opacity: 0.78;
}

/* ===== App Shell ===== */
#app-shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  height: 100vh;
  width: 100vw;
  background: var(--bg);
}

/* ===== Side Nav ===== */
.side-nav {
  background: var(--nav-bg);
  border-inline-start: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  padding: var(--s-3);
  position: relative;
  z-index: 10;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-2) var(--s-5);
}

.brand-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-logo svg,
.brand-mark-svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
}

/* + new project button */
.sidebar-new-btn {
  margin-bottom: var(--s-4);
  font-size: 13px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 var(--s-2);
  margin-bottom: var(--s-2);
}

.sidebar-projects {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -2px;
  padding: 0 2px var(--s-3);
}

.sidebar-project {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-2);
  font-size: 13px;
}

.sidebar-project:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-project.active {
  background: rgb(0 0 0 / 12%);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.sidebar-project-thumb {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--surface-pressed);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-project-thumb.media-thumb--video .media-thumb-video-el,
.sidebar-project-thumb .media-thumb-img-el {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.sidebar-project-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-empty {
  padding: var(--s-3) var(--s-2);
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Nav-item used in footer (settings) */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.nav-icon {
  font-size: 14px;
  width: 16px;
  display: flex;
  justify-content: center;
  color: var(--text-3);
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-status-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 6px;
  row-gap: 2px;
  padding: 10px 12px 8px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-3);
}

.nav-footer .nav-item-lg {
  border-top: 1px solid var(--divider);
}

.sidebar-status-meta .status-bit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  justify-content: flex-start;
}

.status-bit-sep {
  color: var(--text-3);
  opacity: 0.3;
  user-select: none;
  font-size: 10px;
}

.sidebar-status-meta .status-dot {
  width: 5px;
  height: 5px;
}

.nav-item-lg {
  padding: 10px 12px;
  font-size: 14px;
  position: relative;
}

.nav-item-lg .nav-icon {
  font-size: 16px;
  width: 18px;
}

/* Small AI status dot inside settings nav item */
.api-status-dot {
  margin-inline-start: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
  position: relative;
}

.api-status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.15);
}

.api-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  /* background: var(--surface); */
  /* border-radius: var(--r-sm); */
  font-size: 12px;
  color: var(--text-3);
  /* box-shadow: var(--shadow-xs); */
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
}

.api-status.connected .status-dot {
  background: var(--green);
}

.api-status.connected {
  color: var(--text-2);
}

/* ===== Main Area ===== */
.main-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: transparent;
}

.mobile-toggle {
  display: none;
  position: absolute;
  top: var(--s-3);
  inset-inline-end: var(--s-3);
  z-index: 5;
}

@media (max-width: 960px) {
  .mobile-toggle {
    display: flex;
  }
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 16px;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.mobile-only {
  display: none;
}

/* ===== Content Area ===== */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-8) var(--s-10);
  position: relative;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px var(--s-4);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: all 0.15s var(--ease-out);
  border: 1px solid transparent;
  white-space: nowrap;
  position: relative;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-pressed);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-text {
  background: transparent;
  color: var(--accent);
  padding: 4px 8px;
}

.btn-text:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 0;
  line-height: 1.4;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0;
  width: 32px;
  height: 32px;
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
}

/* ===== Loading Spinner ===== */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-secondary .spinner,
.btn-ghost .spinner {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: var(--text);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.32);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* Above mobile popover/sheets (1000) and project menus; below .cselect-menu (9999). */
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  animation: fadeIn 0.2s var(--ease-out);
}

.modal-backdrop[hidden] {
  display: none;
}

/* Confirm sits above any open parent modal so Cancel doesn't wipe it. */
.confirm-backdrop {
  z-index: 1200;
  background: rgba(10, 22, 40, 0.45);
}

/* openStackedModal: the same modal markup opened over an open parent modal
   (a picker's "view large"). Below the crop dialog (1300). */
.modal-backdrop--stacked {
  z-index: 1250;
}

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: var(--s-7);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s var(--ease-out);
}

.modal.modal-lg {
  max-width: 1080px;
}

.modal.modal-lg:has(.lightbox) {
  /* Hug the media: don't stretch to a fixed large width with empty margins. */
  width: fit-content;
  max-width: min(960px, calc(100vw - 32px));
  padding: var(--s-4);
  overflow: hidden;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ===== SF-style SVG icon base ===== */
.ui-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.125em;
  line-height: 1;
}
.ui-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Toast icon */
.toast-icon {
  flex-shrink: 0;
  font-size: 15px;
}
.toast-success .toast-icon {
  color: var(--green, #1f9d63);
}
.toast-error .toast-icon {
  color: var(--red, #d64545);
}
.toast-warning .toast-icon {
  color: var(--ember, #e86d2f);
}
.toast-info .toast-icon {
  color: var(--accent, #0a6b76);
}
.toast-loading .toast-icon {
  color: var(--accent, #0a6b76);
}
/* Spinner animation for loading icon handled inline via animateTransform SVG element */

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 15px;
  transition: all 0.15s;
  background: var(--surface-2);
}

.modal-close:hover {
  background: var(--surface-pressed);
  color: var(--text);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.confirm-dialog-field {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.modal-footer {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--divider);
}

.modal-footer-extra-actions {
  display: contents;
}

.modal-footer:has(.modal-footer-extra-actions) {
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
}

.modal-footer:has(.modal-footer-extra-actions) > .btn,
.modal-footer-extra-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
  padding-inline: 10px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  inset-inline-end: 24px;
  /* Above modal (1100) / confirm (1200) so errors like fal balance show
     while logo / overlay pickers are open. Below login (10000). */
  z-index: 1300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  transform: translate(var(--toast-drag-x, 0px), var(--toast-drag-y, 0px));
  will-change: transform;
}

.toast-container.is-dragging {
  transition: none;
  cursor: grabbing;
  user-select: none;
}

.toast-container .toast {
  cursor: grab;
  /* The chip owns the gesture: without this a touch-drag turns into a page
     pan and the browser cancels our pointer stream. Not set on the render
     progress card - its error state has scrollable text, and touch-action
     cannot be re-enabled on a descendant. */
  touch-action: none;
}

.toast-container .render-progress {
  cursor: grab;
}

.toast-container .toast.toast-clickable {
  cursor: pointer;
}

.toast-container.is-dragging .toast,
.toast-container.is-dragging .toast.toast-clickable {
  cursor: grabbing;
}

/* Older chips folded into the overflow tray while many jobs run. */
.toast.toast-stacked-hidden {
  display: none !important;
}

.toast.toast-overflow {
  cursor: pointer;
  justify-content: center;
  min-width: 200px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent, #0a6b76));
  border: 1px solid color-mix(in srgb, var(--accent, #0a6b76) 28%, transparent);
}

.toast.toast-overflow:hover {
  filter: brightness(1.03);
}

.toast {
  background: var(--surface);
  border-radius: var(--r-md, 12px);
  padding: 10px 12px 10px 14px;
  min-width: 260px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui, inherit);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--_toast-color, var(--border));
  animation: toastIn 0.28s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  pointer-events: auto;
}

.toast-success {
  --_toast-color: color-mix(in srgb, var(--green, #1f9d63) 35%, transparent);
  background: color-mix(in srgb, var(--surface) 94%, var(--green, #1f9d63));
}
.toast-error {
  --_toast-color: color-mix(in srgb, var(--red, #d64545) 35%, transparent);
  background: color-mix(in srgb, var(--surface) 94%, var(--red, #d64545));
}
.toast-warning {
  --_toast-color: color-mix(in srgb, var(--ember, #e86d2f) 35%, transparent);
  background: color-mix(in srgb, var(--surface) 94%, var(--ember, #e86d2f));
}
.toast-info {
  --_toast-color: color-mix(in srgb, var(--accent, #0a6b76) 32%, transparent);
  background: color-mix(in srgb, var(--surface) 94%, var(--accent, #0a6b76));
}
.toast-loading {
  --_toast-color: color-mix(in srgb, var(--accent, #0a6b76) 32%, transparent);
  background: color-mix(in srgb, var(--surface) 94%, var(--accent, #0a6b76));
}

/* Colored dot indicator */
.toast-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}
.toast-success .toast-dot {
  background: var(--green, #1f9d63);
}
.toast-error .toast-dot {
  background: var(--red, #d64545);
}
.toast-warning .toast-dot {
  background: var(--ember, #e86d2f);
}
.toast-info .toast-dot {
  background: var(--accent, #0a6b76);
}
.toast-loading .toast-dot {
  background: transparent;
}

/* Spinning ring for loading toasts */
.toast-dot-spin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--accent, #0a6b76) 22%, transparent);
  border-top-color: var(--accent, #0a6b76);
  animation: toastDotSpin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes toastDotSpin {
  to {
    transform: rotate(360deg);
  }
}

.toast-text {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.4;
}

/* Two-line toast: title + dim model/context detail line (which model, shot…) */
.toast-textblock {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toast-textblock .toast-text,
.toast-textblock .toast-ai-text {
  flex: none;
}
.toast-detail {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted, var(--text-3));
  opacity: 0.78;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-detail[hidden] {
  display: none;
}

.toast-close {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  font-size: 11px;
  transition: color 0.15s;
  margin-inline-start: 2px;
}
.toast-close:hover {
  color: var(--text);
}

.toast-action {
  flex-shrink: 0;
}

/* Stop button on an in-progress AI/loading toast: more visible than the passive
   close X, with a red "stop" hover to read as "cancel this job". */
.toast-cancel {
  color: var(--text-2);
  opacity: 0.85;
}
.toast-cancel:hover {
  color: #fff;
  background: var(--danger, #e5484d);
  opacity: 1;
}

/* Clickable toasts - return to the editing / creation context */
.toast.toast-clickable {
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.toast.toast-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.toast.toast-clickable:active {
  transform: translateY(0);
}

.toast.toast-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message replacing message inside the single shared toast slot. */
@keyframes toastSwap {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* "Return to what was created": when a toast is clicked, flash-highlight the
   target element (shot card / video version / created clip) it points to. */
@keyframes revealFlash {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #0a6b76) 0%, transparent);
    outline-color: color-mix(in srgb, var(--accent, #0a6b76) 0%, transparent);
  }
  18% {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #0a6b76) 40%, transparent);
    outline-color: color-mix(in srgb, var(--accent, #0a6b76) 85%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #0a6b76) 0%, transparent);
    outline-color: color-mix(in srgb, var(--accent, #0a6b76) 0%, transparent);
  }
}
.reveal-flash {
  animation: revealFlash 1.3s ease-out 2;
  outline: 1px solid transparent;
  outline-offset: 1px;
  border-radius: var(--r-sm, 10px);
  position: relative;
  z-index: 2;
}
@media (prefers-reduced-motion: reduce) {
  .reveal-flash {
    animation: none;
    outline-color: color-mix(in srgb, var(--accent, #0a6b76) 85%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #0a6b76) 35%, transparent);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  :root {
    --nav-w: 0px;
  }

  .side-nav {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    transform: translateX(100%);
    transition: transform 0.18s var(--ease-out);
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }

  .side-nav.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: flex;
  }

  .search-box {
    display: none;
  }

  .content-area {
    padding: var(--s-5);
  }
}

/* ===== Login Screen ===== */
.login-screen[hidden] {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  padding-bottom: max(var(--s-6), env(safe-area-inset-bottom, 0px));
}

.login-screen.is-leaving {
  animation: loginScreenOut 0.45s var(--ease-out) forwards;
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 36px 28px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-md);
  animation: loginCardIn 0.45s var(--ease-out) both;
}

.login-card.is-shake {
  animation: loginShake 0.45s var(--ease-out);
}

.login-card.is-success .login-form,
.login-card.is-success .login-heading,
.login-card.is-success .login-mark {
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
  pointer-events: none;
}

.login-mark {
  width: 96px;
  height: 96px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-mark-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.login-track {
  fill: none;
  stroke: rgba(10, 22, 40, 0.1);
  stroke-width: 40;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-base {
  fill: none;
  stroke: #0a1628;
  stroke-width: 40;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-sweep {
  fill: none;
  stroke: url(#loginSweepGrad);
  stroke-width: 40;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 0.2 0.8;
  stroke-dashoffset: 0;
  opacity: 1;
  filter: url(#loginSweepGlow);
  animation: loginMarkSweep 2.4s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.login-sweep-fold {
  animation-delay: -0.8s;
}

.login-sweep-spine {
  animation-delay: -1.6s;
  stroke-dasharray: 0.28 0.72;
}

.login-mark.is-animating .login-sweep {
  animation-duration: 1.6s;
}

.login-mark.is-animating .login-ai {
  animation: loginAiPulse 1.6s ease-in-out infinite;
}

.login-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  text-align: center;
}

.login-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.login-hint {
  font-size: 14px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.5;
  margin: 0;
  /* max-width: 28ch; */
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.login-field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-3);
  padding-inline-start: 2px;
}

.login-input {
  text-align: center;
  font-size: 16px;
  letter-spacing: 0.18em;
  height: 48px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid transparent;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.login-input:focus {
  background: #fff;
  border-color: rgba(10, 107, 118, 0.4);
  box-shadow: 0 0 0 4px rgba(10, 107, 118, 0.14);
  outline: none;
}

.login-input.is-invalid {
  border-color: rgba(255, 59, 48, 0.45);
  box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.1);
}

.login-submit {
  height: 48px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    opacity 0.2s ease;
}

.login-submit:not(:disabled):active {
  transform: scale(0.98);
}

.login-submit.is-busy {
  opacity: 1 !important;
  pointer-events: none;
  cursor: wait;
}

.login-error {
  font-size: 13px;
  font-weight: 500;
  color: #ff3b30;
  text-align: center;
  margin: 0;
  line-height: 1.45;
  min-height: 0;
}

.login-error.is-warn {
  color: #c47d00;
}

.login-success {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  animation: loginSuccessIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-success[hidden] {
  display: none;
}

.login-success-check {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(52, 199, 89, 0.12);
  color: #34c759;
  display: grid;
  place-items: center;
  position: relative;
}

.login-success-check::before {
  content: "";
  width: 14px;
  height: 24px;
  border-right: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: rotate(45deg) translate(-1px, -2px);
  animation: loginCheckDraw 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.login-success-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-credit {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  animation: loginCardIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

.login-by {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: #aeaeb2;
  line-height: 1;
}

.login-ystudia {
  height: 18px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  display: block;
  opacity: 0.88;
}

@keyframes loginMarkSweep {
  to {
    stroke-dashoffset: -1;
  }
}

@keyframes loginAiPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.82;
  }
}

@keyframes loginCardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes loginScreenOut {
  to {
    opacity: 0;
  }
}

@keyframes loginShake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@keyframes loginSuccessIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes loginCheckDraw {
  from {
    opacity: 0;
    transform: rotate(45deg) translate(-1px, -2px) scale(0.6);
  }
  to {
    opacity: 1;
    transform: rotate(45deg) translate(-1px, -2px) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-card,
  .login-credit,
  .login-screen.is-leaving,
  .login-card.is-shake,
  .login-success,
  .login-success-check::before,
  .login-sweep,
  .login-mark.is-animating .login-ai {
    animation: none !important;
  }
  .login-sweep {
    opacity: 1;
    stroke-dasharray: 0.35 0.65;
    stroke-dashoffset: -0.15;
  }
}
