:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #71717a;
  --panel: #f4f4f5;
  --line: #e4e4e7;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg: #09090b;
  --fg: #fafafa;
  --muted: #a1a1aa;
  --panel: #18181b;
  --line: #27272a;
  --accent: #3b82f6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Noto Sans', sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  overflow-y: auto;
}

/* Header Styling */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
  z-index: 1000;
  position: sticky;
  top: 0;
}

.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 32px;
  height: 32px;
  background: var(--fg);
  color: var(--bg);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
}
.brand-text .title { font-weight: 700; font-size: 14px; }
.brand-text .tag { font-size: 9px; color: var(--accent); letter-spacing: 0.05em; font-weight: 800; }

.center-nav { display: flex; gap: 12px; align-items: center; }
.nav-group {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.nav-group button {
  background: transparent;
  border: none;
  padding: 8px 12px;
  color: var(--fg);
  cursor: pointer;
  font-weight: 700;
}
.nav-group button:hover { background: rgba(0,0,0,0.05); }
.set-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 80px;
}
.set-display #setCounter { font-size: 12px; font-weight: 700; }
.set-display #countIndicator { font-size: 9px; color: var(--accent); font-weight: 600; }

.playback-controls { display: flex; gap: 8px; }
.playback-controls button {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
}
.btn-primary { background: var(--accent); color: white; border-color: var(--accent)!important; }
.btn-secondary { background: var(--bg); color: var(--fg); }
.btn-ghost { background: transparent; color: var(--muted); border-style: dashed!important; }
.btn-ghost.active { border-style: solid!important; border-color: var(--accent)!important; color: var(--accent); }

.system-actions { display: flex; gap: 8px; }
.patch-notes-pill {
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--fg);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

/* Layout */
.layout {
  display: flex;
  flex: 1;
}

/* Sidebar */
.sidebar {
  width: 260px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  flex-shrink: 0;
}
.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.panel h3 { margin: 0 0 8px 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.notes-input {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 8px;
  font-size: 13px;
  resize: none;
  background: var(--panel);
  color: var(--fg);
}
.list { list-style: none; padding: 0; margin: 0; font-size: 13px; max-height: 200px; overflow-y: auto; }
.list li { padding: 4px 0; border-bottom: 1px solid var(--line); }

.marker-summary { font-size: 13px; color: var(--fg); }
.marker-summary .marker-line { margin-bottom: 6px; }
.marker-breakdown { display:flex; flex-direction:column; gap:4px; max-height:160px; overflow:auto; }
.marker-breakdown .mb-item { display:flex; justify-content:space-between; padding:6px; border-radius:6px; background:var(--panel); border:1px solid var(--line); font-size:12px; }

/* Main Canvas Area */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
  min-width: 0;
}
.canvas-wrap {
  flex: 1;
  padding: 12px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.field-container {
  width: 100%;
  aspect-ratio: 2.25 / 1;
  max-height: 75vh;
  border-radius: 12px;
  overflow: hidden;
  background: #cbd5e1;
  box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
  position: relative;
}
#fieldSvg { width: 100%; height: 100%; touch-action: none; outline: none; }

/* Action Shelf (Place/Shape tools) */
.action-shelf {
  min-height: 70px;
  height: auto;
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 12px 20px;
  align-items: center;
  flex-shrink: 0;
}
.shelf-tool { display: flex; flex-direction: column; gap: 4px; }
.tool-header { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.tool-controls { display: flex; gap: 8px; align-items: center; }
.tool-controls select, .tool-controls input {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  font-size: 12px;
}
.tool-controls input[type="number"] { width: 60px; }
.size-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.size-control input[type="range"] {
  width: 80px;
  height: 4px;
}
.btn-sm {
  padding: 6px 12px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Status Strip (Field/Audio settings) */
.status-strip {
  min-height: 48px;
  height: auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
  flex-shrink: 0;
}
.strip-section { display: flex; gap: 12px; align-items: center; }
.strip-section select {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.toggle-pills { display: flex; gap: 4px; }
.pill-btn {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.pill-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.met-controls-compact { display: flex; gap: 4px; align-items: center; }
.met-controls-compact input { width: 50px; padding: 4px; font-size: 12px; border-radius: 4px; border: 1px solid var(--line); }
.met-controls-compact button { background: var(--bg); border: 1px solid var(--line); padding: 4px 8px; border-radius: 4px; font-size: 11px; cursor: pointer; }

/* Footer */
.footer-bar {
  height: 32px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.tip { font-style: italic; }

/* Modals and Overlays */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
  display: grid; place-items: center;
}
.modal[hidden] { display: none !important; }
.modal-inner {
  background: var(--bg); width: 440px; border-radius: 12px; border: 1px solid var(--line);
  padding: 24px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header strong { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { font-size: 14px; line-height: 1.6; }
.modal-body .version { font-weight: 800; margin-top: 12px; color: var(--accent); }
.modal-footer { margin-top: 24px; display: flex; justify-content: flex-end; }

/* Field Graphics classes from previous versions */
.field-bg { fill: #0e7a2a; }
.realistic-bg { fill: #0b5f22; }
.paper-bg { fill: #ffffff; }
.blueprint-bg { fill: #1e3a8a; }
.night-bg { fill: #020617; }
.field-line { stroke: #ffffff; stroke-width: 1.5; }
.paper-line { stroke: #000; stroke-width: 1; }
.blueprint-line { stroke: #60a5fa; stroke-width: 1; }
.yard-num { font: 10px "Space Mono"; fill: white; }
.marcher circle { stroke: rgba(0,0,0,0.2); stroke-width: 1; }
.marcher text { 
  font-family: "Space Mono", monospace; 
  fill: white; 
  pointer-events: none; 
  font-weight: 700;
  text-anchor: middle;
  /* allow dynamic sizing via inline styles from JS; keep defaults here */
}
.marcher.brass circle { fill: #2563eb; }
.marcher.woodwind circle { fill: #7c3aed; }
.marcher.percussion circle { fill: #10b981; }
.marcher.pit circle { fill: #f59e0b; }
.marcher.props circle { fill: #4b5563; }
.arrow { stroke: #111827; stroke-width: 1.5; marker-end: url(#arrowHead); }
.count-tag { font: 9px "Space Mono"; fill: #111827; font-weight: 700; }

.drag-label {
  position: absolute; pointer-events: none; background: #000; color: #fff;
  padding: 2px 6px; border-radius: 4px; font-size: 10px; font-family: monospace;
}