/* Built from the astab portfolio sheet: hairline 1px grid, Azeret Mono,
   zero radii, no shadows. Colours come from vars.css (paper/ink inverted). */

*,
*::before,
*::after { box-sizing: border-box; }

* {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  text-decoration: none;
  -webkit-font-smoothing: antialiased;
}

html, body { height: 100%; margin: 0; }

body {
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-mono-light);
  font-weight: 300;
  font-size: 14px;
  overflow: hidden;
}

/* --------------------------------------------------------- menu bar ----- */
body { display: flex; flex-direction: column; }

#stalebar {
  flex: 0 0 auto;
  background: var(--color-red);
  color: var(--color-red-ink);
  font-size: 13px;
  padding: 8px 16px;
  text-align: center;
}
#stalebar code { border: 1px solid currentColor; padding: 0 5px; }
#stalebar[hidden] { display: none; }

#menubar {
  flex: 0 0 auto;
  border-bottom: var(--line);
  display: flex;
  align-items: stretch;
  background: var(--color-paper);
  height: 28px;
}
.menu { position: relative; }
.menu-btn {
  border: none; height: 100%; padding: 0 12px; border-radius: 0;
  font-size: 13px;
}
.menu-btn:hover, .menu.open .menu-btn { background: var(--faint); }
.menu-drop {
  position: absolute; top: 100%; left: 0; z-index: 999990;
  min-width: 210px;
  border: var(--line); background: var(--color-paper);
  display: none; flex-direction: column;
}
.menu.open .menu-drop { display: flex; }
.menu-drop button {
  border: none; border-radius: 0; text-align: left; padding: 6px 12px;
  font-size: 13px; white-space: nowrap;
}
.menu-drop button:hover { background: var(--color-ink); color: var(--color-white); }
.menu-sep { height: 1px; background: var(--faint-strong); margin: 3px 0; }
.menu-spacer { flex: 1 1 auto; }
.menu-brand {
  display: flex; align-items: center; padding: 0 14px;
  font-family: var(--font-mono-semibold); font-weight: 600; color: var(--dim);
}

/* ------------------------------------------------------------ layout ---- */
.app {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}

.panel {
  border-right: var(--line);
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel__head {
  border-bottom: var(--line);
  padding: var(--header-padding-block) var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.site-title {
  font-family: var(--font-mono-semibold);
  font-weight: 600;
  font-size: 20px;
}

.site-sub { font-size: 14px; color: var(--dim); }

#controls {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.panel__foot {
  border-top: var(--line);
  padding: var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.stage-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* ------------------------------------------------------------ groups ---- */
details { border-bottom: var(--line); }

summary {
  padding: var(--header-padding-block) var(--content-padding);
  font-family: var(--font-mono-regular);
  font-weight: 400;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; width: 10px; color: var(--dim); }
details[open] > summary::before { content: "\2212"; }
summary:hover { background: var(--faint); }

.group-body {
  padding: 4px var(--content-padding) var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ------------------------------------------------------------- rows ----- */
.row { display: flex; flex-direction: column; gap: 4px; }

.row__label {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}

.row__name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row__text { overflow-wrap: anywhere; }
.row__val {
  font-family: var(--font-mono-regular);
  font-weight: 400;
  white-space: nowrap;
  flex: 0 0 auto;
}

.note {
  font-size: 12px;
  line-height: 15px;
  color: var(--dim);
  border-left: var(--line);
  padding-left: 8px;
}

/* -------------------------------------------------------- info bubble --- */
.info {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: var(--line);
  font-size: 10px;
  line-height: 12px;
  text-align: center;
  font-family: var(--font-mono-regular);
  font-weight: 400;
  cursor: help;          /* deliberately NOT hidden, unlike the portfolio */
  user-select: none;
}
.info:hover { background: var(--color-ink); color: var(--color-white); }

/* Mirrors .astab-cursor-label from the portfolio. */
#tip {
  border: var(--line);
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-mono-light);
  font-size: 12px;
  font-weight: 300;
  line-height: 15px;
  padding: 6px 8px;
  max-width: 300px;
  position: fixed;
  left: 0; top: 0;
  z-index: 999998;
  pointer-events: none;
  transform: translate(14px, 14px);
}
#tip[hidden] { display: none; }
#tip strong { font-family: var(--font-mono-semibold); font-weight: 600; }

.sm { font-size: 12px; padding: 2px 8px; }

/* ------------------------------------------------------------ inputs ---- */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: none;
  cursor: ew-resize;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 14px;
  border: var(--line);
  background: var(--color-paper);
}
input[type=range]::-moz-range-track {
  height: 14px;
  border: var(--line);
  background: var(--color-paper);
}
/* square handles */
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 12px;
  border: none;
  border-radius: 0;
  background: var(--color-ink);
  margin-top: 0;
}
input[type=range]::-moz-range-thumb {
  width: 10px;
  height: 12px;
  border: none;
  border-radius: 0;
  background: var(--color-ink);
}
input[type=range]:focus-visible::-webkit-slider-runnable-track {
  outline: var(--line);
  outline-offset: 2px;
}

select, button, input[type=text] {
  border: var(--line);
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-mono-light);
  font-weight: 300;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 0;
}
select { width: 100%; cursor: pointer; }
button { cursor: pointer; }
button:hover:not(:disabled), select:hover { background: var(--faint); }
button:disabled { color: var(--dim); cursor: default; }

.button--primary {
  background: var(--color-ink);
  color: var(--color-white);
  font-family: var(--font-mono-regular);
  font-weight: 400;
}
.button--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-ink) 80%, var(--color-paper));
}

input[type=checkbox] {
  appearance: none;
  width: 14px; height: 14px;
  border: var(--line);
  background: var(--color-paper);
  cursor: pointer;
  flex: 0 0 auto;
}
input[type=checkbox]:checked { background: var(--color-ink); }

.btnrow { display: flex; flex-direction: row; gap: 8px; }
.btnrow > * { flex: 1 1 0; min-width: 0; }
.check-row { flex-direction: row; align-items: center; gap: 8px; }

kbd {
  border: 1px solid currentColor;
  padding: 0 4px;
  font-size: 11px;
  font-family: var(--font-mono-light);
}

/* ----------------------------------------------------------- process ---- */
#process { padding: 10px; font-size: 16px; width: 100%; }
#process.busy {
  background: var(--color-red);
  border-color: var(--color-red);
  color: var(--color-red-ink);
}
#process.busy:hover {
  background: color-mix(in srgb, var(--color-red) 82%, var(--color-paper));
}

/* red is reserved for destructive / stop actions */
.button--danger {
  border-color: var(--color-red);
  color: var(--color-red);
}
.button--danger:hover:not(:disabled) {
  background: var(--color-red);
  color: var(--color-red-ink);
}
.button--danger:disabled { border-color: var(--faint-strong); color: var(--dim); }

#stats { font-size: 12px; color: var(--dim); min-height: 15px; }

/* ------------------------------------------------- progress over canvas -- */
#progress {
  position: absolute;
  left: 0; right: 0; top: 0;
  z-index: 6;
  border-bottom: var(--line);
  background: var(--color-paper);
}
#progress[hidden] { display: none; }

#progress .pg-track { height: 6px; background: var(--faint-strong); }
#progress .pg-fill {
  height: 100%;
  width: 0;
  background: var(--color-red);
  transition: width .12s linear;
}
#progress .pg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px var(--content-padding);
  font-size: 12px;
}
#progress .pg-label {
  font-family: var(--font-mono-regular);
  font-weight: 400;
}
#progress .pg-right { color: var(--dim); display: flex; gap: 10px; align-items: center; }
#pgcancel {
  border-color: var(--color-red);
  color: var(--color-red);
  padding: 1px 8px;
  font-size: 12px;
}
#pgcancel:hover { background: var(--color-red); color: var(--color-red-ink); }

/* ------------------------------------------------------------ toolbar --- */
#toolbar {
  border-bottom: var(--line);
  padding: 5px var(--content-padding);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: var(--color-paper);
}
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-lbl { color: var(--dim); font-size: 12px; }
.tb-sep { width: 1px; align-self: stretch; background: var(--faint-strong); margin: 0 2px; }
#toolbar button, #toolbar select { font-size: 12px; padding: 2px 8px; }
#toolbar #brushsize { width: 90px; }

/* icon tool buttons */
.icon-btn {
  border: var(--line);
  width: 28px; height: 26px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn.is-on { background: var(--faint-strong); border-color: var(--color-ink); }
.icon-btn.tool-green { color: #12912f; }
.icon-btn.tool-red { color: var(--color-red); }
:root[data-theme="dark"] .icon-btn.tool-green { color: #35d06a; }

/* ------------------------------------------------------------- stage ---- */
/* .on-dark in vars.css keeps this area dark in both themes */
#stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  border-left: none;
}

#panes { position: absolute; inset: 0; display: flex; }
#panes.split-left   { flex-direction: row; }
#panes.split-right  { flex-direction: row-reverse; }
#panes.split-top    { flex-direction: column; }
#panes.split-bottom { flex-direction: column-reverse; }

.pane { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; }
.pane[hidden] { display: none; }
/* thin light divider between the two views (canvas is always dark) */
#panes.is-split .pane + .pane { border-left: 1px solid rgba(255, 252, 241, 0.35); }
#panes.is-split.split-top .pane + .pane,
#panes.is-split.split-bottom .pane + .pane {
  border-left: none; border-top: 1px solid rgba(255, 252, 241, 0.35);
}

.pane canvas { display: block; width: 100%; height: 100%; }
.pane canvas.brush { cursor: crosshair; }
.pane canvas.panning { cursor: grabbing; }

.pane-tag {
  position: absolute; left: 8px; top: 8px;
  border: var(--line);
  background: var(--color-paper);
  color: var(--color-ink);
  font-size: 11px; padding: 1px 6px;
  pointer-events: none;
}
#panes:not(.is-split) .pane-tag { display: none; }

/* --------------------------------------------------------- scrubber ----- */
#scrubber {
  position: absolute;
  left: 50%; bottom: 54px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  border: var(--line);
  background: var(--color-paper);
  padding: 5px 10px;
  min-width: 340px;
  z-index: 6;
}
#scrubber[hidden] { display: none; }
#scrub { flex: 1 1 auto; }
#scrubber .tb-lbl { white-space: nowrap; }

#hud {
  position: absolute;
  left: var(--content-padding);
  bottom: var(--content-padding);
  display: flex;
  align-items: center;
  gap: 8px;
  border: var(--line);
  background: var(--color-paper);
  padding: 4px 8px;
}
#hud .sm { border: none; padding: 0 4px; text-decoration: underline; }
#hud .sm:hover { background: none; color: var(--dim); }
#zoomlbl { font-family: var(--font-mono-regular); font-weight: 400; }
.hud-hint { color: var(--dim); font-size: 12px; }

/* -------------------------------------------------------- drop target --- */
#dropzone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: var(--content-padding);
}
#dropzone[hidden] { display: none; }
#dropzone .dz-box {
  border: 2px dashed var(--color-ink);
  padding: 40px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--color-paper);
}
.dz-title {
  font-family: var(--font-mono-semibold);
  font-weight: 600;
  font-size: 20px;
}
.dz-sub { color: var(--dim); }

/* whole-stage highlight while a file is over the window */
#stage.dragging::after {
  content: "drop to load";
  position: absolute;
  inset: 8px;
  border: 2px dashed var(--color-ink);
  background: color-mix(in srgb, var(--color-paper) 82%, var(--color-ink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono-semibold);
  font-weight: 600;
  font-size: 20px;
  pointer-events: none;
  z-index: 5;
}

/* ----------------------------------------------------------- library ---- */
#library {
  border-top: var(--line);
  height: var(--strip-height);
  flex: 0 0 var(--strip-height);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.library__head {
  border-bottom: var(--line);
  padding: var(--section-padding-block) var(--content-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.library__title {
  font-family: var(--font-mono-regular);
  font-weight: 400;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.library__actions { display: flex; gap: 8px; align-items: center; }
.library__actions button { font-size: 12px; padding: 2px 8px; }

#strip {
  flex: 1 1 auto;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 0;
}

.thumb {
  border: none;
  border-right: var(--line);
  padding: 6px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  background: var(--color-paper);
  position: relative;
}
.thumb:hover { background: var(--faint); }
.thumb.is-active { background: var(--color-ink); }
.thumb.is-active .thumb__num { color: var(--color-white); }

.thumb__num {
  font-family: var(--font-mono-regular);
  font-weight: 400;
  font-size: 11px;
  color: var(--dim);
  writing-mode: vertical-rl;
  align-self: stretch;
  display: flex;
  align-items: center;
}
.thumb img {
  display: block;
  height: 100%;
  max-height: 76px;
  width: auto;
  border: var(--line);
  image-rendering: auto;
}

.strip-empty {
  color: var(--dim);
  padding: var(--content-padding);
  align-self: center;
  font-size: 12px;
}

/* -------------------------------------------------------------- modal --- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 999997;
  background: color-mix(in srgb, var(--color-ink) 55%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--content-padding);
}
.overlay[hidden] { display: none; }

.modal {
  border: var(--line);
  background: var(--color-paper);
  color: var(--color-ink);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal__head {
  border-bottom: var(--line);
  padding: var(--header-padding-block) var(--content-padding);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.modal__title {
  font-family: var(--font-mono-semibold);
  font-weight: 600;
  font-size: 20px;
}
.modal__body {
  padding: var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal__body p { line-height: 18px; }
.modal__drop {
  border: 2px dashed var(--color-ink);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
}
.modal__drop:hover { background: var(--faint); }
.modal__drop.is-over { background: var(--faint-strong); }
.modal__foot {
  border-top: var(--line);
  padding: var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.link-btn { border: none; text-decoration: underline; padding: 0; }
.link-btn:hover { background: none; color: var(--dim); }

.modal__body .row { gap: 4px; }
.modal__body input[type=text] { width: 100%; }
.modal__body a { color: var(--color-ink); text-decoration: underline; }
.gifbar-wrap { height: 4px; border: var(--line); margin-top: 4px; }
#gifbar { height: 100%; width: 0; background: var(--color-red); }

/* keyboard-shortcuts editor */
#keyslist { display: flex; flex-direction: column; }
.key-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 5px 0; border-bottom: var(--line);
}
.key-row .key-label { color: var(--color-ink); }
.key-cap {
  border: var(--line); background: var(--color-paper);
  padding: 2px 10px; min-width: 74px; text-align: center;
  font-family: var(--font-mono-regular); cursor: pointer;
}
.key-cap:hover { background: var(--faint); }
.key-cap.listening { background: var(--color-red); color: var(--color-red-ink); }

/* --------------------------------------------------------- scrollbars --- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--color-paper); }
::-webkit-scrollbar-thumb { background: var(--faint-strong); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
