:root {
  --green: #00b140;
  --panel-w: 360px;
  --panel-bg: #1b1d21;
  --panel-bg-2: #24272c;
  --panel-border: #34373d;
  --panel-ink: #f2f2f0;
  --panel-ink-muted: #9a9ea5;
  --ui-accent: #3987e5;

  --cat-1: #2a78d6; /* blue */
  --cat-2: #eb6834; /* orange */
  --cat-3: #1baf7a; /* aqua */
  --cat-4: #eda100; /* yellow */
  --cat-5: #e87ba4; /* magenta */
  --cat-6: #4a3aa7; /* violet */
  --cat-7: #e34948; /* red */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--panel-bg);
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---------- Control panel ---------- */

#panel {
  width: var(--panel-w);
  flex: 0 0 var(--panel-w);
  background: var(--panel-bg);
  color: var(--panel-ink);
  padding: 20px 20px 16px;
  overflow-y: auto;
  border-right: 1px solid var(--panel-border);
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 18px;
  color: var(--panel-ink);
}

.field-group {
  margin-bottom: 18px;
}

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

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--panel-ink-muted);
  margin-bottom: 8px;
}

.field-value {
  font-size: 13px;
  color: var(--panel-ink-muted);
  padding-bottom: 8px;
  min-width: 34px;
  text-align: right;
}

.field-hint {
  font-size: 11.5px;
  color: var(--panel-ink-muted);
  margin: 6px 0 0;
  line-height: 1.4;
}

input[type="text"],
select {
  width: 100%;
  background: var(--panel-bg-2);
  border: 1px solid var(--panel-border);
  color: var(--panel-ink);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13.5px;
}
input[type="text"]:focus, select:focus {
  outline: 2px solid var(--ui-accent);
  outline-offset: 1px;
}

input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--panel-bg-2);
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--ui-accent);
}

/* type tabs */

.type-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.type-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg-2);
  border: 1px solid var(--panel-border);
  color: var(--panel-ink-muted);
  border-radius: 10px;
  padding: 10px 6px 8px;
  font-size: 11.5px;
  cursor: pointer;
}
.type-tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.type-tab svg rect,
.type-tab svg path {
  fill: currentColor;
  stroke: none;
}
.type-tab[data-type="line"] svg polyline {
  stroke: currentColor;
  fill: none;
}
.type-tab[data-type="pie"] svg circle {
  stroke: currentColor;
  fill: none;
}
.type-tab.active {
  background: color-mix(in srgb, var(--ui-accent) 22%, var(--panel-bg-2));
  border-color: var(--ui-accent);
  color: #fff;
}

/* rows editor */

.rows-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.row-item {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr auto;
  gap: 6px;
}

.row-item input {
  background: var(--panel-bg-2);
  border: 1px solid var(--panel-border);
  color: var(--panel-ink);
  border-radius: 7px;
  padding: 7px 8px;
  font-size: 13px;
  width: 100%;
}

.row-remove {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--panel-ink-muted);
  border-radius: 7px;
  width: 30px;
  cursor: pointer;
  font-size: 13px;
}
.row-remove:hover {
  color: #e34948;
  border-color: #e34948;
}

/* buttons */

.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
}

.btn-primary {
  background: var(--green);
  color: #06210f;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: var(--panel-bg-2);
  color: var(--panel-ink);
  border: 1px solid var(--panel-border);
}
.btn-ghost:hover { border-color: var(--ui-accent); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.actions .btn { flex: 1; min-width: 90px; }

.btn-block {
  display: block;
  width: 100%;
}

.btn.is-recording {
  color: #e34948;
  border-color: #e34948;
}
.btn.is-recording::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #e34948;
  animation: rec-pulse 1s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.shortcuts-hint {
  font-size: 11px;
  color: var(--panel-ink-muted);
  line-height: 1.6;
  margin-top: 10px;
}
.shortcuts-hint kbd {
  background: var(--panel-bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10.5px;
}

/* ---------- Stage (recorded area) ---------- */

#stage {
  position: relative;
  flex: 1 1 auto;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.stage-inner {
  width: 100%;
  height: 100%;
  max-width: 1400px;
  padding: 48px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.stage-title {
  margin: 0;
  font-size: clamp(22px, 3.2vw, 40px);
  font-weight: 700;
  text-align: center;
  color: #fff;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.stage-title.visible {
  opacity: 1;
  transform: translateY(0);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

#chart-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  background: var(--green);
}
.countdown-overlay.hidden { display: none; }

#countdown-number {
  font-size: 22vh;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,0.25);
}

.edit-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.edit-btn.hidden { display: none; }
#stage:hover .edit-btn { opacity: 1; }

/* Present mode: panel hidden, stage fills the whole window */
body.present-mode #panel {
  display: none;
}
body.present-mode .edit-btn {
  display: flex;
}
