:root {
  color-scheme: dark;
  --ink: #f6f1e8;
  --muted: #b8c9c4;
  --subtle: #78918a;
  --panel: rgba(13, 26, 27, 0.74);
  --panel-strong: rgba(11, 18, 20, 0.9);
  --line: rgba(221, 204, 154, 0.18);
  --gold: #d7be73;
  --mint: #91d8c6;
  --coral: #e8a58d;
  --deep: #071112;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(145, 216, 198, 0.22), transparent 34%),
    radial-gradient(circle at 84% 10%, rgba(215, 190, 115, 0.2), transparent 30%),
    linear-gradient(135deg, #071112 0%, #0d2021 43%, #18231f 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: rgba(7, 17, 18, 0.62);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(215, 190, 115, 0.5);
  background: linear-gradient(135deg, rgba(215, 190, 115, 0.22), rgba(145, 216, 198, 0.12));
  color: var(--gold);
  font-size: 1.2rem;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--mint);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1;
}

.status-pill {
  min-width: 126px;
  padding: 10px 14px;
  border: 1px solid rgba(145, 216, 198, 0.25);
  color: var(--mint);
  background: rgba(145, 216, 198, 0.08);
  text-align: center;
  white-space: nowrap;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.tool-panel,
.preview-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(26px);
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drop-zone {
  min-height: 170px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 22px;
  border: 1px dashed rgba(215, 190, 115, 0.5);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--mint);
  background: rgba(145, 216, 198, 0.08);
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.drop-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(215, 190, 115, 0.45);
  color: var(--gold);
  font-size: 1.55rem;
}

.drop-zone small,
.muted-note,
#fileMeta {
  color: var(--muted);
  line-height: 1.45;
}

.control-group {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

.group-title {
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.confirm-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
  line-height: 1.45;
}

.confirm-line input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--mint);
}

.tool-button,
.primary-button,
.secondary-button {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 13px;
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    opacity 150ms ease;
}

.tool-button {
  justify-content: flex-start;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.045);
}

.tool-button.active,
.tool-button:hover {
  border-color: rgba(145, 216, 198, 0.38);
  background: rgba(145, 216, 198, 0.1);
}

.button-icon {
  width: 24px;
  color: var(--gold);
  text-align: center;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.range-label strong {
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--mint);
}

.action-row {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.primary-button {
  background: linear-gradient(135deg, #d7be73, #91d8c6);
  color: #081314;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid rgba(215, 190, 115, 0.35);
  background: rgba(215, 190, 115, 0.08);
  color: var(--gold);
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.preview-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.canvas-frame {
  position: relative;
  min-height: 520px;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%);
  background-color: rgba(3, 8, 9, 0.45);
  background-size: 28px 28px;
  background-position:
    0 0,
    0 14px,
    14px -14px,
    -14px 0;
}

#previewCanvas {
  max-width: 100%;
  max-height: calc(100vh - 190px);
  display: none;
  object-fit: contain;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  cursor: crosshair;
}

#sourceVideo {
  display: none;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.empty-state span {
  padding: 8px 13px;
  border: 1px solid rgba(215, 190, 115, 0.28);
  color: var(--gold);
  text-transform: uppercase;
  font-size: 0.78rem;
}

.empty-state strong {
  color: var(--ink);
  font-size: clamp(1.6rem, 4vw, 3.4rem);
  font-weight: 800;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.preview-footer > div:first-child {
  min-width: 0;
}

#fileName,
#fileMeta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-wrap {
  min-width: 220px;
  display: grid;
  gap: 8px;
  color: var(--mint);
  font-size: 0.86rem;
}

progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
}

progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.08);
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--gold), var(--mint));
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--gold), var(--mint));
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid rgba(215, 190, 115, 0.35);
  background: rgba(7, 17, 18, 0.92);
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100vw - 18px, 720px);
    margin: 9px auto;
  }

  .topbar,
  .workspace,
  .preview-footer {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .canvas-frame {
    min-height: 380px;
    padding: 12px;
  }

  #previewCanvas {
    max-height: 58vh;
  }

  .progress-wrap {
    min-width: 0;
  }
}
