* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
  color: #1a1a2e;
}

/* === SIDEBAR === */

#sidebar {
  width: 400px;
  min-width: 400px;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000;
}

.sidebar-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-build {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s;
}

.btn-build:hover { background: #1e293b; }
.btn-build:disabled { background: #94a3b8; cursor: wait; }

#build-panel {
  border-bottom: 1px solid #e2e8f0;
  background: #0f172a;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
}

.build-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #1e293b;
}

.build-panel-header button {
  background: none;
  border: none;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

.build-panel-header button:hover { color: #e2e8f0; }

#build-output {
  padding: 10px 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #a5f3fc;
  overflow-y: auto;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.sidebar-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}

/* === MODE TABS === */

.mode-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.mode-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.mode-tab:hover { color: #475569; }

.mode-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
  background: #fff;
}

/* === PANELS === */

.panel { display: none; flex-direction: column; flex: 1; }
.panel.active { display: flex; }

.panel-section {
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
}

.panel-description {
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

.panel-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  margin-top: auto;
}

/* === INPUTS === */

.input-group {
  padding: 12px 20px 4px;
  position: relative;
}

.input-group.compact {
  padding: 6px 20px;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.input-group.compact label {
  font-size: 11px;
  margin-bottom: 4px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 0 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8fafc;
}

.input-wrapper:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #fff;
}

.input-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}

.start-icon { background: #22c55e; }
.end-icon { background: #ef4444; }

.input-wrapper input,
.input-group.compact input,
.input-group.compact select {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  outline: none;
  font-size: 13px;
  padding: 8px 10px;
  font-family: inherit;
  background: #f8fafc;
  color: #1e293b;
}

.input-wrapper input {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 10px 0;
  background: transparent;
}

.input-group.compact input:focus,
.input-group.compact select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #fff;
}

.input-wrapper input::placeholder { color: #94a3b8; }

.btn-clear {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 4px;
  display: none;
}

.btn-clear.visible { display: block; }
.btn-clear:hover { color: #ef4444; }

/* === SUGGESTIONS === */

.suggestions {
  list-style: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  position: absolute;
  left: 20px;
  right: 20px;
  z-index: 10;
}

.suggestions.open { display: block; }

.suggestions li {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover { background: #f1f5f9; }

/* === BUTTONS === */

.actions {
  display: flex;
  gap: 8px;
  padding: 8px 20px 12px;
}

.actions button {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.actions button:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-action {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-action:hover { background: #2563eb; }
.btn-action:disabled { background: #cbd5e1; cursor: default; }

.btn-action.btn-exclude-active {
  background: #ef4444;
}
.btn-action.btn-exclude-active:hover { background: #dc2626; }

.btn-primary {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: #2563eb; }
.btn-primary:disabled { background: #cbd5e1; cursor: default; }

.btn-secondary {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.draw-controls {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
}

.draw-controls button { flex: 1; }

/* === ROUTE SUMMARY === */

#route-summary {
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  background: #f0f9ff;
}

.summary-row {
  display: flex;
  gap: 20px;
}

.summary-item {
  flex: 1;
  text-align: center;
}

.summary-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
}

.summary-label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === INSTRUCTIONS === */

#instructions {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

#instructions h2 {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#instructions-list {
  list-style: none;
  counter-reset: step;
}

#instructions-list li {
  position: relative;
  padding: 10px 12px 10px 40px;
  font-size: 13px;
  line-height: 1.5;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

#instructions-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

#instructions-list li .step-detail {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 2px;
}

/* === NODE HOVER CARD (draw mode) === */

.detail-card {
  margin: 8px 20px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.detail-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

.detail-id {
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace;
}

/* === EXCLUDED / SELECTED / DRAW LISTS === */

#excluded-list-section,
#draw-ways-list-section,
#draw-way-progress,
#inspect-detail {
  padding: 12px 20px;
  flex: 1;
  overflow-y: auto;
}

#excluded-list-section h2,
#draw-ways-list-section h2,
#draw-way-progress h2,
#inspect-detail h2 {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

#excluded-list-section h2 span,
#draw-ways-list-section h2 span,
#draw-way-progress h2 span,
#inspect-detail h2 span {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
}

#excluded-list,
#draw-ways-list,
#draw-node-list,
#selected-list {
  list-style: none;
}

#excluded-list li,
#draw-ways-list li,
#draw-node-list li,
#selected-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

#excluded-list li .way-info,
#draw-ways-list li .way-info,
#draw-node-list li .way-info,
#selected-list li .way-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#excluded-list li .way-name,
#draw-ways-list li .way-name,
#draw-node-list li .way-name,
#selected-list li .way-name {
  font-weight: 500;
}

#excluded-list li .way-id,
#draw-ways-list li .way-id,
#draw-node-list li .way-id,
#selected-list li .way-id {
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace;
}

#excluded-list li .btn-remove,
#draw-ways-list li .btn-remove,
#selected-list li .btn-remove {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}

#excluded-list li .btn-remove:hover,
#draw-ways-list li .btn-remove:hover,
#selected-list li .btn-remove:hover {
  color: #ef4444;
  background: #fef2f2;
}

/* === HINT === */

.hint {
  padding: 20px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
  flex: 1;
  display: grid;
  place-content: center;
}

.hidden { display: none !important; }

/* === MAP === */

#map {
  flex: 1;
  height: 100vh;
}

.marker-start {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #22c55e;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.marker-end {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ef4444;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.marker-draw-node {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* === DRAW LEGEND === */

.draw-legend {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #475569;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.active { background: #3b82f6; }
.legend-dot.bridge { background: #22c55e; box-shadow: 0 0 0 2px #bbf7d0; }
.legend-dot.excluded { background: #ef4444; }
.legend-dot.custom { background: #8b5cf6; }

.node-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.marker-draw-node-snap {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8b5cf6;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
