/* KØNSTAT v0.1.5 — styles. Plain CSS, no framework. */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
  background: #e8edf3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
button:hover { background: #f1f5f9; border-color: #94a3b8; }
button[aria-pressed="true"] { background: #0f172a; color: #fff; border-color: #0f172a; }
button:disabled { opacity: .5; cursor: default; }
input[type="text"], input[type="number"], select {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 6px;
}
input[type="color"] { width: 44px; height: 28px; padding: 1px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; }
input[type="range"] { width: 110px; vertical-align: middle; }
.muted { color: #64748b; }
.small { font-size: 12px; }
.spacer { flex: 1; }
.sep { width: 1px; align-self: stretch; background: #cbd5e1; margin: 0 4px; }

/* Top bar */
#topbar {
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  flex-wrap: wrap;
}
#topbar .brand { font-size: 20px; font-weight: 800; letter-spacing: .04em; }
#topbar .brand-mark { width: 30px; height: 30px; vertical-align: middle; margin-right: 8px; }
#topbar .brand-sub { font-size: 12px; font-weight: 400; color: #94a3b8; letter-spacing: 0; }
#topbar .proj { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
#topbar label { color: #cbd5e1; font-size: 13px; display: flex; align-items: center; gap: 6px; }
#topbar input[type="text"] { background: #1e293b; border-color: #334155; color: #fff; width: 190px; }
#topbar button { background: #1e293b; border-color: #334155; color: #e2e8f0; }
#topbar button:hover { background: #334155; }
/* v0.1.3: the home link — a plain link styled like the other header
   buttons, so it reads as a header control. Same tab, no JavaScript. */
#topbar .home-link {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 5px 10px;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
#topbar .home-link:hover { background: #334155; }
/* v0.1.5: language toggle (EN | FR) in the header. Two small buttons with
   a separator; the active language is filled blue (the emblem colour) so
   it reads at a glance. The #topbar button rule outranks the global
   [aria-pressed] rule, hence the specific selector here. */
#topbar .lang-toggle { display: flex; align-items: center; gap: 2px; }
#topbar .lang-toggle button { padding: 5px 8px; }
#topbar .lang-toggle button[aria-pressed="true"] { background: #2563eb; border-color: #2563eb; color: #fff; }
#topbar .lang-toggle span { color: #64748b; font-size: 12px; }

/* Page tabs + flow controls */
#pagebar, #toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
  flex-wrap: wrap;
}
#pageTabs { display: flex; gap: 4px; flex-wrap: wrap; }
#pageTabs .tab {
  border: 1px solid #cbd5e1;
  border-radius: 6px 6px 0 0;
  background: #e2e8f0;
  padding: 4px 8px;
  display: flex;
  gap: 6px;
  align-items: center;
}
#pageTabs .tab.active { background: #fff; border-bottom-color: #fff; font-weight: 700; }
#pageTabs .tab .x {
  border: none; background: none; padding: 0 2px; color: #64748b;
  font-size: 13px; line-height: 1;
}
#pageTabs .tab .x:hover { color: #b91c1c; }
#pageTabs .tab .rn { border: none; background: none; padding: 0; font-size: 12px; color: #64748b; }
#pageTabs .tab .rn:hover { color: #0f172a; }
.ctl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; }

/* Workspace */
#workspace { flex: 1; display: flex; min-height: 0; }
/* v0.1.2: touch-action pan-y — a vertical pan on the canvas is a page
   scroll (the browser takes it), a horizontal pan reaches the page as
   pointer events (canvas pan / node drag). touch-action: none would
   block page scrolling entirely, which is the mobile scroll lock. */
#canvas { flex: 1; min-width: 0; display: block; background: #e8edf3; cursor: grab; outline: none; touch-action: pan-y; }
#canvas:active { cursor: grabbing; }
#props {
  width: 264px;
  flex: none;
  background: #fff;
  border-left: 1px solid #cbd5e1;
  padding: 12px 14px;
  overflow-y: auto;
}
#props h2 { margin: 0 0 10px; font-size: 15px; }
#props .field { display: block; margin-bottom: 10px; font-size: 13px; color: #334155; }
#props .field input[type="text"], #props .field select { width: 100%; margin-top: 3px; }
#props .row { display: flex; gap: 10px; }
#props .row .field { flex: 1; }
#props .check { display: flex; align-items: center; gap: 6px; }
#props hr { border: none; border-top: 1px solid #e2e8f0; margin: 14px 0; }

/* Status bar */
#statusbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 5px 12px;
  background: #f8fafc;
  border-top: 1px solid #cbd5e1;
  font-size: 12px;
  color: #64748b;
}
/* v0.1.3: the mode badge — always visible, so the active tool is clear
   at a glance on touch as well as mouse (no cursor on touch). Orange in
   Connect mode, matching the orange connect-source outline on the canvas. */
#modeText { font-weight: 700; color: #334155; }
#modeText.connect { color: #ea580c; }

/* v0.1.6: gallery overlay — a presentation device. Full-screen, dark
   backdrop, stage canvas in the middle, controls + page strip below.
   In-memory only: nothing here downloads or stores anything. */
#galleryOverlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 23, 42, 0.96);
  color: #e2e8f0;
  display: flex; flex-direction: column;
}
#galleryOverlay[hidden] { display: none; }
.gallery-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.gallery-title { font-size: 16px; font-weight: 800; }
#galleryOverlay .muted { color: #94a3b8; }
#galleryOverlay button { background: #1e293b; border-color: #334155; color: #e2e8f0; }
#galleryOverlay button:hover { background: #334155; }
#galleryOverlay button[aria-pressed="true"] { background: #2563eb; border-color: #2563eb; color: #fff; }
.gallery-stage { flex: 1; min-height: 0; display: flex; }
#galleryCanvas { flex: 1; min-width: 0; display: block; touch-action: pan-y; outline: none; }
.gallery-controls { display: flex; align-items: center; gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
.gallery-controls .ctl { color: #cbd5e1; }
.gallery-controls input[type="number"] { width: 64px; background: #1e293b; border-color: #334155; color: #fff; }
.gallery-strip { display: flex; gap: 8px; padding: 0 14px 12px; overflow-x: auto; }
.gallery-strip .g-item {
  flex: none; display: flex; align-items: center; gap: 6px;
  background: #1e293b; border: 1px solid #334155; border-radius: 6px; padding: 5px 8px;
}
.gallery-strip .g-item.active { border-color: #2563eb; box-shadow: 0 0 0 1px #2563eb; }
.gallery-strip .g-item .g-name {
  background: none; border: none; color: #e2e8f0; padding: 2px 4px;
  font-weight: 700; max-width: 140px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.gallery-strip .g-item .g-name:hover { background: #334155; }
.gallery-strip .g-item .g-secs { width: 52px; background: #0f172a; border-color: #334155; color: #e2e8f0; padding: 3px 5px; }
.gallery-strip .g-item .g-secs.inherited { opacity: .55; }
.gallery-strip .g-item .g-move { padding: 2px 6px; }

@media (max-width: 760px) {
  /* v0.1.2: the page must scroll normally on mobile. The old layout was a
     fixed 100%-height flex column with body overflow:hidden, so on a phone
     the wrapped toolbars squeezed the workspace and the props panel sat
     clipped below the fold with no way to reach it — every finger drag felt
     like a scroll lock. In flow layout the document grows past the viewport
     and the browser scrolls it; the canvas keeps a fixed viewport height
     and the props panel flows below it instead of being clipped at 40vh. */
  body { height: auto; overflow: visible; }
  #workspace { flex: none; flex-direction: column; }
  #canvas { flex: none; height: 60vh; min-height: 320px; }
  #props { width: auto; border-left: none; border-top: 1px solid #cbd5e1; max-height: none; overflow-y: visible; }
}

/* Choice modal (v0.1.1: replace confirmation, export-budget offer) */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; color: #0f172a;
  border-radius: 10px; padding: 18px 20px;
  max-width: 440px; width: calc(100vw - 48px);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.35);
}
.modal h2 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 0 0 14px; font-size: 14px; color: #334155; }
.modal-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
