:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --edge: #2b303b;
  --text: #d6dae2;
  --dim: #8a919e;
  --accent: #66d9a5;
  --error: #f07178;
  --warn: #e5c07b;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* links must read on the dark theme — the browser default (dark blue,
   purple when visited) vanishes against --bg */
a { color: #7cb3ff; }
a:visited { color: #9d8cff; }
a:hover { color: #a8ccf5; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--edge);
  flex-wrap: wrap;
}

header h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 10px 0 0;
  color: var(--accent);
  letter-spacing: 0.06em;
}

button, select {
  background: #262b35;
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }

#play.playing { background: var(--accent); color: #10231a; font-weight: 600; }

label.toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}

/* which document is open, and whether it has unsaved changes */
#doc-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  min-width: 0;
}

#doc-title {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
}

/* the dirty dot is part of the text, so colour carries the whole label */
#doc-title.dirty { color: var(--accent); font-weight: 600; }

/* --dim rather than --edge, which is a border colour and unreadable as text */
#doc-note {
  color: var(--dim);
  white-space: nowrap;
  font-size: 11px;
}

/* a hairline between document identity and the transport */
.sep {
  align-self: stretch;
  width: 1px;
  background: var(--edge);
  margin: -2px 2px;
}

#status {
  margin-left: auto;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}

#viz {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 14px;
  background: #171a20;
  border-bottom: 1px solid var(--edge);
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--dim);
}

#pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

#position { min-width: 110px; }
#section { min-width: 140px; color: var(--text); }

#lamps { display: flex; gap: 8px; flex-wrap: wrap; }

.lamp {
  padding: 2px 9px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: #20242d;
  color: var(--dim);
  transition: none;
  font: 11px ui-monospace, Menlo, monospace;
  white-space: nowrap;
}

.lamp .note {
  color: var(--accent);
  margin-left: 6px;
  display: inline-block;
  min-width: 4ch;   /* widest note name ("C#-1") — pills keep a fixed size */
  text-align: left;
}

.cm-active-phrase { background: rgba(102, 217, 165, 0.07); }
.cm-active-phrase.cm-activeLine { background: rgba(102, 217, 165, 0.12); }

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#editor {
  flex: 1;
  min-width: 0;
  overflow: auto;
}

#editor .cm-editor { height: 100%; font-size: 13px; }
#editor .cm-editor.cm-focused { outline: none; }

#messages {
  height: 84px;
  overflow-y: auto;
  padding: 6px 14px;
  background: var(--panel);
  border-top: 1px solid var(--edge);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}

#messages .error { color: var(--error); }
#messages .warning { color: var(--warn); }
#messages .info { color: var(--dim); }

input[type="file"] { display: none; }

/* --- executing-source highlight (exec-viz over CodeMirror) ------------------ */
.cm-exec {                       /* sounding note token */
  background: #2a4a35;
  color: #a5f0c8;
  outline: 1px solid #66d9a5;
  border-radius: 2px;
}
.cm-exec-v {                     /* active value-pattern token */
  background: #22344d;
  color: #a8ccf5;
  outline: 1px solid #4d80c0;
  border-radius: 2px;
}
.cm-exec-h {                     /* active harmony: phrase name, chord */
  background: #4d3d1e;
  color: #f0d9a0;
  outline: 1px solid #c9a34d;
  border-radius: 2px;
}
.cm-exec-ann {                   /* live mod readout at line end */
  color: #6f7885;
  font-style: italic;
}
