:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2126;
  --muted: #6b7480;
  --line: #dfe3e8;
  --accent: #1668b3;
  --accent-dark: #11507f;
  --danger: #c0392b;
  --radius: 7px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

/* ------------------------------------------------------------- sidebar */
#sidebar {
  width: 360px;
  flex: 0 0 360px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 0 0 40px;
}

.brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 5;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.3px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 600;
}

.field { display: block; margin-bottom: 11px; }
.field > span {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field.sub { margin-left: 24px; }
.field.grow { flex: 1; }

input[type="number"], input[type="text"], select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}
input[type="color"] {
  width: 100%;
  height: 31px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
select:focus, input:focus { outline: 2px solid rgba(22, 104, 179, 0.35); outline-offset: 0; }

.row { display: flex; gap: 10px; align-items: flex-end; }
.row > .field { flex: 1; }

.check, .checks label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  margin-bottom: 7px;
  cursor: pointer;
}
.check input, .checks input { margin-top: 2px; accent-color: var(--accent); }
.check em { color: var(--muted); font-style: normal; font-size: 11.5px; display: block; }
.check.inline { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

button {
  font: inherit;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
button:hover:not(:disabled) { background: var(--accent-dark); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary {
  background: #eceff3;
  color: var(--ink);
  font-weight: 500;
}
button.secondary:hover:not(:disabled) { background: #dfe4ea; }
button.link-btn {
  background: none;
  color: var(--accent);
  padding: 4px 0;
  font-weight: 500;
  font-size: 12.5px;
  text-decoration: underline;
}
button.link-btn:hover:not(:disabled) { background: none; color: var(--accent-dark); }
#trackList button.remove:hover:not(:disabled) { background: none; color: var(--danger); }

/* ------------------------------------------------------------ dropzone */
#dropzone {
  display: block;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
#dropzone:hover, #dropzone.hover { border-color: var(--accent); background: #f0f6fc; }
#dropzone strong { display: block; font-size: 13.5px; }
#dropzone span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }

#trackList { list-style: none; margin: 10px 0 0; padding: 0; }
#trackList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}
#trackList .swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
#trackList .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#trackList .meta { color: var(--muted); font-size: 11.5px; }
#trackList .remove {
  background: none;
  color: var(--muted);
  padding: 0 4px;
  font-size: 16px;
  line-height: 1;
}
#trackList .remove:hover { background: none; color: var(--danger); }

/* ---------------------------------------------------------------- main */
#main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#map { flex: 1; background: #dde3e8; }

#statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.summary { flex: 1; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.summary strong { color: var(--ink); }
.summary .warn { color: #b06a00; }
.summary .bad { color: var(--danger); }
.actions { display: flex; align-items: center; gap: 10px; }

#progressWrap {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  width: min(460px, 80%);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  z-index: 900;
}
#progressBar { height: 6px; background: #e6eaee; border-radius: 3px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
#progressText { margin-top: 7px; font-size: 12px; color: var(--muted); }

#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #2b3038;
  color: #fff;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 1000;
  max-width: 70%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}
#toast.error { background: var(--danger); }

.hint {
  margin: -2px 0 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}
.hint em { font-style: normal; font-weight: 600; }

.field > span a { color: var(--accent); font-size: 11px; }

/* start / finish markers in the preview */
.sf-icon {
  border-radius: 50%;
  border: 2px solid #fff;
  color: #fff;
  width: 20px;
  height: 20px;
  line-height: 17px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.sf-icon.start { background: #168a3e; }
.sf-icon.finish { background: #be1a2a; }
.sf-icon.loop { width: 14px; height: 14px; line-height: 12px; }

/* page rectangles in the preview */
.page-label {
  background: #fff;
  border: 1px solid #c81e1e;
  color: #c81e1e;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  line-height: 20px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

@media (max-width: 860px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; flex: 0 0 auto; max-height: 48vh; border-right: none; border-bottom: 1px solid var(--line); }
  #main { flex: 1; min-height: 52vh; }
}
