:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --panel-2: #eef3f1;
  --ink: #17201d;
  --muted: #64726d;
  --line: #d9e1de;
  --accent: #117864;
  --accent-2: #e9b44c;
  --danger: #b94040;
  --shadow: 0 18px 42px rgba(30, 45, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.workspace,
.settings-panel {
  min-width: 0;
}

.topbar,
.settings-panel,
.timeline-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 16px 18px;
  border-radius: 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p,
.settings-panel small,
.timeline-toolbar span,
.drop-empty span,
.status-panel p {
  color: var(--muted);
}

.topbar p {
  margin-top: 7px;
  font-size: 14px;
}

.topbar-actions,
.timeline-actions,
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#fileInput {
  display: none;
}

.icon-button,
.round-button,
.input-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 650;
}

.icon-button {
  padding: 0 13px;
}

.round-button {
  width: 38px;
  padding: 0;
  font-size: 17px;
}

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

.success {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #231a08;
}

.danger {
  color: var(--danger);
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 284px);
  margin-top: 20px;
  overflow: hidden;
  border: 1px dashed #b8c6c1;
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(17, 120, 100, 0.07) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(45deg, transparent 75%, rgba(233, 180, 76, 0.12) 75%) 0 0 / 28px 28px,
    #fbfcfc;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background-color: #f2fbf8;
}

.drop-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.drop-empty strong {
  font-size: 22px;
}

.has-frames .drop-empty {
  display: none;
}

#previewCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 1180px);
  max-height: calc(100vh - 330px);
  background: #111615;
}

.timeline-panel {
  margin-top: 20px;
  padding: 14px;
  border-radius: 8px;
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.timeline-toolbar > div:first-child {
  display: grid;
  gap: 4px;
}

.timeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 132px;
  gap: 10px;
  min-height: 158px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.frame-card {
  display: grid;
  grid-template-rows: 76px auto auto;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--panel-2);
  cursor: grab;
}

.frame-card.selected {
  border-color: var(--accent);
  background: #e4f4ef;
}

.frame-card.dragging {
  opacity: 0.45;
}

.frame-thumb {
  width: 100%;
  height: 76px;
  object-fit: contain;
  border-radius: 6px;
  background: #202826;
}

.frame-name {
  overflow: hidden;
  color: #2f3d39;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frame-duration {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 7px;
  background: #fff;
}

.settings-panel {
  align-self: start;
  display: grid;
  gap: 18px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
}

.settings-panel section {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span,
.check-row span {
  color: #33423e;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.field input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input-row input {
  min-width: 0;
}

.input-row button {
  min-width: 70px;
  padding: 0 12px;
  background: #eef3f1;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.status-panel {
  padding-top: 4px;
}

.status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.status-row p {
  min-width: 0;
}

.status-row small {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3ebe8;
}

#progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.download-link {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  text-decoration: none;
}

.download-link.ready {
  display: flex;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .icon-button {
    flex: 1 1 95px;
  }

  .drop-zone {
    min-height: 360px;
  }

  #previewCanvas {
    max-height: 420px;
  }

  .settings-panel {
    position: static;
    max-height: none;
  }
}
