:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --subtle: #9ca3af;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-2: #3b82f6;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.07);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  background: transparent;
  justify-self: start;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.26);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: none;
}

.brand-copy {
  display: grid;
  text-align: left;
  line-height: 1.05;
}

.brand-copy strong {
  font-size: 20px;
  letter-spacing: 0;
}

.brand-copy small {
  margin-top: 7px;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.3px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #eef0f4;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.nav-tabs button {
  min-width: 130px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 18px;
  color: #4b5563;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  transition: 160ms ease;
}

.nav-tabs button.active {
  color: var(--blue);
  background: #fff;
  box-shadow: 0 1px 7px rgba(15, 23, 42, 0.08);
}

.nav-tabs svg {
  width: 16px;
  height: 16px;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
}

.quota {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  color: #0b63f6;
  background: #edf5ff;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}

.quota span {
  padding-left: 10px;
  color: var(--green);
  border-left: 1px solid #bfdbfe;
  font-size: 12px;
}

.icon-button,
.language {
  color: #374151;
  background: transparent;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.language {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
}

.language-dropdown {
  position: relative;
}

.language-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  max-height: 400px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  z-index: 100;
}

.language-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: #374151;
  text-decoration: none;
  transition: background 120ms ease;
}

.language-option:hover {
  background: #f3f4f6;
}

.language-option.active {
  background: #eef2ff;
  color: #4f46e5;
}

.lang-code {
  width: 32px;
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.language-option.active .lang-code {
  background: #ddd6fe;
}

.lang-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.lang-name-en {
  display: none;
  font-size: 12px;
  color: #9ca3af;
}

.main {
  flex: 1;
  width: min(100%, 1408px);
  margin: 0 auto;
  padding: 26px 48px 72px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.back-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #4b5563;
  background: #fff;
  border: 1px solid #edf0f4;
  border-radius: 999px;
}

.title-row h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
}

.title-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 314px;
  gap: 24px;
  align-items: start;
}

.canvas-panel,
.settings-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #edf0f4;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.05);
}

.canvas-panel {
  min-height: 764px;
  display: grid;
  place-items: center;
  padding: 38px;
  border-radius: 22px;
}

.dropzone {
  width: min(100%, 578px);
  min-height: 256px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 32px;
  text-align: center;
  background: #fff;
  border: 2px dashed #cfd6df;
  border-radius: 18px;
  transition: 180ms ease;
  position: relative;
}

.dropzone.dragover,
.dropzone:hover {
  border-color: var(--blue-2);
  background: var(--blue-soft);
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: #6b7280;
  background: #f1f3f7;
  border-radius: 50%;
}

.upload-icon svg {
  width: 36px;
  height: 36px;
}

.dropzone h2 {
  margin: 0;
  font-size: 18px;
}

.dropzone p,
.dropzone small {
  margin: 8px 0 0;
  color: #64748b;
}

.dropzone small {
  display: block;
  font-size: 12px;
}

.queue {
  width: 100%;
  align-self: stretch;
}

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.queue-head h2 {
  margin: 0;
  font-size: 22px;
}

.queue-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.saved-pill {
  padding: 10px 14px;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.file-list {
  display: grid;
  gap: 12px;
}

.file-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.thumb {
  width: 76px;
  height: 60px;
  object-fit: cover;
  border-radius: 10px;
  background: #f3f4f6;
}

.file-meta {
  min-width: 0;
}

.file-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.file-meta small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.progress-track {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: inherit;
  transition: width 250ms ease;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 10px 12px;
  color: #fff;
  background: var(--blue);
  border-radius: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.download-link.disabled {
  pointer-events: none;
  color: #64748b;
  background: #e5e7eb;
}

.settings-card {
  padding: 26px 24px 24px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 88px;
}

.settings-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #1f2937;
}

.settings-title svg {
  color: #b8c0cb;
}

.settings-title h2 {
  margin: 0;
  font-size: 20px;
}

.divider {
  height: 1px;
  margin: 14px 0 22px;
  background: var(--line);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.input-row span,
.resize-grid span {
  margin-bottom: 12px;
  color: #9ca3af;
  font-size: 13px;
  font-weight: 800;
}

.mode-field {
  display: grid;
  gap: 16px;
}

.mode-option {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 14px;
  min-height: 86px;
  padding: 14px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: 160ms ease;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
}

.mode-option.active {
  background: #eaf3ff;
  border-color: var(--blue-2);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.mode-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #9ca3af;
  background: #f1f5f9;
  border-radius: 12px;
}

.mode-option.active .mode-icon {
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.mode-option strong {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
}

.mode-option small {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.dynamic-settings {
  margin: 22px 0 18px;
}

.input-row,
.resize-grid label {
  display: grid;
  gap: 8px;
}

.input-row input,
.resize-grid input[type="number"] {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.resize-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-row {
  grid-column: 1 / -1;
  display: flex !important;
  align-items: center;
  gap: 9px !important;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.primary-action,
.secondary-action,
.ghost-action {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 800;
}

.primary-action {
  color: #fff;
  background: #9ab7f4;
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.14);
}

.primary-action:not(:disabled) {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.primary-action:disabled {
  cursor: not-allowed;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.secondary-action {
  color: #fff;
  background: #111827;
}

.ghost-action {
  color: #475569;
  background: #f1f5f9;
}

.footer {
  height: 70px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 32px;
  padding: 0 104px;
  color: #6b7280;
  background: #fff;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.footer a {
  color: #2563eb;
  font-weight: 700;
  text-decoration: none;
}

.footer strong {
  color: #2563eb;
}

.footer div {
  display: flex;
  gap: 28px;
}

.rating-card {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 190px;
  padding: 18px 16px;
  text-align: center;
  background: #fff;
  border: 1px solid #dfe4eb;
  border-radius: 14px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.13);
  font-size: 12px;
}

.rating-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
}

.stars {
  color: #cbd5e1;
  font-size: 28px;
  letter-spacing: 2px;
  line-height: 1;
}

.rating-card span {
  display: block;
  margin-top: 9px;
  color: #64748b;
  font-size: 13px;
}

body.dark {
  --bg: #111827;
  --panel: #1f2937;
  --panel-soft: #1f2937;
  --text: #f9fafb;
  --muted: #cbd5e1;
  --line: #374151;
  background: var(--bg);
}

body.dark .topbar,
body.dark .footer,
body.dark .dropzone,
body.dark .file-card,
body.dark .settings-card,
body.dark .rating-card,
body.dark .mode-option,
body.dark .canvas-panel {
  background: #1f2937;
  border-color: #374151;
}

body.dark .nav-tabs {
  background: #374151;
  border-color: #4b5563;
}

body.dark .nav-tabs button.active,
body.dark .back-button {
  background: #111827;
}

body.dark .mode-option.active {
  background: #172554;
}

body.dark .input-row input,
body.dark .resize-grid input[type="number"] {
  color: #f9fafb;
  background: #111827;
  border-color: #374151;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: auto 1fr;
  }

  .nav-tabs {
    justify-self: end;
  }

  .header-actions {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .settings-card {
    position: static;
  }

  .rating-card {
    display: none;
  }

  .canvas-panel {
    min-height: 520px;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    grid-template-columns: 1fr;
    padding: 14px 18px;
  }

  .brand {
    justify-self: center;
  }

  .nav-tabs {
    width: 100%;
    overflow-x: auto;
    justify-self: stretch;
  }

  .nav-tabs button {
    min-width: 112px;
    padding: 9px 12px;
  }

  .main {
    padding: 22px 16px 88px;
  }

  .title-row {
    align-items: flex-start;
  }

  .canvas-panel {
    min-height: 420px;
    padding: 16px;
  }

  .dropzone {
    min-height: 220px;
  }

  .file-card {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .thumb {
    width: 58px;
    height: 52px;
  }

  .download-link {
    grid-column: 1 / -1;
  }

  .footer {
    height: auto;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 18px;
    text-align: center;
  }

  .footer div {
    justify-content: center;
    gap: 16px;
  }

  .rating-card {
    display: none;
  }
}
