:root {
  --font-base: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-lifted: #f1f5f9;
  --border: rgba(20, 26, 41, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #94a3b8;
  --accent-strong: #64748b;
  --danger: #64748b;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

.text-base {
  font-family: var(--font-base);
  font-size: .8rem;
  line-height: 1rem;
  color: var(--text);
}

.text-base * {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

.text-base i[class*="fa-"],
.text-base i[class^="fa-"] {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900;
  font-style: normal;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(148, 163, 184, 0.15), transparent 45%),
    var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem clamp(1.5rem, 3vw, 3rem);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
}

.logo {
  font-weight: 600;
}

.token-input {
  display: inline-flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.token-input label {
  color: var(--muted);
}

.token-input input {
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.token-input button,
button.primary,
.controls button,
.icon-btn {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: var(--text);
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s ease, filter 0.2s ease;
}

button.primary:disabled,
.token-input button:disabled,
.controls button:disabled,
.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary:hover:not(:disabled),
.token-input button:hover:not(:disabled),
.controls button:hover:not(:disabled),
.icon-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

main {
  padding: clamp(1.5rem, 3vw, 3rem);
  max-width: 1100px;
  margin: 0 auto;
}

.dev-note {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.control-row {
  display: grid;
  grid-template-columns: 4fr 1fr 1fr 1fr;
  gap: 1rem;
  align-items: flex-end;
}

.control-row > * {
  min-width: 0;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: var(--muted);
  min-width: 220px;
}

.control-field.prompt-field {
  min-width: 0;
  width: 100%;
}

.control-field.prompt-field input {
  width: 100%;
  box-sizing: border-box;
}

.control-field label {
  color: var(--muted);
}

.control-field select,
.control-field input,
.control-field textarea {
  padding: 0.45rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.control-field select,
.control-field input[type="text"] {
  border-radius: 999px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  height: fit-content;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: var(--muted);
}

.checkbox-label span {
  color: var(--text);
}

.control-field select {
  cursor: pointer;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn.circle {
  width: 36px;
  height: 36px;
}

.circle-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text);
  font-weight: 600;
  margin-left: 0.35rem;
  cursor: pointer;
}


#rows {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.add-row-panel {
  margin-top: 1.5rem;
}

.add-row-action {
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-row-action.solo {
  padding: 1rem 0;
}

.row {
  display: grid;
  grid-template-columns: 0.2fr 0.2fr 0.2fr 0.4fr;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  align-items: stretch;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  height: 100%;
}

.col label {
  color: var(--muted);
}

.col input,
.col textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: var(--panel-lifted);
  color: var(--text);
  resize: none;
}

.col.fill textarea,
.col.fill input {
  flex: 1;
  min-height: 180px;
  width: 100%;
}

.prompt-box {
  position: relative;
  height: 100%;
}

.prompt-box textarea {
  height: 100%;
  padding: 0.45rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.prompt-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--text);
  font-style: normal;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.prompt-overlay.hidden {
  opacity: 0;
}

.upload-box {
  position: relative;
  border: 1px dashed rgba(15, 23, 42, 0.15);
  border-radius: 0.9rem;
  overflow: hidden;
  min-height: 180px;
  cursor: pointer;
}

.upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.image-preview {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  background: var(--panel-lifted);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.2s ease;
  pointer-events: none;
  position: relative;
}

.upload-placeholder {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--muted);
}

.upload-placeholder .upload-icon {
  font-size: 1rem;
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  display: inline-block;
}

.image-preview.has-image .upload-placeholder {
  display: none;
}

.image-preview.has-image {
  color: transparent;
}

.swap-icon {
  margin-left: 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: var(--muted);
  pointer-events: none;
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  display: inline-block;
  font-style: normal;
}

.swap-icon.visible {
  opacity: 1;
  pointer-events: auto;
}

.swap-icon:hover {
  color: var(--text);
}

.upload-box:hover .image-preview {
  transform: scale(0.98);
}

.result {
  grid-column: span 1;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.btn-download,
.btn-repeat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--muted);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: var(--font-base);
  font-size: 0.8rem;
  line-height: 1rem;
  background: #ffffff;
  color: var(--muted);
  height: fit-content;
}

.btn-download:hover:not(:disabled),
.btn-repeat:hover:not(:disabled) {
  background: var(--muted);
  color: #ffffff;
  border-color: var(--muted);
}

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

.btn-download i,
.btn-repeat i {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900;
  font-style: normal;
  font-size: 0.7rem;
}

.result .result-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem;
  height: 100%;
  background: var(--panel-lifted);
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.result-video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.5rem;
  position: absolute;
}

.result .status {
  color: var(--muted);
}

.result .status.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  font-weight: 500;
  color: var(--muted);
}

.result .status.tag::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.result .status.tag.sending {
  color: var(--muted);
  background: rgba(15, 23, 42, 0.06);
}

.result .status.tag.sending::before {
  background: var(--muted);
}

.result .status.tag.waiting {
  color: var(--muted);
  background: rgba(15, 23, 42, 0.06);
}

.result .status.tag.waiting::before {
  background: var(--muted);
}

.result .status.tag.success {
  color: var(--muted);
  background: rgba(15, 23, 42, 0.06);
}

.result .status.tag.success::before {
  background: var(--muted);
}

.result .status.loading {
  color: var(--muted);
}

.result .status.error {
  color: var(--muted);
}

.result-link {
  color: var(--muted);
  text-decoration: none;
  text-align: center;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.actions .actions-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.actions button {
  border-radius: 0.7rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
}

.actions button.primary {
  border: none;
}

.actions button.ghost {
  background: transparent;
}

.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: var(--font-base);
  font-size: 0.8rem;
  line-height: 1rem;
  background: var(--muted);
  color: #ffffff;
  max-width: 200px;
  margin: 0 auto;
}

.btn-generate:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

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

.btn-generate i {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900;
  font-style: normal;
}

@media (max-width: 1100px) {
  .row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}
