:root {
  --bg: #15171c;
  --panel: #1d2027;
  --text: #e6e6e6;
  --muted: #9097a3;
  --accent: #7fb3d5;
  --guide: #23272f;
  --me: #2c3a48;
  --stop: #b5544f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.5 system-ui, "Segoe UI", sans-serif;
  display: flex; flex-direction: column;
}
button {
  font: inherit; color: var(--text); background: #2e333d;
  border: 1px solid #3c424e; border-radius: 6px; padding: 6px 14px; cursor: pointer;
}
button:hover { background: #383e4a; }
button:disabled { opacity: .45; cursor: default; }
button.stop { background: var(--stop); border-color: var(--stop); }

a { color: var(--accent); }

header { display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
#phases { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; flex: 1; }
#phases li { font-size: 13px; color: var(--muted); padding: 2px 8px; border-radius: 10px; border: 1px solid transparent; }
#phases li.done { color: #6c7380; }
#phases li.current { color: var(--text); border-color: var(--accent); }

#stage { flex: 0 0 38vh; display: flex; flex-direction: column; justify-content: center; position: relative; }
#track { position: relative; height: 80px; margin: 0 2vw; }
#dot {
  position: absolute; top: 50%; left: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); transform: translate(-50%, -50%); opacity: .35;
}
body.running #dot { opacity: 1; }
#stageHint { text-align: center; color: var(--muted); font-size: 14px; margin-top: 8px; }
#stageControls { display: flex; justify-content: center; gap: 12px; margin-top: 10px; }

#chatArea {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  max-width: 880px; width: 100%; margin: 0 auto; padding: 0 16px 12px;
  transition: opacity .4s;
}
body.running #chatArea { opacity: .12; pointer-events: none; }
#log { flex: 1; overflow-y: auto; padding: 8px 0; }
.msg { padding: 8px 12px; border-radius: 8px; margin: 6px 0; white-space: pre-wrap; max-width: 85%; }
.msg.guide { background: var(--guide); }
.msg.me { background: var(--me); margin-left: auto; }
.msg.note { color: var(--muted); font-size: 14px; background: none; text-align: center; max-width: 100%; }
.msg.thinking { color: var(--muted); background: none; font-style: italic; }

#rating { background: var(--panel); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.ratingRow { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.ratingRow input { flex: 1; }
#ratingValue { font-size: 22px; min-width: 2ch; text-align: center; }

#composer { display: flex; gap: 8px; }
#msg {
  flex: 1; resize: none; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid #3c424e; border-radius: 6px; padding: 8px 10px;
}

dialog { background: var(--panel); color: var(--text); border: 1px solid #3c424e; border-radius: 10px; width: min(460px, 92vw); }
dialog label { display: block; margin: 10px 0; }
dialog input[type=range] { width: 70%; vertical-align: middle; }
dialog output { margin-left: 8px; }
.note { color: var(--muted); font-size: 13px; }
#setBtn.ready { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
#cue { position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-size: 28px; color: var(--text); pointer-events: none; }
dialog select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid #3c424e; border-radius: 6px; padding: 4px; display: block; margin-top: 4px; max-width: 100%; }
dialog h2 { margin-bottom: 4px; }
/* DBT paced breathing: the circle grows on the in-breath and shrinks on the out-breath */
/* It takes the dot's place in the layout (not on top of the text and buttons): track and hint hide meanwhile. */
#pacer { width: min(140px, 22vh); height: min(140px, 22vh); margin: 36px auto 0; flex: none;
         border-radius: 50%; background: var(--accent); opacity: .35; transform: scale(.4); pointer-events: none; }
body.breathing #track, body.breathing #stageHint { display: none; }
