/* Bangers ships with the app (fonts/NOTICE.txt). block: wait for it rather than
   flash a fallback, since the preview canvas draws text with it. */
@font-face {
  font-family: 'Bangers';
  src: url('../fonts/Bangers-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  --bg: #121317;
  --pane: #1b1d23;
  --line: #2c2f38;
  --text: #e6e7ea;
  --muted: #8b8f9a;
  --accent: #7c5cff;
  --box-a: #36c5f0;
  --box-b: #f5a524;
  --speed: #2ecc71;
  --label-w: 90px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.muted { color: var(--muted); font-weight: 400; }
.mono { font-family: ui-monospace, monospace; }

/* toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--pane);
}
.brand { font-size: 15px; margin-right: 8px; }
.spacer { flex: 1; }
.field { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.field input { width: 260px; }

.btn {
  background: #2a2d36;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.danger { border-color: #a33; color: #ff8a8a; }

input, textarea, select {
  background: #0f1014;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 7px;
  font: inherit;
}

.toolbar-link { color: var(--muted); text-decoration: none; padding: 6px 8px; }
.toolbar-link:hover { color: var(--text); }
a.brand { color: var(--text); text-decoration: none; }

/* document pages (security.html) */
body.doc { display: block; height: auto; min-height: 100vh; }
.doc-main { max-width: 760px; margin: 0 auto; padding: 24px 20px 64px; font-size: 15px; line-height: 1.6; }
.doc-main h1 { font-size: 28px; margin: 0 0 4px; }
.doc-main h2 { font-size: 18px; margin: 28px 0 8px; }
.doc-main li { margin: 4px 0; }
.doc-main a { color: #a998ff; }
.doc-main code { background: #0f1014; padding: 1px 5px; border-radius: 4px; }

/* notice bar (errors and info) */
.notice {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #1f2a3d;
}
.notice.error { background: #3d1f24; color: #ffb3b3; }
.notice[hidden] { display: none; }

/* drag-and-drop highlight */
body.dragging .source-wrap { outline: 3px dashed var(--accent); outline-offset: -8px; }

/* workspace */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(240px, 26vw, 420px) 260px;
  min-height: 0;
}
.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.pane-title {
  padding: 8px 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

/* source stage */
.source-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
}
.stage { position: relative; display: none; }
.stage.ready { display: block; }
.stage video { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; }
.empty { color: var(--muted); max-width: 46ch; text-align: center; line-height: 1.55; }
.empty h1 { margin: 0 0 10px; font-size: 22px; color: var(--text); }
.empty p { margin: 0 0 8px; }
.empty .empty-start { margin-top: 16px; color: var(--text); font-weight: 600; }

.cropbox {
  position: absolute;
  border: 2px solid var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  cursor: move;
  touch-action: none;
}
.cropbox.a { --c: var(--box-a); }
.cropbox.b { --c: var(--box-b); }
.cropbox .tag {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--c);
  color: #000;
  font-weight: 700;
  font-size: 11px;
  padding: 1px 6px;
  pointer-events: none;
}
.handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--c);
  border: 2px solid #000;
}
.handle[data-h="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
.handle[data-h="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
.handle[data-h="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.handle[data-h="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }
.handle[data-h="n"] { left: calc(50% - 14px); top: -5px; width: 28px; height: 8px; cursor: ns-resize; }
.handle[data-h="s"] { left: calc(50% - 14px); bottom: -5px; width: 28px; height: 8px; cursor: ns-resize; }
.handle[data-h="e"] { top: calc(50% - 14px); right: -5px; width: 8px; height: 28px; cursor: ew-resize; }
.handle[data-h="w"] { top: calc(50% - 14px); left: -5px; width: 8px; height: 28px; cursor: ew-resize; }

/* snap guides */
.guide { position: absolute; background: #ff3ec8; pointer-events: none; }
.guide[hidden] { display: none; }
.guide-x { top: 0; bottom: 0; left: calc(50% - 1px); width: 2px; }
.guide-y { left: 0; right: 0; top: calc(50% - 1px); height: 2px; }

/* preview */
.preview-wrap {
  flex: 1;
  min-height: 0;
  padding: 12px;
  display: grid;
  place-items: center;
}
#preview {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  touch-action: none;
}

/* properties panel */
.panel { padding: 12px; display: grid; gap: 10px; align-content: start; }
.panel label { display: grid; gap: 4px; color: var(--muted); min-width: 0; }
.panel input, .panel select, .panel textarea { width: 100%; min-width: 0; }
.panel .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.panel textarea { resize: vertical; min-height: 54px; }

/* timeline */
.timeline-pane { border-top: 1px solid var(--line); background: var(--pane); }
.transport { display: flex; align-items: center; gap: 12px; padding: 6px 12px; }
.timeline { position: relative; padding-bottom: 8px; user-select: none; }

.tl-row { display: grid; grid-template-columns: var(--label-w) 1fr; height: 28px; }
.tl-row.ruler { height: 22px; }
.tl-label {
  padding: 0 10px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
}
.tl-track {
  position: relative;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.tl-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
  padding-left: 3px;
  pointer-events: none;
}

.tl-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  cursor: grab;
  touch-action: none;
}
.tl-bar.speed { background: var(--speed); color: #000; }
.tl-bar.selected { outline: 2px solid #fff; }
.tl-edge { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.tl-edge.l { left: 0; }
.tl-edge.r { right: 0; }

.tl-playhead-layer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--label-w);
  right: 0;
  pointer-events: none;
}
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff4d4d; }

/* modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: grid;
  place-items: center;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--pane);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
  width: min(720px, 92vw);
}
.modal-card h3 { margin: 0 0 12px; }
.modal-card pre {
  background: #0f1014;
  padding: 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.progress { height: 8px; background: #0f1014; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); }

/* keyboard focus: always visible when using the keyboard */
.btn:focus-visible,
.toolbar-link:focus-visible,
.cropbox:focus-visible,
.tl-bar:focus-visible,
.tl-track:focus-visible,
#preview:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.doc-main a:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* text only screen readers hear */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* keyboard shortcuts table */
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys th { text-align: left; padding: 10px 0 4px; color: var(--muted); font-weight: 600; }
.keys td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.keys td:first-child { width: 40%; font-family: ui-monospace, monospace; }
.modal-card { max-height: 90vh; overflow: auto; }

/* emoji picker (inside the dialog) */
.emoji-picker { display: grid; gap: 10px; }
.emoji-search {
  width: 100%;
  padding: 8px 10px;
  background: #0f1014;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}
.emoji-tones, .emoji-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-tone {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--swatch);
  cursor: pointer;
}
.emoji-tone[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }
.emoji-tab {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.emoji-tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.emoji-status { margin: 0; font-size: 13px; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 46px);
  gap: 4px;
  height: min(46vh, 380px);
  overflow-y: auto;
  align-content: start;
  padding: 2px;
}
.emoji-cell {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.emoji-cell:hover { background: var(--line); }
.emoji-cell:focus-visible, .emoji-tone:focus-visible, .emoji-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* selected emoji in the properties panel */
.emoji-current { display: flex; align-items: center; gap: 10px; color: var(--text); }

/* hint tip: one floating element placed by js/hints.js */
.hint-tip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  padding: 7px 10px;
  background: #f4f4f6;
  color: #15161a;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.hint-tip[hidden] { display: none; }

/* quick start strip under the toolbar */
.tips {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--accent) 16%, var(--pane));
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.tips[hidden] { display: none; }
.tips ol { flex: 1; display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; padding-left: 18px; }
.tips-end { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.tips-end p { margin: 0; }
@media (max-width: 900px) { .tips { flex-wrap: wrap; } .tips-end { margin-left: auto; } }
