/* Font Builder Studio - editor UI.
 *
 * Builds on the shared design tokens in theme.css (same visual language as
 * Cross Canvas Art Studio: dark surfaces, purple brand, 10px radii).
 */

/* ---------- Layout ---------- */
/* The app is a fixed-height shell: the page itself never scrolls, only the
   sidebar does. That keeps the canvas exactly as tall as the viewport. */
html,
body {
  height: 100%;
  overflow: hidden;
}

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 324px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

/* ---------- Data-loss warning (static build only) ---------- */
/* Static builds have no storage, so the banner is the one place that says a
   refresh is destructive. `[hidden]` needs restating because the flex display
   below would otherwise override the browser's built-in hidden rule. */
.data-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 10px 0;
  padding: 9px 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12.5px;
}

.data-warning[hidden] {
  display: none;
}

.data-warning-icon {
  flex: 0 0 auto;
  color: var(--warn);
  font-size: 15px;
  line-height: 1;
}

.data-warning p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.data-warning strong {
  color: var(--warn);
}

.data-warning .btn-ghost {
  flex: 0 0 auto;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.sidebar::-webkit-scrollbar {
  width: 9px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 5px;
}

.canvas-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 0;
  overflow: hidden;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  flex: 0 0 auto;
}

/* Collapsible panels are <details> elements: native toggling, no JS, and
   keyboard accessible. */
.panel > .panel-head {
  cursor: pointer;
  user-select: none;
  list-style: none;
  margin-bottom: 0;
}

.panel > .panel-head::-webkit-details-marker {
  display: none;
}

.panel > .panel-head::marker {
  content: "";
}

.panel[open] > .panel-head {
  margin-bottom: 8px;
}

.panel-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.panel-title::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}

.panel[open] .panel-title::before {
  transform: rotate(90deg);
}

.panel > .panel-head:hover .panel-title {
  color: var(--text);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Section divider + sub-heading used inside the Glyph panel. */
.panel-sep {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.panel-subhead {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* ---------- Readout grid ---------- */
/* A row of three labelled values. Used for the interpreted code point and for
   the spacing breakdown, so the numbers behind both fields are visible. */
.readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.u-cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 4px 3px 4px 8px;
}

.u-line {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 26px;
}

.u-char {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1.1;
  overflow: hidden;
}

.u-char.empty {
  color: var(--text-faint);
  font-size: 13px;
}

.u-value {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}

/* A negative right sidebearing means this glyph's ink runs into the next one. */
.u-value.warn {
  color: var(--warn);
}

.u-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
}

/* Deliberately quiet until hovered: six arrows in a narrow sidebar would
   otherwise compete with the values they adjust. */
.u-keys {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.u-step {
  width: 19px;
  height: 12px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  line-height: 1;
  background: var(--bg-2);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  border-radius: 3px;
  opacity: 0.75;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s;
}

.u-step:hover:not(:disabled),
.u-step:focus-visible {
  opacity: 1;
  color: #fff;
  border-color: var(--brand);
}

.readout:hover .u-step {
  opacity: 0.95;
}

.u-step:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ---------- Input with a trailing action button ---------- */
.input-group {
  display: flex;
  gap: 6px;
  align-items: stretch;
  margin-top: 4px;
}

.input-group input {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

.btn-icon {
  flex: 0 0 auto;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  transition: color 0.15s, border-color 0.15s;
}

.btn-icon:hover:not(:disabled) {
  color: #fff;
  border-color: var(--brand);
}

.btn-icon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Character picker ---------- */
.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 12, 17, 0.7);
}

.picker-backdrop[hidden] {
  display: none;
}

.picker {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 780px;
  height: min(82vh, 660px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.picker-head h2 {
  font-size: 14px;
  white-space: nowrap;
  margin: 0;
}

.picker-head input {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

.picker-close {
  flex: 0 0 auto;
  padding: 6px 10px;
}

.picker-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
}

.picker-blocks {
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 8px;
}

.picker-block {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.25;
}

.picker-block:hover {
  background: var(--bg-3);
  color: var(--text);
}

.picker-block.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: #fff;
}

.picker-block small {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
}

.picker-block.active small {
  color: var(--text-dim);
}

/* "In this font" is a section rather than a Unicode block, so it is pinned above
   the list and set apart from it. */
.picker-block.pinned {
  background: var(--bg-3);
  border-color: var(--border-2);
  border-left: 3px solid var(--brand);
  color: var(--text);
  margin-bottom: 8px;
}

.picker-block.pinned.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  border-left-color: var(--brand);
}

.picker-chars {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.picker-status {
  margin: 0;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}

.picker-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 4px;
  padding: 10px;
  align-content: start;
}

.picker-cell {
  position: relative;
  height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  overflow: hidden;
}

.picker-cell span {
  font-size: 19px;
  line-height: 1.1;
}

.picker-cell small {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-faint);
}

/* Thumbnail of the font's own outline. The size here must match THUMB_SIZE in
   char-picker.js; the module handles the device pixel ratio. */
.picker-thumb {
  width: 34px;
  height: 30px;
  display: block;
  margin: 0 auto;
  /* The fill colour comes from here, since canvas cannot use currentColor. */
  color: var(--text);
}

/* Outlines need more room than a line of text. */
.picker-grid.in-font-view .picker-cell {
  height: 56px;
}

.picker-cell:hover {
  border-color: var(--brand);
}

.picker-cell.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

/* Already in the font: picking it again would just duplicate the code point. */
.picker-cell.in-font {
  opacity: 0.45;
}

.picker-cell.in-font::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ok);
}

/* Previewing the font's own repertoire: every cell is in-font by definition, so
   the dimming and the dot would be noise spread over the whole grid. */
.picker-grid.in-font-view .picker-cell.in-font {
  opacity: 1;
}

.picker-grid.in-font-view .picker-cell.in-font::after {
  display: none;
}

.picker-empty {
  grid-column: 1 / -1;
  padding: 24px 8px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.picker-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.picker-detail {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
}

.picker-detail b {
  color: var(--text);
  font-family: var(--mono);
}

.picker-detail .pd-char {
  font-size: 18px;
  font-family: var(--font);
  vertical-align: -2px;
  margin-right: 6px;
}

.hint.warn {
  color: var(--warn);
}

/* Point insertion has no button, so the toolbar says so out loud. */
.canvas-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.panel-head h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin: 0;
}

.hint {
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------- Form controls ---------- */
label {
  font-size: 12px;
  color: var(--text-dim);
}

input[type="number"],
input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
  margin-top: 4px;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 6px;
}

.field-row label {
  flex: 1;
  min-width: 0;
}

/* ---------- Buttons ---------- */
.btn-primary,
.btn-secondary,
.btn-ghost {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}

.btn-primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-2);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--brand);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-2);
}

.btn-ghost:hover:not(:disabled) {
  color: #fff;
  border-color: var(--brand);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.full {
  width: 100%;
  margin-top: 8px;
}

/* ---------- Drop zone ---------- */
.drop-zone {
  position: relative;
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  color: var(--text-dim);
  background: var(--bg-2);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.drop-icon {
  font-size: 24px;
  display: block;
  margin-bottom: 4px;
}

.drop-zone p {
  margin: 0;
  font-size: 12px;
}

/* ---------- Canvas toolbar ---------- */
.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tool-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.tool {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
}

.tool:hover {
  color: #fff;
  border-color: var(--brand);
}

.tool.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.zoom-readout {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  min-width: 52px;
  text-align: right;
}

/* ---------- Canvas ---------- */
.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0b0d13;
}

#glyphCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#glyphCanvas.panning {
  cursor: grabbing;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 13px;
  pointer-events: none;
  text-align: center;
  padding: 20px;
}

/* An author-level `display: flex` beats the UA stylesheet's [hidden] rule, so
   the attribute has to be honoured explicitly. */
.canvas-empty[hidden] {
  display: none;
}

.empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 460px;
}

.empty-title {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
}

.empty-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-faint);
}

.empty-note[hidden] {
  display: none;
}

/* The overlay ignores pointer events so it can never block the canvas, but the
   buttons inside it have to stay clickable. */
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  pointer-events: auto;
}

.empty-actions button[hidden] {
  display: none;
}

.empty-actions button {
  margin-top: 0;
}

/* ---------- Status bar ---------- */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
  padding: 0 2px;
}

.status-bar strong {
  color: var(--text-dim);
  font-weight: 600;
}

/* ---------- App footer ---------- */
.app-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  font-size: 12px;
  color: var(--text-faint);
}

.footer-note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Font-resource links, sitting between the note and the repo link. Wraps to a
   second line rather than overflowing on a narrow window. */
.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 2px 4px;
  min-width: 0;
}

.footer-links a {
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--text);
  background: var(--brand-soft);
}

/* Logo + repo name, pinned to the right by the footer's space-between. */
.footer-github {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 550;
  white-space: nowrap;
}

.footer-github:hover,
.footer-github:focus-visible {
  color: var(--text);
  background: var(--brand-soft);
}

.footer-logo {
  flex: 0 0 auto;
  display: block;
}

/* ---------- Glyph list ---------- */
.glyph-list {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.glyph-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  width: 100%;
}

.glyph-row:hover {
  background: var(--bg-3);
}

.glyph-row.active {
  background: var(--brand-soft);
  border-color: var(--brand);
}

.glyph-row .gname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glyph-row .gcode {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* An empty slot reads as a hollow ring, a drawn one as a solid dot - shape
   carries the meaning even without colour. */
.glyph-row .gempty {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: transparent;
  box-sizing: border-box;
  flex: 0 0 auto;
}

.glyph-row .gempty.filled {
  background: var(--brand);
  border-color: var(--brand);
}

/* Composite: a ring, because the outline is borrowed rather than its own. */
.glyph-row .gempty.composite:not(.filled) {
  border-color: var(--brand);
  background: transparent;
}

/* Per-row delete: revealed on hover so the list stays uncluttered. */
.glyph-row .gremove {
  color: var(--text-faint);
  font-size: 11px;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}

.glyph-row:hover .gremove,
.glyph-row:focus-within .gremove {
  opacity: 1;
}

.glyph-row .gremove:hover {
  color: var(--danger);
}

/* ---------- Stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.stat-grid b {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Header actions ---------- */
/* theme.css ships the brand styles but not this rule, so the action row needs
   its own flex layout - without it the buttons are block-level and stack. */
.app-header .header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

/* Reciprocal link to the sister tool, Stitchee. Deliberately the same pill the
   Stitchee site uses to link back here - same tokens, same metrics - so the two
   read as one family rather than two unrelated buttons. */
.ext-tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px 4px 5px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.ext-tool:hover,
.ext-tool:focus-visible {
  border-color: var(--brand);
  background: var(--bg-2);
  color: #fff;
}

.ext-tool-logo {
  display: inline-flex;
  filter: drop-shadow(0 2px 6px rgba(124, 58, 237, 0.4));
}

/* ---------- Header dropdown menu (Projects) ---------- */
.menu-wrap {
  position: relative;
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 330px;
  max-height: min(72vh, 580px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  z-index: 55;
  text-align: left;
}

.menu[hidden] {
  display: none;
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.menu .glyph-list {
  max-height: 190px;
}

/* ---------- Auth header + dialog ---------- */
.auth-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 17, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

.modal form {
  display: flex;
  flex-direction: column;
}

.modal .modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  max-width: 380px;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.ok {
  border-left-color: var(--ok);
}

/* ---------- Busy overlay ---------- */
.busy {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 17, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  color: var(--text);
  font-size: 14px;
}

@media (max-width: 900px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(420px, 1fr);
    overflow-y: auto;
  }
  .canvas-area {
    min-height: 420px;
  }
  .sidebar {
    overflow: visible;
  }
}
