:root {
  --bg: #0f1218;
  --surface: #171b23;
  --surface-2: #1f2430;
  --border: #2b3140;
  --text: #e6e9ef;
  --muted: #8b93a7;
  --accent: #6c8cff;
  --green: #3ecf8e;
  --red: #ff6b6b;
  --amber: #f5b14c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { font-family: ui-monospace, Consolas, monospace; resize: vertical; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 7px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.ghost { background: transparent; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button.small { padding: 4px 9px; font-size: 12px; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand img { width: 22px; height: 22px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { background: none; border: none; color: var(--muted); padding: 8px 14px; }
.tabs button.active { color: var(--text); background: var(--surface-2); }

main { max-width: 1400px; margin: 0 auto; padding: 24px; }
#tab-todos, #tab-followups { max-width: 1100px; margin: 0 auto; }

.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
@media (max-width: 1100px) { .dash-layout { grid-template-columns: 1fr; } }
.dash-main { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.dash-side { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1100px) { .dash-side { position: static; } }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.block-head h3 { margin: 0; }
.week-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.week-head { display: flex; align-items: center; gap: 8px; }
.week-head h3 { margin: 0; }
.metric-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-height: 104px; text-align: left; }
.metric-tile:hover { border-color: var(--accent); }
.metric-tile .m-name { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.metric-tile .m-value { font-size: 34px; font-weight: 700; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-tile .m-value.text { font-size: 20px; padding-top: 6px; }
.metric-tile .m-value.m-empty { color: var(--muted); }
.metric-tile .m-value small { font-size: 18px; color: var(--muted); font-weight: 600; }
.metric-tile .m-prev { color: var(--muted); font-size: 11px; margin-top: auto; }
.metric-tile .m-bar { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.metric-tile .m-bar span { display: block; height: 100%; background: var(--green); }
.metric-empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; border: 1px dashed var(--border); border-radius: 12px; cursor: pointer; }
.goal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.goal-list li { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.goal-list li .text { flex: 1; }
.goal-list li.done .text { text-decoration: line-through; color: var(--muted); }
.goal-list li .check { border: none; background: none; color: var(--green); font-size: 18px; font-weight: 700; padding: 0 2px; opacity: .6; }
.goal-list li .check:hover, .goal-list li.done .check { opacity: 1; }
.goal-list li .del { visibility: hidden; border: none; background: none; color: var(--muted); padding: 0 4px; }
.goal-list li:hover .del { visibility: visible; }
.week-panel .inline-form { margin: 0; }
.ratio-inputs { display: flex; align-items: center; gap: 8px; }
.ratio-inputs span { color: var(--muted); font-size: 20px; }
.metrics-config-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.metrics-config-list li { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.metrics-config-list li .m-info { flex: 1; }
.metrics-config-list li code { color: var(--muted); font-size: 12px; }
.metric-form { display: flex; gap: 8px; flex-direction: row; }
.metric-form select { width: auto; }
.tab { display: none; }
.tab.active { display: block; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
h2 { margin: 0; }
h3 { margin: 28px 0 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; }
.card .title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.card code { display: block; background: var(--bg); padding: 4px 6px; border-radius: 6px; font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 56px; overflow: auto; }
.card .meta { color: var(--muted); font-size: 11.5px; display: flex; flex-wrap: wrap; gap: 2px 12px; }
.card .btns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto; }
.card .btns button { padding: 2px 8px; font-size: 11.5px; border-radius: 6px; }
.card.overdue { border-color: var(--red); }
.card.due-today { border-color: var(--amber); }
.card.done { opacity: .55; }
.card .resolution { white-space: pre-wrap; border-left: 3px solid var(--green); padding-left: 8px; }
.todo-history .cards { margin-top: 4px; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); grid-column: 1 / -1; }

.status { font-size: 11px; font-weight: 600; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.status.running { color: var(--accent); }
.status.success { color: var(--green); }
.status.failed, .status.timeout { color: var(--red); }
.status.cancelled { color: var(--amber); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }

table.runs { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.runs th, table.runs td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
table.runs th { color: var(--muted); font-weight: 500; font-size: 12px; }
.runs-more-wrap { display: flex; justify-content: center; margin-top: 10px; }

.inline-form { display: flex; gap: 8px; margin-bottom: 16px; }
.todo-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.todo-list li { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.todo-list li .check { flex: none; border: none; background: none; color: var(--green); font-size: 20px; font-weight: 700; line-height: 1; padding: 0 4px; cursor: pointer; opacity: 0.6; }
.todo-list li .check:hover { opacity: 1; }
.todo-list li.done .check { opacity: 1; }
.todo-list li.done .check:hover { opacity: 0.6; }
.todo-list li .text { flex: 1; cursor: text; }
.todo-list li.done .text { text-decoration: line-through; color: var(--muted); }
.todo-list li .del { visibility: hidden; border: none; background: none; color: var(--muted); }
.todo-list li:hover .del { visibility: visible; }
.todo-list li .progress { flex: none; border: none; background: none; color: var(--muted); font-size: 13px; line-height: 1; padding: 0 4px; opacity: 0.5; }
.todo-list li .progress:hover { opacity: 1; color: var(--amber); }
.todo-list li.in-progress { background: rgba(245, 177, 76, 0.07); border-color: var(--amber); box-shadow: inset 3px 0 0 var(--amber); }
.todo-list li.in-progress .progress { color: var(--amber); opacity: 1; }
.todo-list li .pause { flex: none; border: none; background: none; color: var(--muted); font-size: 13px; line-height: 1; padding: 0 4px; opacity: 0.5; }
.todo-list li .pause:hover { opacity: 1; color: var(--accent); }
.todo-list li.paused { flex-wrap: wrap; background: rgba(108, 140, 255, 0.07); border: 1px dashed var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.todo-list li.paused .pause { color: var(--accent); opacity: 1; }
.todo-list li.paused .text { color: var(--muted); }
/* Reason goes on its own line under the title (order puts it after the buttons) */
.todo-list li .pause-reason { order: 10; flex-basis: 100%; padding-left: 24px; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; }
.todo-list li .pause-reason:hover { text-decoration: underline; }
.todo-list li .notes-btn { flex: none; border: none; background: none; font-size: 13px; line-height: 1; padding: 0 4px; opacity: 0.3; filter: grayscale(1); }
.todo-list li .notes-btn:hover { opacity: 1; filter: none; }
.todo-list li .notes-btn.has-notes { opacity: 1; filter: none; }
.todo-list li .today-btn { flex: none; border: none; background: none; font-size: 14px; line-height: 1; padding: 0 4px; opacity: 0.35; filter: grayscale(1); }
.todo-list li .today-btn:hover { opacity: 1; filter: none; }
.todo-list li .today-btn.on { opacity: 1; filter: none; }
.todo-today { margin: 4px 0 18px; padding: 10px 12px; border: 1px solid rgba(245, 177, 76, 0.45); border-radius: var(--radius); background: rgba(245, 177, 76, 0.04); }
.todo-today-head { font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.todo-today .todo-list li.todo-today-empty { color: var(--muted); justify-content: center; border-style: dashed; background: transparent; font-size: 13px; }
.todo-list li .handle { cursor: grab; color: var(--muted); user-select: none; padding: 0 2px; }
.idea-list li .to-todo-btn { flex: none; white-space: nowrap; }
.todo-list li.dragging { opacity: 0.4; }
.todo-list li .run-todo-btn, .todo-list li .link-run-btn { flex: none; border: none; background: none; font-size: 13px; line-height: 1; padding: 0 4px; opacity: 0.35; filter: grayscale(1); }
.todo-list li .run-todo-btn:hover, .todo-list li .link-run-btn:hover { opacity: 1; filter: none; }
.todo-list li .todo-run { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.todo-list li .todo-run .status { cursor: help; }
.todo-list li .todo-run button { padding: 2px 6px; font-size: 11px; }
.todo-list li .done-at { color: var(--muted); font-size: 12px; white-space: nowrap; }
.todo-history { margin-top: 20px; }
.todo-rest summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; user-select: none; }
.todo-history summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; user-select: none; }

.filters { display: flex; gap: 16px; margin-bottom: 16px; }
.filters label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.filters select { width: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--accent); color: #fff; border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.chip button { border: none; background: none; color: #fff; padding: 0 6px; }
.chip.static { padding: 2px 10px; background: #2c3a6b; }
.chips-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.chips-input input { border: none; background: none; flex: 1; min-width: 160px; padding: 4px; outline: none; }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: min(620px, 94vw); }
dialog.wide { width: min(1000px, 96vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h3 { margin: 0 0 4px; }
dialog label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
dialog label.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: 8px; }
dialog label.check input { width: auto; }
.duration-field { display: flex; flex-direction: column; gap: 6px; }
.duration-field .field-label { color: var(--muted); font-size: 13px; }
.duration-inputs { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.duration-inputs input { width: 70px; }
.duration-inputs input + span { margin-right: 8px; }
.duration-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.focus-modes { display: flex; gap: 16px; }
dialog .focus-modes label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); cursor: pointer; }
.focus-modes input, .duration-inputs input[type="time"] { width: auto; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; }
.presets button { padding: 3px 8px; font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); min-height: 16px; }
.hint.bad, .error { color: var(--red); font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.run-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.run-head h3 { margin: 0; }
.spacer { flex: 1; }
.resume-form { display: flex; flex-direction: row; gap: 8px; margin-top: 10px; align-items: stretch; }
.resume-form textarea { flex: 1; font: inherit; resize: vertical; }
#run-output { background: #0a0c10; border-radius: 8px; padding: 12px; height: 60vh; overflow: auto; margin: 0; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

/* Session / Summary switch in the run viewer, and Claude's final answer rendered as Markdown */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: none; border-radius: 0; background: transparent; color: var(--muted); padding: 6px 11px; font-size: 13px; }
.view-toggle button + button { border-left: 1px solid var(--border); }
.view-toggle button.active { background: var(--accent); color: #fff; }
.md { background: var(--surface-2); border-radius: 8px; padding: 18px 24px; height: 60vh; overflow: auto; font-size: 15px; line-height: 1.6; word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .4em; line-height: 1.3; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; color: var(--muted); }
.md p { margin: .6em 0; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.5em; }
.md li { margin: .2em 0; }
.md li > ul, .md li > ol { margin: .1em 0; }
.md a { color: var(--accent); }
.md strong { color: #fff; }
.md code { background: #0a0c10; border-radius: 4px; padding: 1px 5px; font: 13px ui-monospace, Consolas, monospace; }
.md pre { background: #0a0c10; border-radius: 8px; padding: 10px 12px; overflow: auto; }
.md pre code { background: none; padding: 0; white-space: pre; }
.md blockquote { margin: .6em 0; padding: 2px 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.md table { border-collapse: collapse; margin: .6em 0; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface); }
.md .md-empty { color: var(--muted); font-style: italic; }

.focus-btn { border-color: var(--red); color: var(--red); background: transparent; font-variant-numeric: tabular-nums; }
.focus-btn:hover { background: rgba(255, 107, 107, 0.1); border-color: var(--red); }
.focus-btn.active, .focus-btn.active:hover { border-color: var(--amber); color: var(--amber); background: transparent; cursor: default; }
#ext-status.bad { color: var(--amber); }
.bell-wrap { position: relative; }
.icon-btn { background: none; border: none; font-size: 18px; position: relative; }
.badge { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; font-size: 10px; border-radius: 99px; padding: 1px 5px; }
.panel { position: absolute; right: 0; top: 40px; width: 360px; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#notif-list { list-style: none; margin: 0; padding: 0; }
#notif-list li { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: default; }
#notif-list li.clickable { cursor: pointer; }
#notif-list li.clickable:hover { background: var(--surface-2); }
#notif-list li.unread { border-left: 3px solid var(--accent); }
#notif-list .when { color: var(--muted); font-size: 11px; }

.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; min-width: 260px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }

.summary { background: var(--surface-2); border-left: 4px solid var(--green); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.summary.warn { border-left-color: var(--amber); }
.summary.error { border-left-color: var(--red); }
.card .summary { margin: 0; font-size: 12px; padding: 5px 9px; }
td.summary-cell { color: var(--muted); max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-btns { display: flex; gap: 8px; }
#summary-text { font: 13px/1.55 system-ui, "Segoe UI", sans-serif; min-height: 50vh; }
.hint code { font-size: 11px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

/* Dashboard: two job cards per row, and a runs table that does not wrap its short columns */
.dash-main .cards { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.dash-main table.runs td:nth-child(2), .dash-main table.runs td:nth-child(5), .dash-main table.runs td:nth-child(6), .dash-main table.runs td:last-child { white-space: nowrap; }
.dash-main table.runs td:first-child { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-main table.runs td button { white-space: nowrap; }
.dash-main td.summary-cell { max-width: 300px; }
.dash-main table.runs { table-layout: fixed; }
.dash-main table.runs th:nth-child(1) { width: 16%; }
.dash-main table.runs th:nth-child(2) { width: 10%; }
.dash-main table.runs th:nth-child(3) { width: 11%; }
.dash-main table.runs th:nth-child(5) { width: 14%; }
.dash-main table.runs th:nth-child(6) { width: 15%; }
.dash-main table.runs th:nth-child(7) { width: 230px; }
.dash-main table.runs td { overflow: hidden; text-overflow: ellipsis; }
.dash-main table.runs td:first-child, .dash-main td.summary-cell { max-width: none; }
.metric-tile .m-pct { font-size: 18px; font-weight: 700; color: var(--text); margin-left: 8px; }

/* Compact job cards on the Dashboard: one-line command, two-line summary, buttons on one row */
.dash-main .cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.job-card { padding: 12px; gap: 6px; }
.job-card .title { font-size: 14px; justify-content: space-between; align-items: flex-start; }
.job-card code.job-cmd { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: none; font-size: 11px; color: var(--muted); padding: 4px 8px; }
.job-card .summary { font-size: 12px; line-height: 1.4; padding: 0 10px; border-top: 5px solid transparent; border-bottom: 5px solid transparent; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.job-card .meta { font-size: 11px; gap: 2px 10px; }
.job-card .btns { flex-wrap: nowrap; gap: 4px; }
.job-card .btns button { padding: 3px 8px; font-size: 12px; white-space: nowrap; }
.job-card .btns .job-del { margin-left: auto; border-color: transparent; background: none; color: var(--muted); }
.job-card .btns .job-del:hover { border-color: var(--red); }

/* Metric tiles: tighter, names clamp to two lines, an odd last tile spans the full row */
.metric-tile { min-height: 88px; padding: 10px 12px; }
.metric-tile .m-name { font-size: 11px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.metric-tile .m-value { font-size: 30px; }
.metric-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* Metric goals: coloured tile numbers with an explanatory tooltip, and auto-evaluated goal rows */
.metric-tile { position: relative; }
.metric-tile .m-value.goal-met { color: var(--green); }
.metric-tile .m-value.goal-missed { color: var(--red); }
.metric-tile .m-goal-flag { color: var(--accent); }
.metric-tile .m-tip { display: none; position: absolute; left: 0; min-width: 240px; max-width: 320px; bottom: calc(100% + 6px); z-index: 20; background: #0a0c10; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.45; color: var(--text); text-transform: none; letter-spacing: 0; box-shadow: 0 8px 24px rgba(0,0,0,.5); pointer-events: none; }
.metric-tile:hover .m-tip, .metric-tile:focus-visible .m-tip { display: block; }
.goal-form { display: flex; flex-direction: column; gap: 6px; }
.goal-row { display: flex; gap: 6px; }
.goal-row select { width: auto; }
.goal-row input { min-width: 0; }
.goal-list li .goal-sub { display: block; font-size: 11px; color: var(--muted); }
.goal-list li .goal-state { font-size: 18px; font-weight: 700; padding: 0 2px; }
.goal-list li.metric-goal.met .goal-state { color: var(--green); }
.goal-list li.metric-goal.missed .goal-state { color: var(--red); }
.goal-list li.metric-goal.pending .goal-state { color: var(--muted); }

/* Slack message a run wrote */
.run-actions { display: flex; gap: 4px; justify-content: flex-end; }
.run-actions .slack-btn { border-color: #4a154b; background: #4a154b; color: #fff; }
.run-actions .slack-btn:hover { border-color: #e01e5a; }
#slack-dialog { width: min(720px, 94vw); }
#notes-dialog { width: min(1100px, 96vw); }
#notes-dialog textarea { height: 60vh; min-height: 240px; font-size: 14px; line-height: 1.5; }
.slack-text { background: var(--surface-2); border-radius: 8px; padding: 14px; margin: 0; max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 14px/1.5 system-ui, "Segoe UI", sans-serif; }
.metric-tile .m-value.goal-met .m-pct { color: var(--green); }
.metric-tile .m-value.goal-missed .m-pct { color: var(--red); }
.metric-tile .m-tip .tip-missed { color: var(--red); }
.metric-tile .m-tip .tip-met { color: var(--green); }
.metric-tile .m-tip .tip-meta { color: var(--muted); }

/* Metric goal form: stacked labelled fields so nothing runs off the side panel */
.goal-metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.goal-metric-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); min-width: 0; }
.goal-metric-grid label.full { grid-column: 1 / -1; }
.goal-metric-grid select, .goal-metric-grid input { width: 100%; }
.goal-metric-grid .target-wrap { display: flex; align-items: center; gap: 6px; }
.goal-metric-grid .target-wrap span { color: var(--muted); font-size: 14px; }
.goal-row input#goal-title { flex: 1; }

/* Weekly goal carry-over toggle */
.goal-list li .carry { border: 1px solid transparent; background: none; color: var(--muted); font-size: 15px; font-weight: 700; padding: 0 6px; border-radius: 6px; opacity: .45; }
.goal-list li .carry:hover { opacity: 1; border-color: var(--border); }
.goal-list li .carry.on { opacity: 1; color: var(--accent); background: rgba(108, 140, 255, 0.15); }

/* Recent runs duration: live elapsed time, time left / comparison with the previous successful run */
.dash-main table.runs td.dur-cell { white-space: normal; line-height: 1.25; }
.dur-cell .dur-main { display: block; font-variant-numeric: tabular-nums; }
.dur-cell .dur-note { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dur-cell .dur-note.faster { color: var(--green); }
.dur-cell .dur-note.slower, .dur-cell .dur-note.over { color: var(--amber); }
.dur-cell .dur-bar { display: block; height: 4px; margin-top: 3px; background: var(--border); border-radius: 99px; overflow: hidden; }
.dur-cell .dur-bar span { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
.dur-cell .dur-bar.over span { background: var(--amber); }

/* Spotify remote in the top bar */
.spotify-wrap { position: relative; }
.spotify-bar { display: flex; align-items: center; gap: 2px; border: 1px solid #1db954; border-radius: 8px; padding-right: 4px; }
.spotify-bar.playing { background: rgba(29, 185, 84, 0.12); }
.spotify-btn { display: flex; align-items: center; gap: 6px; max-width: 220px; border-color: transparent; color: #1db954; background: transparent; }
.spotify-btn:hover { border-color: transparent; }
.spotify-btn #spotify-mini { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-mini-controls { display: flex; align-items: center; gap: 2px; padding-left: 4px; border-left: 1px solid rgba(29, 185, 84, 0.35); }
.sp-mini-controls button { padding: 4px 6px; font-size: 13px; line-height: 1; background: transparent; border-color: transparent; color: #1db954; }
.sp-mini-controls button:hover { background: rgba(29, 185, 84, 0.18); border-color: transparent; }
/* Speaker drawn in SVG (the 🔊 emoji has its own colors): waves when on, a cross when muted */
.sp-mini-controls .sp-icon { width: 15px; height: 15px; display: block; }
#sp-mini-mute .sp-cross, #sp-mini-mute.muted .sp-waves { display: none; }
#sp-mini-mute.muted .sp-cross { display: inline; }
/* Slim custom volume slider: 3px line (green up to the current volume, --vol set from JS) and a small dot */
.sp-mini-controls input[type=range] {
  -webkit-appearance: none; appearance: none; width: 56px; height: 3px; padding: 0; margin: 0 4px; border: none; border-radius: 99px; cursor: pointer;
  background: linear-gradient(to right, #1db954 var(--vol, 70%), rgba(29, 185, 84, 0.3) var(--vol, 70%));
}
.sp-mini-controls input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 9px; height: 9px; border-radius: 50%; background: #1db954; border: none; }
.sp-mini-controls input[type=range]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: #1db954; border: none; }
.spotify-btn .sp-logo { width: 18px; height: 18px; flex: none; }
.spotify-panel { width: 380px; padding: 14px; right: 0; }
.sp-section { display: flex; flex-direction: column; gap: 10px; }
.sp-steps { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.sp-steps code { color: var(--text); word-break: break-all; }
.sp-row { display: flex; gap: 6px; }
button.sp-connect { background: #1db954; border-color: #1db954; color: #000; font-weight: 600; }
.spotify-panel a { color: var(--accent); }
.sp-now { display: flex; gap: 12px; align-items: center; }
.sp-now img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.sp-meta { min-width: 0; }
.sp-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-artist, .sp-device { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-progress { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.sp-progress span { display: block; height: 100%; background: #1db954; }
.sp-controls { display: flex; align-items: center; gap: 8px; }
.sp-controls button { font-size: 16px; padding: 6px 12px; }
.sp-controls .sp-play { background: #1db954; border-color: #1db954; color: #000; }
.sp-controls input[type=range] { flex: 1; padding: 0; accent-color: #1db954; }
/* Scrollable list; more results load as it nears the bottom (app.js). Contain keeps the wheel from scrolling the page. */
.sp-results { list-style: none; margin: 0; padding: 0; max-height: min(320px, 45vh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sp-results:empty { display: none; }
.sp-results li[data-kind="playlist"] small { color: #1db954; }
.sp-results li { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 6px; cursor: pointer; }
.sp-results li:hover { background: var(--surface-2); }
.sp-results img { width: 36px; height: 36px; border-radius: 4px; }
.sp-results span { display: flex; flex-direction: column; min-width: 0; }
.sp-results b, .sp-results small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-results small { color: var(--muted); }
.sp-disconnect { align-self: flex-end; font-size: 12px; color: var(--muted); }
.sp-reconnect { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--amber); }
.head-actions { display: flex; gap: 8px; }

/* Focus reminder pop-up: big on purpose, so it can't be missed */
#focus-reminder-dialog { width: min(1100px, 92vw); min-height: 70vh; border: 2px solid var(--amber); border-radius: 18px;
  padding: 56px; text-align: center; font-size: 18px; }
#focus-reminder-dialog[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#focus-reminder-dialog h1 { font-size: 52px; margin: 0 0 12px; }
#focus-reminder-dialog .lead { font-size: 24px; color: var(--muted); margin: 0 0 36px; }
#focus-reminder-dialog .go { font-size: 30px; font-weight: 600; padding: 22px 56px; border-radius: 14px; border: none;
  background: var(--accent); color: #fff; }
#focus-reminder-dialog .go:disabled { opacity: .6; cursor: default; }
#focus-reminder-dialog .detail { margin-top: 14px; color: var(--muted); font-size: 17px; }
#focus-reminder-dialog .phone { margin-top: 36px; padding: 22px 26px; border-radius: 14px; background: #2a2414;
  border: 1px solid var(--amber); font-size: 24px; width: 100%; }
#focus-reminder-dialog .msg { margin-top: 22px; font-size: 20px; min-height: 30px; }
#focus-reminder-dialog .msg.ok { color: var(--green); }
#focus-reminder-dialog .msg.err { color: var(--red); }
#focus-reminder-dialog .later { margin-top: 18px; color: var(--muted); font-size: 16px; text-decoration: underline; }

/* Interactive review buttons (Recent runs row and run viewer) */
.review-btn.pending { border-color: var(--amber); background: var(--amber); color: #1b1300; }
.review-btn.pending:hover { border-color: #fff; }
.review-btn.submitted { color: var(--muted); }

/* WhatsApp notifications (Settings) */
.wa-box { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.wa-box .field-label { color: var(--muted); font-size: 13px; }
.wa-box label.check { align-self: start; padding-bottom: 0; }
.wa-setup { display: flex; flex-direction: column; gap: 6px; }
.wa-steps { margin: 0; padding-left: 20px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.wa-steps code { font-size: 11px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.wa-inputs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wa-inputs input { flex: 1 1 160px; width: auto; }
.wa-steps a { color: var(--accent); }
.wa-qr { display: flex; align-items: center; justify-content: center; min-height: 120px; }
.wa-qr img { width: 240px; height: 240px; background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }
