:root {
  --bg-a: #0b1118;
  --bg-b: #162632;
  --panel: rgba(8, 16, 25, 0.74);
  --fg: #e8f4ff;
  --subtle: #a3c0d8;
  --accent: #6de8bc;
  --accent-2: #2fc8ff;
  --danger: #ff7f7f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--fg);
  min-height: 100vh;
  background: radial-gradient(1100px 600px at 15% 10%, #27435f 0%, transparent 50%),
    linear-gradient(140deg, var(--bg-a), var(--bg-b));
}

.layout {
  width: min(1360px, 94vw);
  margin: 0.8rem auto 1.4rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
}

header,
#error-panel {
  grid-column: 1 / -1;
}

#preview-panel {
  grid-column: 1;
  grid-row: 2;
}

#result-panel {
  grid-column: 1;
  grid-row: 3;
}

#controls-panel {
  grid-column: 2;
  grid-row: 2;
}

#status-panel {
  grid-column: 2;
  grid-row: 3;
}

header h1 {
  margin: 0;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
  line-height: 1.1;
}

header p {
  margin: 0;
  color: var(--subtle);
  font-size: 0.78rem;
  line-height: 1.15;
}

header {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(109, 232, 188, 0.22);
  border-radius: 0.9rem;
  padding: 1rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
}

.help-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.help-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 1px solid rgba(109, 232, 188, 0.5);
  color: var(--subtle);
  font-size: 0.72rem;
  line-height: 1;
  cursor: help;
}

.help-mark::after {
  content: attr(data-help);
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: 230px;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(109, 232, 188, 0.35);
  color: var(--fg);
  background: rgba(6, 13, 20, 0.96);
  font-size: 0.73rem;
  line-height: 1.35;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.help-mark:hover::after,
.help-mark:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.live-seek-wrap {
  margin-bottom: 0.8rem;
}

.seek-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--subtle);
  margin-top: 0.28rem;
}

.seek-action-row {
  margin-top: 0.4rem;
}

.seek-action-row button {
  width: 100%;
}

.audio-controls {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

input[type="file"] {
  display: block;
  width: 100%;
  margin-bottom: 0.8rem;
}

input[type="range"],
select {
  width: 100%;
}

select {
  border: 1px solid rgba(109, 232, 188, 0.35);
  border-radius: 0.55rem;
  padding: 0.45rem 0.55rem;
  color: var(--fg);
  background: rgba(5, 12, 18, 0.85);
}

button {
  border: none;
  border-radius: 0.65rem;
  padding: 0.7rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
  color: #081118;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.action-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.action-row button {
  flex: 1;
}

.secondary {
  color: var(--fg);
  border: 1px solid rgba(109, 232, 188, 0.45);
  background: rgba(5, 12, 18, 0.85);
}

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

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(109, 232, 188, 0.35);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7df7ca, #4ec9ff);
  transition: width 0.18s linear;
}

#preview-canvas,
#result-video {
  width: 100%;
  border-radius: 0;
  border: none;
  background: #000;
}

#preview-canvas {
  display: block;
  max-width: none;
}

.preview-viewport {
  width: 100%;
  overflow: auto;
}

#preview-canvas {
  min-height: 240px;
}

#download-link {
  display: inline-block;
  margin-top: 0.7rem;
  color: var(--accent);
}

#error-text {
  color: var(--danger);
  white-space: pre-wrap;
}

.hidden {
  display: none;
}

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

  #preview-panel,
  #controls-panel,
  #status-panel,
  #result-panel,
  #error-panel,
  header {
    grid-column: 1;
    grid-row: auto;
  }
}
