:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #66665f;
  --border: #e2e1dc;
  --accent: #0a66c2;
  --accent-text: #ffffff;
  --accent-soft: #e8f1fb;
  --b1: #0a66c2; --b1-bg: #e3eefa;
  --b2: #2f7d4f; --b2-bg: #e4f2e9;
  --b3: #8a6100; --b3-bg: #f8efd9;
  --b4: #7a5196; --b4-bg: #f0e8f6;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161615; --surface: #1f1f1d; --text: #ecebe6; --muted: #a3a29b; --border: #33322f;
    --accent: #5aa2ec; --accent-text: #0b1a2a; --accent-soft: #1d2c3c;
    --b1: #8cc0f5; --b1-bg: #1d2c3c;
    --b2: #82c99e; --b2-bg: #1b2e23;
    --b3: #e3bd62; --b3-bg: #33290f;
    --b4: #c7a3e3; --b4-bg: #2c2135;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; }
.lead { margin: 0 0 1rem; color: var(--muted); max-width: 60ch; }
.muted { color: var(--muted); }
.top { padding: 28px 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.course-pick { display: flex; gap: .5rem; align-items: center; font-weight: 600; max-width: 100%; }
.course-pick select { min-width: 0; flex: 0 1 auto; max-width: 100%; text-overflow: ellipsis; }

select, input[type="search"], button {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem;
}
button { cursor: pointer; background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); font-weight: 500; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 24px; padding-top: 20px; padding-bottom: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tools { display: flex; gap: .5rem; flex-wrap: wrap; }
.tools input { min-width: 0; width: 220px; }

.phase { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.phase > header { display: flex; align-items: center; justify-content: space-between; padding: .55rem .8rem; border-bottom: 1px solid var(--border); }
.phase > header label { font-weight: 650; display: flex; gap: .5rem; align-items: center; cursor: pointer; }
.phase > header .small { font-size: .82rem; }
.phase ul { list-style: none; margin: 0; padding: .3rem 0; }
.disc { display: flex; gap: .6rem; padding: .35rem .8rem; align-items: flex-start; }
.disc:hover { background: var(--accent-soft); }
.disc input { margin-top: .25rem; flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.disc label { flex: 1; cursor: pointer; min-width: 0; }
.disc .code { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; margin-right: .35rem; }
.disc .nsk { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.disc.nomap label { color: var(--muted); }

.results-inner { position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; max-height: calc(100vh - 32px); overflow: auto; }
.pill { display: inline-block; min-width: 1.6em; padding: 0 .45em; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .85rem; text-align: center; }
.filters { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-size: .9rem; margin-bottom: .5rem; }
.filters label { display: flex; gap: .35rem; align-items: center; }

.skills { list-style: none; padding: 0; margin: 0; }
.skill { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .6rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.skill:first-child { border-top: 0; }
.skill .name { font-weight: 650; overflow-wrap: anywhere; }
.skill .core { font-size: .72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; margin-left: .35rem; }
.skill .pt { color: var(--muted); font-size: .88rem; }
.skill .from { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); }
.skill .from b { font-weight: 600; color: var(--text); }
.skill .side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.skill button { padding: .2rem .55rem; font-size: .82rem; }

.band { display: inline-block; font-size: .74rem; font-weight: 600; padding: .05rem .5rem; border-radius: 99px; white-space: nowrap; }
.b-muito-comum { color: var(--b1); background: var(--b1-bg); }
.b-comum { color: var(--b2); background: var(--b2-bg); }
.b-nicho { color: var(--b3); background: var(--b3-bg); }
.b-rara { color: var(--b4); background: var(--b4-bg); }
.legend { font-size: .8rem; color: var(--muted); margin: .75rem 0 0; }
.legend .band { margin-right: .15rem; }

.howto { margin-top: 1rem; font-size: .9rem; border-top: 1px solid var(--border); padding-top: .6rem; }
.howto summary { cursor: pointer; font-weight: 600; }
.foot { padding-bottom: 32px; font-size: .82rem; }
.foot a, .legend a { color: var(--accent); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s; background: var(--text); color: var(--bg); padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .results-inner { position: static; max-height: none; }
  .results { order: -1; }
  .tools input { width: 100%; }
  .tools { width: 100%; }
}
