:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --fg: #17171a;
  --muted: #6b6b74;
  --line: #e2e2e7;
  --accent: #3b6fd4;
  --accent-fg: #ffffff;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121215;
    --panel: #1b1b20;
    --fg: #e9e9ee;
    --muted: #9a9aa5;
    --line: #2c2c34;
    --accent: #6f9bf0;
    --accent-fg: #0d0d10;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.65 system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
        "Noto Sans JP", Meiryo, sans-serif;
}

header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.2rem 0 1.2rem;
}

h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
}

.sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
}

/* --- ドロップ領域 --- */

.drop {
  text-align: center;
  padding: 2.4rem 1.2rem;
  border-style: dashed;
  border-width: 2px;
  transition: border-color .15s, background .15s;
}

.drop.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.dropTitle { margin: 0; font-size: 1.05rem; font-weight: 600; }
.dropHint { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.9rem; }
.fileInfo { margin: 0.8rem 0 0; font-size: 0.9rem; color: var(--accent); min-height: 1.2em; }

/* --- 設定 --- */

.opts { display: grid; gap: 0.85rem; }

.optRow {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr auto;
  align-items: center;
  gap: 0.9rem;
}

.optRow label { font-size: 0.92rem; }
.hint { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 400; }

.optRow output {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 3.4em;
  text-align: right;
}

select, input[type=range] { width: 100%; max-width: 340px; }

select {
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  padding: 0.45rem 0.9rem;
}

button:disabled { opacity: 0.45; cursor: default; }

.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  justify-self: start;
}

.primary.small { padding: 0.35rem 0.9rem; font-weight: 500; }
.ghost { background: transparent; }

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
}

/* --- 進捗 --- */

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s;
}

.stage { margin: 0.7rem 0 0; font-size: 0.92rem; }

.log {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  max-height: 8em;
  overflow: auto;
}

/* --- 結果 --- */

.tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.tabs .spacer { flex: 1; }

.tab { border-color: transparent; background: transparent; color: var(--muted); }
.tab.active { background: var(--bg); color: var(--fg); border-color: var(--line); }

.viewport {
  background: #000;
  border-radius: 8px;
  overflow: auto;
  max-height: 78vh;
  display: grid;
  place-items: center;
}

.viewport canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.viewport.zoomed { place-items: start; }
.viewport.zoomed canvas { max-width: none; cursor: grab; }

/* --- 注意書き --- */

.notes h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.notes ul { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.88rem; }
.notes li { margin-bottom: 0.35rem; }

@media (max-width: 720px) {
  .optRow { grid-template-columns: 1fr; gap: 0.3rem; }
  .optRow output { text-align: left; }
}
