:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #1f2a1f;
  --muted: #6b766b;
  --accent: #2f7d4a;
  --accent-2: #e9f3ec;
  --border: #dfe5df;
  --easy: #2f9e44;
  --mid: #e8890c;
  --hard: #d6336c;
  --star: #f0a500;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
body { display: flex; }
.hidden { display: none !important; }
#panel { width: 380px; max-width: 100%; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--border); padding: 0 16px 16px; }
main { flex: 1; position: relative; height: 100vh; height: 100dvh; }
#map { position: absolute; inset: 0; }
.top { position: sticky; top: 0; background: var(--panel); z-index: 5; padding-top: 14px; border-bottom: 1px solid var(--border); }
h1 { font-size: 1.3rem; margin: 0 0 10px; }
h2 { font-size: 1rem; margin: 0 0 8px; }
.tabs { display: flex; gap: 4px; }
.tab { flex: 1; border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 4px; color: var(--muted); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.block { border-bottom: 1px solid var(--border); padding: 12px 0; }
.row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; }
input[type=text], select { padding: 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
select { width: 100%; margin-top: 4px; }
button { padding: 8px 12px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font: inherit; color: inherit; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.fav-on { background: #fff6dd; border-color: var(--star); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.wide { width: 100%; margin-top: 8px; }
label { display: block; font-size: .9rem; margin: 8px 0 2px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.dual { display: flex; gap: 8px; }
.hint, .muted { color: var(--muted); font-size: .8rem; font-weight: normal; }
.status { font-size: .85rem; margin: 8px 0; color: var(--muted); min-height: 1.2em; }
.status.error { color: var(--hard); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { margin: 4px 0; background: var(--accent-2); padding: 4px 10px; border-radius: 999px; cursor: pointer; }
.route-list { list-style: none; padding: 0; margin: 0; }
.route-list li { padding: 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.route-list li:hover, .route-list li.active { border-color: var(--accent); background: var(--accent-2); }
.route-list .name { font-weight: 600; }
.route-list .star { color: var(--star); }
.route-list .meta { font-size: .8rem; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; color: #fff; font-size: .75rem; }
.badge.facil { background: var(--easy); }
.badge.moderada { background: var(--mid); }
.badge.dificil { background: var(--hard); }
.badge.pending { background: #999; }
.badge.done { background: var(--accent); }
#detail { position: absolute; right: 12px; bottom: 12px; z-index: 1000; width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto; background: var(--panel); border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.2); padding: 14px; }
#detail h3 { margin: 0 0 6px; font-size: 1rem; padding-right: 24px; }
#detail .close { position: absolute; top: 8px; right: 8px; border: none; background: none; font-size: 1.2rem; }
#detail .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; text-align: center; font-size: .8rem; }
#detail .stats b { display: block; font-size: 1rem; }
#detail canvas { width: 100%; height: 110px; display: block; }
#detail .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
#detail .actions label { margin: 0; }
#detail .tags { font-size: .8rem; color: var(--muted); margin-top: 4px; }
#detail a { text-decoration: none; }
#detail a button { color: var(--text); }

@media (max-width: 760px) {
  body { flex-direction: column-reverse; }
  #panel { width: 100%; height: 55dvh; border-right: none; border-top: 1px solid var(--border); }
  main { height: 45dvh; }
  #panel #detail { position: relative; inset: auto; width: auto; max-height: none; margin: 10px 0; padding: 10px; box-shadow: none; border: 2px solid var(--accent); }
  #detail canvas { height: 80px; }
  #detail .stats { margin: 4px 0; }
  #detail .actions button { padding: 6px 10px; font-size: .9rem; }
}
