/* SPDX-License-Identifier: GPL-3.0-or-later */
:root {
  --fg: #1d2330;
  --muted: #5d6676;
  --bg: #f5f6f8;
  --card: #fff;
  --line: #d9dde4;
  --accent: #e08a00;
  --error: #c62828;
  --warning: #b26a00;
  --ok: #2e7d32;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 3px solid var(--accent);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.switch {
  margin: 0.25rem 0 0;
}

.refused:not(:empty) {
  max-width: 70rem;
  margin: 0 auto 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid #c0392b;
  border-radius: 6px;
  background: #fdecea;
  color: #7b241c;
}

header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button,
.button {
  font: inherit;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.small {
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: start;
}

@media (max-width: 1000px) {
  main {
    grid-template-columns: 1fr;
  }
}

/* calibration mode: the form alone, the checks and the files are in its section */
main.calibrating {
  grid-template-columns: minmax(0, 60rem);
  justify-content: center;
}

main.calibrating aside {
  display: none;
}

aside {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 2rem);
}

@media (max-width: 1000px) {
  aside {
    position: static;
    max-height: none;
  }
}

aside section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

#output-box {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

#output {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

aside h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

fieldset {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem 1rem;
}

fieldset.error {
  border-left-color: var(--error);
}

fieldset.warning {
  border-left-color: var(--warning);
}

legend {
  font-weight: 600;
  font-size: 1.1rem;
  padding: 0 0.4rem;
}

h3 {
  font-size: 1rem;
  margin: 0.75rem 0 0.25rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: flex-end;
  margin: 0.4rem 0;
}

.row > strong {
  min-width: 5.5rem;
  align-self: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.3rem 0;
}

.field > span {
  font-size: 0.85rem;
  color: var(--muted);
}

.check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.3rem 0;
}

.check .help {
  flex-basis: 100%;
  margin-left: 1.6rem;
}

.help {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.15rem 0 0.3rem;
}

input[type='number'] {
  width: 7rem;
}

input[type='text'] {
  width: 14rem;
}

input,
select {
  font: inherit;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.block {
  padding: 0.25rem 0;
  border-top: 1px dashed var(--line);
}

.block:first-of-type {
  border-top: none;
}

.sub {
  border-left: 2px solid var(--line);
  padding-left: 0.75rem;
  margin: 0.5rem 0;
}

.targets {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
}

.info {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0.5rem 0;
}

.info dt {
  color: var(--muted);
}

.info dd {
  margin: 0;
  font-weight: 600;
}

.note {
  font-size: 0.85rem;
  background: #fff6e5;
  border-left: 3px solid var(--accent);
  padding: 0.4rem 0.6rem;
}

#problems,
.problems {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 14rem;
  overflow: auto;
}

#problems li,
.problems li {
  padding: 0.3rem 0.5rem;
  margin: 0.2rem 0;
  border-left: 3px solid;
  font-size: 0.9rem;
  cursor: pointer;
}

#problems li.error,
.problems li.error {
  border-color: var(--error);
  color: var(--error);
}

#problems li.warning,
.problems li.warning {
  border-color: var(--warning);
  color: var(--warning);
}

.problems li {
  cursor: default;
}

#problems li.group {
  border: none;
  padding: 0.5rem 0 0.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: default;
}

#problems li.ok {
  border-color: var(--ok);
  color: var(--ok);
  cursor: default;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tabs button {
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
}

.tabs button.active {
  border-color: var(--accent);
  background: #fff6e5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

pre {
  margin: 0;
  padding: 0.75rem;
  background: #1d2330;
  color: #e8eaee;
  border-radius: 6px;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.35;
  min-height: 10rem;
  max-height: 55vh;
}

.cal-files {
  margin: 0.25rem 0 0.5rem;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

pre.lines {
  min-height: 0;
}

.where {
  font-size: 0.85rem;
}

.where ul {
  margin: 0.25rem 0;
  padding-left: 1.2rem;
}

output {
  display: inline-block;
  min-width: 6rem;
  padding: 0.3rem 0;
  font-family: ui-monospace, monospace;
}

output.changed {
  color: var(--ok);
  font-weight: 600;
}

.folder-status {
  font-size: 0.85rem;
  margin: 0.25rem 0 0.5rem;
  white-space: pre-line;
}

.folder-status.ok {
  color: var(--ok);
}

.folder-status.error {
  color: var(--error);
}

.blocked {
  color: var(--error);
}

footer {
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

footer a {
  color: inherit;
}

/* ---- boost timeline ---- */

.timeline {
  margin: 0.5rem 0 0.75rem;
}

.tl-lane {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.5rem;
  align-items: center;
  margin: 3px 0;
}

.tl-name {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

.tl-track {
  position: relative;
  height: 26px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.tl-bar {
  position: absolute;
  top: 2px;
  bottom: 2px;
  min-width: 6px;
  box-sizing: border-box;
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
  line-height: 20px;
  cursor: grab;
  touch-action: none; /* a touch drag moves the bar, not the page */
  user-select: none;
}

.tl-bar.dragging {
  cursor: grabbing;
  opacity: 0.85;
}

.tl-bar.c0 {
  background: #3b6fd8;
}
.tl-bar.c1 {
  background: #2f9e6a;
}
.tl-bar.c2 {
  background: #c7792a;
}
.tl-bar.c3 {
  background: #8a55c2;
}

.tl-bar.open {
  border-right: 3px dashed #fff; /* until the meter goes back to peak */
}

.tl-bar.bad {
  background: var(--error);
}

.tl-bar.selected {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

.tl-text {
  display: block;
  padding: 0 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

.tl-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 33%; /* a short bar keeps a body to move it by */
  max-width: 8px;
  cursor: ew-resize;
}

.tl-handle.right {
  right: 0;
}

.tl-handle.left {
  left: 0;
}

.sub.selected {
  border-left-color: var(--accent);
  background: #fff8ec;
}
