:root {
  color-scheme: dark;
  --bg: #020202;
  --panel: rgba(14, 14, 16, .78);
  --border: rgba(255, 255, 255, .075);
  --text: #fff;
  --muted: #6f6f79;
  --radius-lg: 16px;
  --radius-md: 12px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% -10%, rgba(50, 50, 62, .08), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.top-nav {
  position: relative;
  z-index: 20;
  min-height: 76px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(2, 2, 2, .86);
  backdrop-filter: blur(18px);
}

.back-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #777781;
  font-size: .87rem;
  font-weight: 620;
  transition: color .25s ease;
}
.back-link:hover { color: #fff; }
.back-link svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .3s var(--ease); }
.back-link:hover svg { transform: translateX(-4px); }

.nexus-logo { grid-column: 2; justify-self: center; display: block; line-height: 0; }
.nexus-logo img { display: block; width: clamp(150px, 18vw, 225px); height: auto; }

.discord-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  overflow: hidden;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 8px;
  background: linear-gradient(135deg, #5865f2, #404eed);
  box-shadow: 0 4px 14px rgba(88, 101, 242, .28);
  color: #fff;
  font-size: .8rem;
  font-weight: 680;
  transition: transform .3s var(--ease), box-shadow .3s ease, background .3s ease;
}
.discord-btn::before { content: ""; position: absolute; inset: 0; transform: translateX(-110%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent); transition: transform .5s ease; }
.discord-btn:hover { transform: translateY(-2px); background: linear-gradient(135deg, #6571f3, #4752c4); box-shadow: 0 7px 20px rgba(88, 101, 242, .42); }
.discord-btn:hover::before { transform: translateX(110%); }
.discord-btn svg { width: 19px; height: 19px; fill: currentColor; }
.desktop-discord { grid-column: 3; justify-self: end; }

.menu-toggle, .menu-scrim, .mobile-menu { display: none; }

.dashboard {
  width: min(100% - 48px, 1600px);
  margin: 0 auto;
  padding: 24px 0 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.main-split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; min-height: 620px; }
.workspace, .sidebar, .history-strip {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025), 0 22px 70px rgba(0,0,0,.34);
}

.workspace { position: relative; min-width: 0; min-height: 620px; overflow: hidden; border-radius: var(--radius-lg); }
.action-center {
  position: absolute;
  z-index: 3;
  top: 50%; left: 50%;
  width: min(100%, 700px);
  padding: 0 32px;
  transform: translate(-50%, -50%);
  transition: top .65s var(--ease), transform .65s var(--ease), width .65s var(--ease);
}
.workspace.has-media .action-center { top: 28px; width: 100%; transform: translate(-50%, 0); }

.tool-title { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 22px; font-size: clamp(1.65rem, 2.4vw, 2.35rem); letter-spacing: -.045em; }
.tool-title img { width: 48px; height: 48px; border-radius: 11px; object-fit: contain; }

.input-group { display: flex; gap: 8px; padding: 8px; border: 1px solid rgba(255,255,255,.11); border-radius: var(--radius-md); background: #000; box-shadow: 0 16px 32px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05); transition: border-color .3s ease; }
.input-group:focus-within { border-color: rgba(255,255,255,.27); }
.input-group input { min-width: 0; flex: 1; padding: 12px 14px; border: 0; outline: 0; background: transparent; color: #fff; font-size: .98rem; }
.input-group input::placeholder { color: #55555e; }
.input-group button { flex: 0 0 auto; min-width: 116px; padding: 0 22px; border: 0; border-radius: 8px; background: #fff; color: #050505; font-size: .87rem; font-weight: 760; cursor: pointer; transition: transform .2s ease, opacity .2s ease; }
.input-group button:hover { opacity: .88; }
.input-group button:active { transform: scale(.97); }

.usage-note { max-width: 620px; margin: 12px auto 0; color: #5f5f68; font-size: .7rem; line-height: 1.5; text-align: center; }
.status-line { min-height: 20px; margin-top: 10px; color: var(--muted); font-size: .81rem; font-weight: 520; text-align: center; }
.status-line.loading { color: #a8a8b2; }
.status-line.success { color: #73e9ad; }
.status-line.error { color: #ff7f89; }

.preview-stage { position: absolute; inset: 245px 32px 32px; opacity: 0; visibility: hidden; transform: translateY(22px) scale(.99); transition: opacity .55s var(--ease), transform .7s var(--ease), visibility .55s; }
.workspace.has-media .preview-stage { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.video-frame { position: relative; width: 100%; height: 100%; min-height: 320px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: #000; }
.video-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.05); transition: opacity .65s ease, transform 1s var(--ease); }
.workspace.has-media .video-frame img.loaded { opacity: .8; transform: scale(1); }
.frame-overlay { position: absolute; z-index: 1; inset: auto 0 0; padding: 70px 30px 27px; background: linear-gradient(0deg, rgba(0,0,0,.96), rgba(0,0,0,.36) 66%, transparent); }
.frame-overlay h2 { margin: 0 0 8px; font-size: clamp(1.2rem, 2vw, 1.55rem); letter-spacing: -.025em; }
.media-meta { display: flex; align-items: center; gap: 9px; color: #9696a0; font-size: .84rem; }

.sidebar { min-width: 0; overflow: hidden; border-radius: var(--radius-lg); display: flex; flex-direction: column; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,.18); }
.sidebar-header h2, .history-header h2 { margin: 0; font-size: .94rem; font-weight: 660; letter-spacing: .01em; }
.sidebar-header span { color: var(--muted); font-size: .73rem; }
.sidebar-content { min-height: 0; flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
.empty-sidebar { margin: auto; padding: 40px 16px; color: var(--muted); font-size: .82rem; text-align: center; }

.quality-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(0,0,0,.38); transition: border-color .2s ease, background .2s ease; }
.quality-row:hover { border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.025); }
.quality-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.quality-name { color: #f5f5f7; font-size: .91rem; font-weight: 670; }
.quality-meta { color: #74747e; font-size: .75rem; line-height: 1.4; }
.quality-download { flex: 0 0 auto; padding: 8px 13px; border: 0; border-radius: 8px; background: #fff; color: #050505; font-size: .75rem; font-weight: 760; cursor: pointer; transition: transform .2s ease, opacity .2s ease; }
.quality-download:hover { opacity: .86; }
.quality-download:active { transform: scale(.96); }
.quality-download:disabled { opacity: .48; cursor: wait; }

.progress-card { display: none; margin: 0 15px 15px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(0,0,0,.36); }
.progress-card.visible { display: block; }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; color: #aaaab3; font-size: .72rem; }
.progress-track { height: 4px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.08); }
.progress-track div { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#5865f2,#a855f7); transition: width .25s ease; }
.download-more { display: none; width: 100%; padding: 11px 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; background: #fff; color: #050505; font-size: .82rem; font-weight: 760; cursor: pointer; transition: transform .2s ease, opacity .2s ease; }
.download-more:hover { opacity: .88; }
.download-more:active { transform: scale(.98); }
.progress-card.complete .progress-copy, .progress-card.complete .progress-track { display: none; }
.progress-card.complete .download-more { display: block; }

.history-strip { min-height: 270px; overflow: hidden; border-radius: var(--radius-lg); display: flex; flex-direction: column; }
.history-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 22px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,.18); }
.history-header button { padding: 5px 0; border: 0; background: transparent; color: var(--muted); font-size: .76rem; cursor: pointer; }
.history-header button:hover { color: #fff; }
.history-feed { min-height: 0; flex: 1; padding: 14px 18px; display: grid; align-content: start; gap: 8px; }
.history-card { width: 100%; min-width: 0; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 11px 14px; border: 1px solid rgba(255,255,255,.065); border-radius: var(--radius-md); background: rgba(0,0,0,.32); transition: transform .25s var(--ease), border-color .2s ease, background .2s ease; }
.history-card:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.13); background: rgba(255,255,255,.025); }
.history-service-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.075); border-radius: 10px; background: #08080a; }
.history-service-icon img { width: 24px; height: 24px; object-fit: contain; }
.history-main { min-width: 0; }
.history-card h3 { overflow: hidden; margin: 0 0 5px; font-size: .84rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { display: flex; align-items: center; gap: 7px; overflow: hidden; color: #74747e; font-size: .68rem; white-space: nowrap; }
.history-meta span { overflow: hidden; text-overflow: ellipsis; }
.history-meta time { flex: 0 0 auto; color: #5d5d66; }
.history-side { min-width: 98px; display: grid; justify-items: end; gap: 6px; text-align: right; }
.history-quality { color: #b8b8c0; font-size: .7rem; font-weight: 680; }
.history-badge { flex: 0 0 auto; padding: 4px 7px; border: 1px solid rgba(255,255,255,.06); border-radius: 5px; background: rgba(255,255,255,.045); color: #d0d0d5; font-size: .6rem; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.empty-history { width: 100%; padding: 50px 20px; color: var(--muted); font-size: .82rem; text-align: center; }
.history-pagination { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 54px; padding: 8px 18px 13px; border-top: 1px solid rgba(255,255,255,.055); }
.history-pagination:empty { display: none; }
.history-pagination button { min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid rgba(255,255,255,.075); border-radius: 8px; background: rgba(255,255,255,.025); color: #777781; font-size: .7rem; font-weight: 700; cursor: pointer; transition: border-color .2s ease, background .2s ease, color .2s ease, transform .2s ease; }
.history-pagination button:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(255,255,255,.16); color: #fff; }
.history-pagination button.active { border-color: rgba(255,255,255,.22); background: #f1f1f3; color: #08080a; }
.history-pagination button:disabled { opacity: .3; cursor: not-allowed; }
.history-pagination .page-arrow { min-width: 70px; }

.site-footer { display: flex; align-items: center; justify-content: center; gap: 20px; padding: 6px 0 24px; color: #54545d; font-size: .67rem; letter-spacing: .12em; text-transform: uppercase; }
.site-footer nav { display: flex; gap: 18px; }
.site-footer a { color: #707079; transition: color .2s ease; }
.site-footer a:hover { color: #fff; }

.toast-stack { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 9px; }
.toast { max-width: min(360px, calc(100vw - 32px)); padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #111114; color: #dddde2; box-shadow: 0 14px 38px rgba(0,0,0,.5); font-size: .8rem; animation: toast-in .3s var(--ease); }
.toast.error { border-color: rgba(255,100,110,.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1024px) {
  .main-split { grid-template-columns: 1fr; }
  .workspace { min-height: 620px; }
  .sidebar { min-height: 300px; }
}

@media (max-width: 700px) {
  body.mobile-menu-open { overflow: hidden; }
  .top-nav { min-height: 66px; grid-template-columns: 44px 1fr 44px; padding: 11px 14px; }
  .back-link span, .desktop-discord { display: none; }
  .back-link { width: 42px; height: 42px; justify-content: center; border: 1px solid var(--border); border-radius: 10px; }
  .nexus-logo { grid-column: 2; }
  .nexus-logo img { width: 145px; }
  .menu-toggle { position: relative; z-index: 130; grid-column: 3; justify-self: end; width: 42px; height: 42px; display: grid; place-content: center; gap: 4px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.025); cursor: pointer; transition: border-color .25s ease, background .25s ease, transform .3s var(--ease); }
  .menu-toggle:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.06); }
  .menu-toggle[aria-expanded="true"] { border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.08); }
  .menu-toggle span { width: 18px; height: 2px; border-radius: 2px; background: #ddd; transition: transform .3s var(--ease), opacity .2s ease; }
  .menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  .menu-scrim {
    position: fixed;
    z-index: 110;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    padding: 0;
    border: 0;
    background: rgba(0,0,0,.62);
    opacity: 0;
    visibility: hidden;
    cursor: default;
    backdrop-filter: blur(0);
    transition: opacity .35s ease, visibility .35s, backdrop-filter .45s ease;
  }
  .menu-scrim.open { opacity: 1; visibility: visible; backdrop-filter: blur(5px); }

  .mobile-menu {
    position: fixed;
    z-index: 120;
    top: 0;
    right: 0;
    width: min(88vw, 370px);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 92px 18px max(24px, env(safe-area-inset-bottom));
    overflow-y: auto;
    border-left: 1px solid rgba(255,255,255,.09);
    background:
      radial-gradient(circle at 85% 2%, rgba(88,101,242,.16), transparent 18rem),
      linear-gradient(165deg, #111116 0%, #09090c 52%, #050506 100%);
    box-shadow: -28px 0 70px rgba(0,0,0,.58);
    opacity: 0;
    visibility: hidden;
    transform: translateX(104%);
    transition: transform .5s var(--ease), opacity .3s ease, visibility .5s;
  }
  .mobile-menu.open { opacity: 1; visibility: visible; transform: translateX(0); }
  .mobile-menu-head { padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.075); }
  .mobile-menu-kicker { display: block; margin-bottom: 8px; color: #777782; font-size: .64rem; font-weight: 780; letter-spacing: .2em; text-transform: uppercase; }
  .mobile-menu-head > strong { display: block; font-size: 1.65rem; letter-spacing: -.045em; }
  .mobile-menu-head p { max-width: 250px; margin: 8px 0 0; color: #777782; font-size: .78rem; line-height: 1.55; }
  .mobile-menu-links { display: grid; gap: 8px; margin-top: 20px; }
  .mobile-menu-links a { position: relative; display: flex; align-items: center; min-height: 72px; padding: 14px 42px 14px 15px; overflow: hidden; border: 1px solid rgba(255,255,255,.075); border-radius: 13px; background: rgba(255,255,255,.025); transition: transform .3s var(--ease), border-color .25s ease, background .25s ease; }
  .mobile-menu-links a::after { content: "\2192"; position: absolute; right: 16px; color: #656571; font-size: 1rem; transition: color .25s ease, transform .3s var(--ease); }
  .mobile-menu-links a:hover { transform: translateX(-3px); border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.055); }
  .mobile-menu-links a:hover::after { color: #fff; transform: translateX(3px); }
  .mobile-menu-links strong, .mobile-menu-links small { display: block; }
  .mobile-menu-links strong { color: #f2f2f5; font-size: .88rem; font-weight: 690; }
  .mobile-menu-links small { margin-top: 5px; color: #6f6f79; font-size: .68rem; }
  .mobile-menu .mobile-discord { width: 100%; min-height: 48px; margin-top: auto; padding: 13px 16px; border-radius: 11px; }
  .mobile-menu-foot { padding: 15px 4px 0; color: #4f4f58; font-size: .62rem; letter-spacing: .04em; text-align: center; }

  .dashboard { width: min(100% - 20px, 1600px); padding-top: 14px; gap: 14px; }
  .main-split { gap: 14px; }
  .workspace { min-height: 0; overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .action-center { position: relative; top: auto; left: auto; width: 100%; padding: 18px 0 8px; transform: none; transition: none; }
  .workspace.has-media .action-center { top: auto; width: 100%; transform: none; }
  .tool-title { gap: 10px; margin-bottom: 15px; font-size: 1.48rem; }
  .tool-title img { width: 38px; height: 38px; border-radius: 9px; }
  .input-group { gap: 5px; padding: 5px; border-radius: 11px; box-shadow: 0 10px 26px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.04); }
  .input-group input { width: 100%; padding: 11px 9px; font-size: .82rem; }
  .input-group button { min-width: 94px; min-height: 40px; padding: 0 14px; }
  .usage-note { font-size: .65rem; }
  .preview-stage { position: relative; inset: auto; height: 0; min-height: 0; margin: 0; overflow: hidden; transform: translateY(16px); transition: height .65s var(--ease), margin .65s var(--ease), opacity .45s ease, transform .65s var(--ease), visibility .45s; }
  .workspace.has-media .preview-stage { height: 340px; margin-top: 18px; transform: translateY(0); }
  .video-frame { min-height: 0; }
  .frame-overlay { padding: 60px 18px 18px; }
  .sidebar, .history-strip { border-radius: 14px; }
  .history-strip { min-height: 0; }
  .history-header { padding: 14px 15px; }
  .history-feed { padding: 10px; gap: 7px; }
  .history-card { grid-template-columns: 38px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .history-service-icon { width: 38px; height: 38px; border-radius: 9px; }
  .history-service-icon img { width: 21px; height: 21px; }
  .history-side { grid-column: 2; min-width: 0; display: flex; align-items: center; justify-content: flex-start; gap: 8px; text-align: left; }
  .history-pagination { padding: 8px 10px 12px; }
  .history-pagination .page-arrow { min-width: 62px; }
  .site-footer { flex-direction: column; gap: 11px; padding: 12px 0 26px; }
  .site-footer nav { gap: 22px; }
  .site-footer > span { color: #44444d; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
