:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-strong: #f7f9fb;
  --text: #17202a;
  --muted: #637083;
  --line: #d8e0e8;
  --primary: #1267d8;
  --primary-strong: #0b4fa8;
  --accent: #0f9f6e;
  --danger: #c03744;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(120deg, rgba(18, 103, 216, 0.08), transparent 36%),
    linear-gradient(240deg, rgba(15, 159, 110, 0.08), transparent 42%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(216, 224, 232, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar,
.layout,
.log-panel {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 251, 0.82);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 14px;
  text-align: center;
}

.status-pill.active {
  color: var(--primary-strong);
  border-color: rgba(18, 103, 216, 0.35);
  background: rgba(18, 103, 216, 0.08);
}

.status-pill.done {
  color: #0a6a4b;
  border-color: rgba(15, 159, 110, 0.35);
  background: rgba(15, 159, 110, 0.1);
}

.status-pill.error {
  color: var(--danger);
  border-color: rgba(192, 55, 68, 0.35);
  background: rgba(192, 55, 68, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
  gap: 20px;
}

.panel,
.log-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.composer,
.result-panel {
  padding: 20px;
}

.field-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label,
.checkbox-row {
  color: #2b3645;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-strong);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 260px;
  padding: 12px;
  line-height: 1.6;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(18, 103, 216, 0.65);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(18, 103, 216, 0.1);
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-strong);
  cursor: pointer;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 22px;
}

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

.actions,
.download-row,
.result-header,
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.actions {
  margin: 18px 0;
}

.primary-button,
.secondary-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  color: var(--primary-strong);
  background: rgba(18, 103, 216, 0.08);
  border-color: rgba(18, 103, 216, 0.22);
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.download-button {
  color: #fff;
  background: var(--accent);
}

.download-button.disabled {
  pointer-events: none;
  color: #7b8794;
  background: #e6ebf0;
}

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

.manual-query {
  display: grid;
  gap: 8px;
}

.result-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.video-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #111820;
}

.video-stage.landscape {
  aspect-ratio: 16 / 9;
}

.video-stage.square {
  aspect-ratio: 1 / 1;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 14px;
  color: #d5dde7;
  text-align: center;
}

.empty-state p {
  margin: 0;
}

.play-mark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 43%, #fff 43% 57%, transparent 57%),
    rgba(255, 255, 255, 0.14);
}

.download-row {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
}

.steps li.done {
  color: #0a6a4b;
  font-weight: 700;
}

.steps li.active {
  color: var(--primary-strong);
  font-weight: 700;
}

.steps li.error {
  color: var(--danger);
  font-weight: 700;
}

.log-panel {
  margin: 0 24px 24px;
}

.log-header {
  margin-bottom: 12px;
}

.text-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

pre {
  min-height: 120px;
  max-height: 260px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: 8px;
  color: #dfe7ef;
  background: #111820;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .video-stage {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .topbar,
  .layout,
  .log-panel {
    padding: 18px;
  }

  .topbar,
  .actions,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .checkbox-row {
    margin-top: 0;
  }

  .primary-button,
  .secondary-button,
  .download-button {
    width: 100%;
  }

  .log-panel {
    margin: 0 18px 18px;
  }
}
