:root {
  --bg: #121317;
  --panel: #1a1c22;
  --raised: #23262e;
  --line: #2e313a;
  --text: #e8e9ee;
  --muted: #8a8f9c;
  --accent: #6d8bff;
  --accent-ink: #0d1330;
  --warn: #ffb547;
  --error: #ff6b6b;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.primary, .ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  background: var(--raised);
}
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.primary:hover { filter: brightness(1.08); }
.ghost:hover { background: var(--line); }
.muted { color: var(--muted); }

/* top bar */

.top {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 750; letter-spacing: -0.2px; white-space: nowrap; }
.logo { color: var(--accent); }
.name {
  width: 180px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 8px;
}
.name:hover, .name:focus { border-color: var(--line); outline: none; }
.languages { display: flex; gap: 6px; align-items: center; overflow-x: auto; flex: 1; }
.lang {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 99px;
  padding: 4px 6px 4px 12px; background: transparent; white-space: nowrap;
}
.lang.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.lang .x { border: 0; background: transparent; opacity: 0.6; padding: 0 4px; }
.lang .x:hover { opacity: 1; }
.add-lang { background: transparent; border: 1px dashed var(--line); border-radius: 99px; padding: 4px 8px; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; }
.menu { position: relative; }
.menu-items {
  position: absolute; right: 0; top: 40px; z-index: 10; min-width: 190px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}
.menu-items[hidden] { display: none; }
.menu-items button, .menu-items label {
  text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.menu-items button:hover, .menu-items label:hover { background: var(--line); }
#checks-button.has-errors { color: var(--error); border-color: var(--error); }
#checks-button.has-warnings { color: var(--warn); }

/* layout */

.editor {
  display: grid;
  grid-template-columns: 200px 1fr 320px;
  height: calc(100% - 56px);
}

.slides {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  overflow-y: auto;
}
#slide-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.slide-item {
  position: relative;
  display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: start;
  padding: 6px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
}
.slide-item.active { border-color: var(--accent); background: rgba(109,139,255,0.08); }
.slide-item .num { color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.slide-item canvas { width: 100%; border-radius: 6px; display: block; }
/* below the thumbnail, never on top of it, so selecting a slide can't
   accidentally move or delete it */
.slide-tools {
  grid-column: 2; display: none; justify-content: space-between; gap: 2px;
  background: var(--raised); border-radius: 6px; padding: 2px;
}
.slide-item.active .slide-tools { display: flex; }
.slide-tools button { border: 0; background: transparent; padding: 2px 6px; border-radius: 4px; }
.slide-tools button:hover { background: var(--line); }
.add-slides {
  display: block; margin-top: 12px; padding: 10px; text-align: center; cursor: pointer;
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted);
}
.add-slides:hover { color: var(--text); border-color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 6px 0 0; }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.stage-bar select, .panel select, .panel input[type=text], .panel textarea, .panel input[type=number] {
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}
.canvas-wrap {
  flex: 1; min-height: 0; display: grid; place-items: center; padding: 24px; overflow: hidden;
  background:
    linear-gradient(45deg, #15161a 25%, transparent 25%) 0 0 / 24px 24px,
    linear-gradient(-45deg, #15161a 25%, transparent 25%) 0 0 / 24px 24px,
    var(--bg);
}
#preview { max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }

/* right panel */

.panel { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: transparent; border: 0; padding: 12px 0; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
#panel-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .group-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.field textarea { resize: vertical; min-height: 56px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
input[type=color] { width: 100%; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--raised); padding: 4px; border-radius: 9px; }
.segmented button { border: 0; background: transparent; padding: 6px 4px; border-radius: 6px; font-size: 13px; }
.segmented button.active { background: var(--line); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset { height: 54px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 650; font-size: 12px; }
.drop-zone {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted); cursor: pointer;
}
.drop-zone:hover { border-color: var(--muted); color: var(--text); }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.issue { display: grid; grid-template-columns: 18px 1fr; gap: 8px; padding: 10px; border-radius: 8px; background: var(--raised); cursor: default; }
.issue.error .icon { color: var(--error); }
.issue.warning .icon { color: var(--warn); }
.issue .where { color: var(--muted); font-size: 12px; margin-top: 2px; }
.issue[data-slide] { cursor: pointer; }
.ok { color: #63d297; }

/* dialog */

dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text);
  width: min(620px, 92vw); padding: 24px;
}
dialog::backdrop { background: rgba(0,0,0,0.55); }
dialog h2 { margin: 0 0 4px; }
dialog h3 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.export-grid label { display: flex; gap: 8px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.export-grid small { display: block; color: var(--muted); }
.badge { font-size: 11px; color: var(--accent); margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; }
.summary { margin: 18px 0 8px; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.drop-overlay {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 50;
  background: rgba(109,139,255,0.18); border: 3px dashed var(--accent); font-size: 22px; font-weight: 700;
}
.drop-overlay[hidden] { display: none; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.toast[hidden] { display: none; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: auto 60vh auto; height: auto; }
  .slides { border-right: 0; border-bottom: 1px solid var(--line); }
  #slide-list { flex-direction: row; overflow-x: auto; }
  .slide-item { width: 110px; flex: none; }
  .name, .languages { display: none; }
  .top { gap: 8px; }
}

/* colour fields */
.color-row { display: grid; grid-template-columns: 44px 1fr; gap: 8px; }
.color-row input[type=color] { height: 34px; }
.hex { font-family: ui-monospace, "SF Mono", Menlo, monospace; text-transform: lowercase; }
.hex.invalid { border-color: var(--error) !important; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.18); padding: 0; }
.swatch:hover { transform: scale(1.15); }
.group { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.drop-zone.empty { border-color: var(--warn); color: var(--warn); }
.link { background: none; border: 0; color: var(--muted); text-align: left; padding: 0; text-decoration: underline; }
.link:hover { color: var(--text); }
