:root {
  color-scheme: dark light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  --bg: #121212;
  --surface: #1b1b1b;
  --code-bg: #0b0b0b;
  --border: #2c2c2c;
  --text: #e6e6e6;
  --muted: #a6a6a6;
  --accent: #f7a41d;
  --accent-hover: #ffb43b;
  --accent-text: #121212;
  --link: #f7a41d;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #f6f6f6;
    --code-bg: #eeeeee;
    --border: #dcdcdc;
    --text: #121212;
    --muted: #555555;
    --accent: #f7a41d;
    --accent-hover: #e5940c;
    --accent-text: #121212;
    --link: #b86b00;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: clamp(1rem, 3vw, 2rem) clamp(0.75rem, 3vw, 2rem);
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--link);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 1.25rem;
  align-items: start;
}

header {
  grid-column: 1 / -1;
}

header h1 {
  margin: 0 0 0.25rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.meta {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  min-width: 0;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

#gl-canvas {
  display: block;
  width: 100%;
  max-width: 960px;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

#gl-canvas:active {
  cursor: grabbing;
}

.media-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d111a;
  margin-bottom: 0.75rem;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.media-box {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d111a;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.row + .row {
  margin-top: 0.6rem;
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

input[type="text"] {
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font-size: 0.95rem;
  flex: 1 1 200px;
  min-width: 0;
  max-width: 100%;
}

input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type="file"] {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 100%;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--muted);
  padding: 1.35rem 1rem;
  text-align: center;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.drop-zone.drag-over,
.drop-zone:focus {
  border-color: var(--accent);
  color: var(--text);
  outline: none;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .panel {
    padding: 0.9rem 1rem;
  }

  button {
    width: 100%;
  }
}
