:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde6;
  --text: #1c2430;
  --muted: #667085;
  --accent: #1677ff;
  --good: #15803d;
  --bad: #b42318;
  --warn: #b54708;
  --ink: #111827;
  --shadow: 0 10px 28px rgba(30, 41, 59, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.rock-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.rock-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.brand strong {
  display: block;
  font-size: 16px;
  line-height: 20px;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.nav-button,
.ghost,
.primary,
.file-button {
  min-height: 40px;
  border-radius: 7px;
  font-weight: 650;
  cursor: pointer;
}

.nav-button {
  border: 1px solid var(--line);
  padding: 9px 12px;
  background: #fff;
  color: #344054;
  text-decoration: none;
  font-size: 13px;
}

.rock-main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
}

.viewer-panel {
  min-width: 0;
  min-height: calc(100vh - 64px);
  padding: 16px;
  display: grid;
}

.canvas-wrap {
  min-height: 420px;
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.route-popover {
  position: absolute;
  z-index: 4;
  width: min(240px, calc(100% - 20px));
  display: grid;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  padding: 10px 11px;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.route-popover strong {
  font-size: 13px;
  line-height: 18px;
}

.route-popover span {
  color: #d1d5db;
  font-size: 12px;
  line-height: 16px;
}

canvas {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  display: block;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: #dbeafe;
  text-align: center;
}

.empty-state strong {
  font-size: 18px;
  line-height: 24px;
}

.empty-state span {
  color: #a8b3c7;
  font-size: 13px;
}

.control-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: 22px;
  line-height: 28px;
}

h2 {
  font-size: 15px;
  line-height: 20px;
}

.field-grid {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

input,
select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.13);
}

.button-row,
.feedback-row,
.section-head,
.mini-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button-row {
  margin-top: 12px;
}

.button-row > * {
  flex: 1 1 0;
}

.button-row {
  align-items: stretch;
}

.file-button {
  border: 1px solid var(--line);
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  background: #fff;
  color: #344054;
  text-align: center;
}

.file-button input {
  display: none;
}

.primary {
  border: 0;
  padding: 0 13px;
  background: var(--accent);
  color: #fff;
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ghost {
  border: 1px solid var(--line);
  padding: 0 13px;
  background: #fff;
  color: #344054;
}

.tiny {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.summary-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fbfcfe;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}

.summary-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.topo-link {
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.topo-preview {
  min-height: 130px;
  max-height: 260px;
  position: relative;
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: auto;
  background: #f3f5f8;
}

.topo-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.topo-preview canvas {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: auto;
  max-height: none;
  pointer-events: none;
}

.route-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.route-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: #fff;
}

.route-item.is-hidden {
  opacity: 0.46;
}

.route-item.is-outside {
  background: #f8fafc;
}

.route-item.is-outside .route-swatch {
  opacity: 0.45;
}

.route-item.is-active {
  border-color: rgba(22, 119, 255, 0.45);
  background: #f5f9ff;
}

.route-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.25);
}

.route-title {
  min-width: 0;
}

.route-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 18px;
}

.route-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.route-badge {
  min-width: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  white-space: nowrap;
}

.route-badge.is-active {
  border-color: rgba(21, 128, 61, 0.3);
  color: var(--good);
  background: #f0fdf4;
}

.section-status {
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.recommend-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.recommend-item {
  width: 100%;
  min-height: 54px;
  display: grid;
  gap: 3px;
  justify-items: start;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.recommend-item strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 18px;
}

.recommend-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.feedback-row {
  margin-top: 10px;
  flex-wrap: wrap;
}

.feedback-row button {
  flex: 1 1 80px;
}

@media (max-width: 900px) {
  .rock-main {
    display: flex;
    flex-direction: column;
  }

  .viewer-panel {
    min-height: auto;
    padding: 10px;
  }

  .canvas-wrap {
    min-height: 54vh;
  }

  canvas {
    max-height: 68vh;
  }

  .control-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .rock-header {
    height: 58px;
    padding: 0 12px;
  }

  .rock-main {
    min-height: calc(100vh - 58px);
  }

  .viewer-panel {
    padding: 8px;
  }

  .canvas-wrap {
    min-height: 48vh;
  }

  .panel-section {
    padding: 13px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .button-row .primary {
    grid-column: 1 / -1;
  }
}
