/* ReadFlow — matches the sadapanna app look (see geoflow/styles.css) */

@font-face {
  font-family: "Poppins";
  src: url("fonts/Poppins-SemiBold.ttf") format("truetype");
  /* only one weight is bundled — declare it as 400 so the browser synthesises
     bold for the per-beat "bold text" option instead of matching this face */
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Pacifico";
  src: url("fonts/Pacifico-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --bg: #fafafa;
  --ink: #1c1c28;
  --muted: #8a8a99;
  --panel: #ffffff;
  --line: #e4e4ee;
  --accent: #4f46e5;
  --accent-soft: #eef;
  --shadow: 0 4px 24px rgba(20, 20, 40, .10);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

#app { display: flex; height: 100%; }

/* ---------- left panel ---------- */

#panel {
  width: 340px; flex-shrink: 0; height: 100%;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}

#brand { padding: 16px 18px 8px; }
#brand h1 { font-size: 20px; letter-spacing: -.4px; }
#brand h1::after { content: "·"; color: var(--accent); margin-left: 3px; }
#brand .tagline { font-size: 12px; color: var(--muted); }

/* ---------- numbered stepper ---------- */

#stepper {
  display: flex; gap: 0; padding: 10px 12px 12px;
  border-bottom: 1px solid var(--line);
}
#stepper button {
  flex: 1; border: none; background: transparent; cursor: pointer;
  font: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 2px 6px; border-radius: 10px; position: relative;
}
#stepper button .st-num {
  width: 24px; height: 24px; border-radius: 999px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--bg); color: var(--muted); border: 1.5px solid var(--line);
}
#stepper button .st-lbl { font-size: 11px; font-weight: 600; color: var(--muted); }
/* connector line between the circles */
#stepper button:not(:first-child)::before {
  content: ""; position: absolute; top: 16px; right: calc(50% + 15px); left: calc(-50% + 15px);
  height: 2px; background: var(--line);
}
#stepper button.done .st-num { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
#stepper button.done:not(:first-child)::before,
#stepper button.active:not(:first-child)::before { background: var(--accent); }
#stepper button.active .st-num { background: var(--accent); color: #fff; border-color: var(--accent); }
#stepper button.active .st-lbl { color: var(--accent); }
#stepper button:hover .st-lbl { color: var(--accent); }

.step { flex: 1; overflow-y: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 14px; }

.step-hint {
  font-size: 12.5px; line-height: 1.5; color: var(--ink);
  background: var(--accent-soft); border-radius: 10px; padding: 9px 11px;
}
.step-hint b { color: var(--accent); }

.step-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line);
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.field > span { font-weight: 600; }
.field > span b { color: var(--ink); }
.field output { color: var(--accent); font-weight: 700; }

textarea, input[type="text"], input[type="number"], select {
  font: inherit; font-size: 13.5px; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 9px;
  background: var(--bg); padding: 8px 10px; outline: none; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; min-height: 90px; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 42px; height: 30px; padding: 2px; border: 1.5px solid var(--line);
  border-radius: 8px; background: var(--bg); cursor: pointer;
}
.colorwrap { display: flex; align-items: center; gap: 6px; }

/* ---------- font picker ---------- */

#font-picker { position: relative; }
#font-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font: inherit; font-size: 13.5px; color: var(--ink); text-align: left;
  border: 1.5px solid var(--line); border-radius: 9px;
  background: var(--bg); padding: 8px 10px;
}
#font-trigger:hover, #font-trigger[aria-expanded="true"] { border-color: var(--accent); }
#font-current { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#font-trigger .fp-caret { color: var(--muted); font-size: 11px; }
#font-picker.loading #font-trigger { color: var(--muted); }
#font-picker.loading #font-trigger::after {
  content: "loading font…"; font-size: 11px; font-weight: 700; color: var(--accent);
}

#font-menu {
  margin-top: 6px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--panel); box-shadow: var(--shadow); padding: 8px; overflow: hidden;
}
#font-search { margin-bottom: 6px; }
#font-list { max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
#font-list .fp-group {
  font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted); padding: 8px 6px 3px;
}
#font-list button {
  border: none; background: transparent; text-align: left; width: 100%;
  font: inherit; font-size: 13px; color: var(--ink);
  padding: 5px 8px; border-radius: 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#font-list button:hover { background: var(--accent-soft); color: var(--accent); }
#font-list button.active { background: var(--accent); color: #fff; font-weight: 600; }
#font-list button .fp-cat { float: right; font-size: 10px; opacity: .6; font-weight: 400; }
.fp-empty { font-size: 12px; color: var(--muted); padding: 10px 6px; text-align: center; }
.fp-note {
  font-size: 11.5px; line-height: 1.4; color: #9a5b00;
  background: #fff6e5; border: 1px solid #f2dcae; border-radius: 8px; padding: 6px 8px;
}

.row2 { display: flex; gap: 10px; align-items: flex-end; }
.row2 > * { flex: 1; min-width: 0; }
.row3 { display: flex; gap: 8px; }
.row3 > * { flex: 1; min-width: 0; }

button { font: inherit; cursor: pointer; }
button.primary {
  border: none; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 13.5px; padding: 9px 16px; border-radius: 9px;
}
button.primary:disabled { opacity: .4; cursor: default; }
button.primary:not(:disabled):active { transform: scale(.97); }
button.ghost {
  border: none; background: var(--accent-soft); color: var(--accent);
  font-weight: 600; font-size: 13px; padding: 8px 12px; border-radius: 9px;
}
button.ghost:hover { background: var(--accent); color: #fff; }
button.ghost.armed { background: var(--accent); color: #fff; }
button.mini {
  border: none; background: var(--bg); color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 7px;
}
button.mini:hover { background: var(--accent-soft); color: var(--accent); }

.tip { font-size: 12px; color: var(--muted); line-height: 1.5; }
.tip b { color: var(--ink); }
.dim { color: var(--muted); font-weight: 400; }
.empty-note { color: var(--muted); font-size: 12.5px; text-align: center; padding: 16px 6px; }

details.group { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
details.group summary {
  cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--ink);
  padding: 10px 0; list-style: none; user-select: none;
}
details.group summary::before { content: "▸ "; color: var(--accent); }
details.group[open] summary::before { content: "▾ "; }
details.group > *:not(summary) { margin-bottom: 12px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- theme grid ---------- */

#theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#theme-grid button {
  border: 2px solid var(--line); border-radius: 10px; background: var(--bg);
  padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 9.5px; font-weight: 600; color: var(--muted);
}
#theme-grid button .sw { width: 100%; height: 26px; border-radius: 6px; border: 1px solid var(--line); }
#theme-grid button.active { border-color: var(--accent); color: var(--accent); }

/* ---------- beats ---------- */

#selection-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px;
}
#selection-info { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#selection-info.has { color: var(--ink); font-style: italic; }

#beat-list { display: flex; flex-direction: column; gap: 6px; }
.beat-item {
  border: 1px solid var(--line); border-radius: 11px; background: var(--panel);
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.beat-item.open { border-color: var(--accent); }
.beat-item.dragging { opacity: .4; }
.beat-item.dropover { border-color: var(--accent); }
.beat-head { display: flex; align-items: center; gap: 7px; padding: 8px 10px; cursor: pointer; }
.beat-head:hover { background: var(--accent-soft); }
.beat-head .bi-meta { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.beat-head .bi-caret { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.beat-editor {
  display: flex; flex-direction: column; gap: 9px;
  padding: 9px 10px 10px; border-top: 1px dashed var(--line);
}
.empty-beats {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1.5px dashed var(--line); border-radius: 11px; padding: 12px;
  font-size: 12.5px; color: var(--muted); line-height: 1.55;
}
.empty-beats .eb-icon { font-size: 20px; line-height: 1.2; }
.empty-beats b { color: var(--ink); }
details.sub { border-top: 1px dashed var(--line); padding-top: 8px; }
details.sub summary {
  cursor: pointer; font-size: 11.5px; font-weight: 700; color: var(--muted);
  list-style: none; user-select: none;
}
details.sub summary::before { content: "▸ "; color: var(--accent); }
details.sub[open] summary::before { content: "▾ "; }
details.sub > *:not(summary) { margin-top: 8px; }
.beat-head .bi-grip { cursor: grab; color: var(--muted); font-size: 12px; }
.beat-head .bi-num {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center;
}
.beat-head .bi-text {
  flex: 1; min-width: 0; font-size: 12.5px; font-style: italic; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.beat-head .bi-del {
  border: none; background: transparent; color: var(--muted); font-size: 13px;
  padding: 3px 6px; border-radius: 6px;
}
.beat-head .bi-del:hover { color: #b91c1c; background: #fee2e2; }
.beat-row { display: flex; gap: 5px; align-items: center; }
.beat-row select { font-size: 12px; padding: 4px 6px; flex: 1; }
.beat-row input[type="color"] { width: 30px; height: 26px; flex-shrink: 0; }
.beat-row .bt {
  width: 100%; font-size: 12px; padding: 4px 5px; text-align: center;
}
.beat-row .lbl { font-size: 10px; color: var(--muted); font-weight: 700; }
.beat-more summary { font-size: 11px; color: var(--muted); cursor: pointer; list-style: none; }
.beat-more summary::before { content: "⋯ "; }
.beat-more[open] summary::before { content: "▾ "; }
.beat-more .beat-row { margin-top: 6px; }
.beat-row input[type="range"] { flex: 1; }

#tapsync-status {
  background: var(--accent); color: #fff; border-radius: 9px; padding: 8px 10px;
  font-size: 12.5px; font-weight: 600; text-align: center;
}

/* ---------- overlays ---------- */

#overlay-add-row { display: flex; flex-wrap: wrap; gap: 5px; }
#overlay-add-row button { font-size: 12px; padding: 6px 9px; }
#overlay-place-hint { font-size: 12px; color: var(--accent); font-weight: 600; }
#overlay-list { display: flex; flex-direction: column; gap: 6px; }
.ov-item {
  border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.ov-head { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.ov-head .ov-del { border: none; background: transparent; color: var(--muted); margin-left: auto; padding: 3px 6px; border-radius: 6px; }
.ov-head .ov-del:hover { color: #b91c1c; background: #fee2e2; }
.ov-row { display: flex; gap: 5px; align-items: center; font-size: 11px; color: var(--muted); }
.ov-row select, .ov-row input { font-size: 12px; padding: 4px 6px; }
.ov-row input[type="color"] { width: 30px; height: 26px; padding: 1px; }
.ov-row input[type="range"] { flex: 1; }

/* ---------- export ---------- */

#frame-presets { display: flex; gap: 6px; }
#frame-presets button {
  flex: 1; border: 2px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 8px 4px; font-size: 13px; font-weight: 700; color: var(--muted);
  display: flex; flex-direction: column; gap: 1px; align-items: center;
}
#frame-presets button small { font-size: 9.5px; font-weight: 500; }
#frame-presets button.active { border-color: var(--accent); color: var(--accent); }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btn-grid button {
  border: none; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 13.5px; padding: 10px 4px; border-radius: 9px;
}
.btn-grid button:hover { background: var(--accent); color: #fff; }
.btn-grid button.primary { background: var(--accent); color: #fff; }
/* exporter.js writes plain text here and toggles [hidden] */
#export-progress {
  margin-top: 8px; padding: 7px 9px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; font-weight: 600; line-height: 1.35;
}
#export-progress[hidden] { display: none; }

#project-list { display: flex; flex-direction: column; gap: 3px; max-height: 180px; overflow-y: auto; }
.project-row { display: flex; align-items: center; gap: 4px; }
.project-open {
  display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0;
  padding: 7px 8px; border: none; background: transparent; border-radius: 9px;
  cursor: pointer; font: inherit; font-size: 13px; text-align: left; color: var(--ink);
}
.project-open b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-open small { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.project-row:hover .project-open { background: var(--accent-soft); }
.project-delete {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 13px; padding: 6px 7px; border-radius: 8px; line-height: 1;
}
.project-delete:hover { background: rgba(232, 68, 58, 0.12); color: #e8443a; }

#project-status { color: var(--muted); font-size: 11.5px; padding: 4px 2px 0; min-height: 0; }
#project-status:empty { display: none; }

/* ---------- stage ---------- */

#stage {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; gap: 0;
  background: var(--bg);
}
#canvas-holder {
  flex: 1; min-height: 0; display: grid; place-items: center; padding: 22px;
}
#preview {
  max-width: 100%; max-height: 100%;
  border-radius: 10px; box-shadow: var(--shadow);
  background: #fff; cursor: text; touch-action: none;
}
#preview.placing { cursor: crosshair; }

#transport {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px 14px;
}
.chip {
  border: none; background: var(--panel); color: var(--ink);
  box-shadow: var(--shadow);
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  font-size: 17px; cursor: pointer; display: grid; place-items: center;
}
.chip:active { transform: scale(.95); }
.chip svg { width: 20px; height: 20px; }
#scrubber { flex: 1; accent-color: var(--accent); }
#time-readout { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  #app { flex-direction: column; }
  #panel { width: 100%; height: 46%; border-right: none; border-top: 1px solid var(--line); order: 2; }
  #stage { order: 1; height: 54%; }
  #canvas-holder { padding: 10px; }
}
