/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-ui); font-size: 0.98rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #34508f; border-color: #34508f; }
.btn-lg { min-height: 52px; padding: 12px 26px; font-size: 1.05rem; letter-spacing: 0.03em; }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: 0.9rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font: inherit; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-soft { background: var(--surface-2); box-shadow: none; }
.card h3 { margin-bottom: 4px; }
.card-kicker {
  font-family: var(--font-ui); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.card-title { font-size: 1.45rem; margin: 6px 0 2px; }
.card-sub { color: var(--muted); margin-bottom: 10px; }
.card hr, .rule { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.hw-card { display: flex; flex-direction: column; }
.hw-card .explain { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 10px; }
.hw-card .explain p:last-child { margin-bottom: 0; }
.hw-card .card-actions { margin-top: auto; padding-top: 14px; }

.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.facts li { display: flex; gap: 10px; justify-content: space-between; border-bottom: 1px dashed var(--line); padding-bottom: 6px; margin: 0; }
.facts li:last-child { border-bottom: 0; }
.facts .k { color: var(--muted); white-space: nowrap; }
.facts .v { text-align: right; font-weight: 600; }
.facts .v.unknown { font-weight: 400; color: var(--muted); font-style: italic; }

/* ---------- Ô thông số điền tại chỗ ---------- */
.fill-btn {
  font-family: var(--font-ui); font-size: 0.88rem; font-weight: 600; cursor: pointer;
  min-height: 36px; padding: 6px 12px; border-radius: 999px;
  border: 1px dashed #d9c27a; background: var(--butter); color: var(--butter-ink);
}
.fill-btn:hover { border-style: solid; filter: brightness(0.97); }
.edit-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  min-width: 32px; min-height: 32px; border-radius: 50%; font-size: 0.95rem; vertical-align: middle;
}
.edit-btn:hover { background: var(--accent-soft); color: var(--accent); }
.facts li.editing { flex-direction: column; align-items: stretch; }
.facts li.editing .v { text-align: left; font-weight: 400; }
.inline-edit { display: grid; gap: 8px; margin-top: 4px; }
.inline-error { color: var(--rose-ink); }
.fill-host { width: 100%; }
.wl-open { padding: 12px 14px; border-style: dashed; }
.wl-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; }
.wl-head .meter { grid-column: 1 / -1; }
.wl-fill { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.wl-fill .fill-host { flex-basis: 100%; }
.missing-box { background: var(--butter); border: 1px solid #eedfa6; border-radius: var(--radius-sm); padding: 12px 14px; }
.missing-box h3 { font-size: 1.1rem; margin-bottom: 2px; }
.missing-box .facts li { border-bottom-color: #e9d9a0; }
.missing-box .fill-btn { background: var(--surface); }

/* ---------- Chips / badges ---------- */
.chip {
  font-family: var(--font-ui); font-size: 0.82rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
.chip-mint { background: var(--mint); color: var(--mint-ink); }
.chip-peach { background: var(--peach); color: var(--peach-ink); }
.chip-butter { background: var(--butter); color: var(--butter-ink); }
.chip-lilac { background: var(--lilac); color: var(--lilac-ink); }
.chip-rose { background: var(--rose); color: var(--rose-ink); }
.chip-sky { background: var(--sky); color: var(--sky-ink); }
.chip-plain { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
a.chip { text-decoration: none; }
a.chip:hover { filter: brightness(0.96); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.conf-certain { background: var(--mint); color: var(--mint-ink); }
.conf-likely { background: var(--sky); color: var(--sky-ink); }
.conf-confirm { background: var(--butter); color: var(--butter-ink); }
.conf-unused { background: var(--rose); color: var(--rose-ink); }

/* ---------- Notices ---------- */
.notice { border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; border: 1px solid transparent; }
.notice p:last-child, .notice ul:last-child { margin-bottom: 0; }
.notice-info { background: var(--sky); border-color: #c9def0; }
.notice-warn { background: var(--butter); border-color: #eedfa6; }
.notice-ask { background: var(--lilac); border-color: #d9cff0; }
.notice-bad { background: var(--rose); border-color: #efc7cd; }
.notice h4 { margin-bottom: 6px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-family: var(--font-ui); font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.textarea { resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 26px 0 8px; }
.hero h1 { margin-bottom: 10px; }
.hero .lead { color: var(--muted); max-width: 640px; margin: 0 auto 22px; }
.hero-input {
  max-width: 820px; margin: 0 auto; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 14px;
}
.hero-input .textarea { min-height: 150px; font-size: 1.08rem; border: 0; padding: 8px 10px; }
.hero-input .textarea:focus { box-shadow: none; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.examples { max-width: 820px; margin: 14px auto 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.examples button {
  font-family: var(--font-ui); font-size: 0.82rem; border: 1px dashed var(--line); background: transparent;
  border-radius: 999px; padding: 8px 12px; min-height: 36px; cursor: pointer; color: var(--muted);
}
.examples button:hover { border-color: var(--accent); color: var(--accent); }

.steps { counter-reset: step; }
.step { position: relative; padding-left: 52px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--font-ui); font-weight: 700;
  background: var(--lilac); color: var(--lilac-ink);
}

/* ---------- Summary ---------- */
.summary-card { display: grid; gap: 14px; }
.summary-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.summary-head h2 { margin: 0; }
.conf-grid { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Workload rows ---------- */
.wl-list { display: grid; gap: 10px; }
.wl {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.wl > summary {
  list-style: none; cursor: pointer; padding: 12px 14px; min-height: 52px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center;
}
.wl > summary::-webkit-details-marker { display: none; }
.wl-name { font-weight: 700; }
.wl-label { font-family: var(--font-ui); font-weight: 700; font-size: 0.92rem; text-align: right; }
.wl .meter { grid-column: 1 / -1; }
.wl-body { padding: 0 14px 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
.wl-body h4 { font-family: var(--font-ui); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 0 4px; }
.wl[open] > summary { background: var(--surface-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

/* ---------- Meter ---------- */
.meter { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.meter span { height: 10px; border-radius: 4px; background: #ece9e1; }
.meter[data-level="0"] span:nth-child(-n+1) { background: var(--lv0); }
.meter[data-level="1"] span:nth-child(-n+2) { background: var(--lv1); }
.meter[data-level="2"] span:nth-child(-n+3) { background: var(--lv2); }
.meter[data-level="3"] span:nth-child(-n+4) { background: var(--lv3); }
.meter[data-level="4"] span:nth-child(-n+5) { background: var(--lv4); }
.meter[data-level="5"] span:nth-child(-n+6) { background: var(--lv5); }
.meter span.range { background: repeating-linear-gradient(45deg, #e6e2d8 0 4px, #f3f1ea 4px 8px) !important; }
.meter[data-level="na"] span { background: repeating-linear-gradient(45deg, #ece9e1 0 4px, #f6f4ee 4px 8px); }
.lv-0 { color: var(--rose-ink); } .lv-1 { color: var(--peach-ink); } .lv-2 { color: var(--butter-ink); }
.lv-3, .lv-4 { color: var(--mint-ink); } .lv-5 { color: var(--sky-ink); } .lv-na { color: var(--muted); }

/* ---------- Bullet lists ---------- */
.plus-list, .minus-list { list-style: none; padding: 0; }
.plus-list li, .minus-list li { position: relative; padding-left: 30px; margin-bottom: 10px; }
.plus-list li::before, .minus-list li::before {
  position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--font-ui); font-size: 0.8rem; font-weight: 700;
}
.plus-list li::before { content: "+"; background: var(--mint); color: var(--mint-ink); }
.minus-list li::before { content: "!"; background: var(--peach); color: var(--peach-ink); }

/* ---------- Ladder ---------- */
.ladder { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; max-width: 560px; }
.ladder li { margin: 0; display: grid; grid-template-columns: 1fr; justify-items: start; }
.rung {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 10px 14px;
}
.rung-name { font-weight: 700; }
.rung.mine { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.rung .mine-tag { font-family: var(--font-ui); font-weight: 700; color: var(--accent); font-size: 0.9rem; }
.ladder .arrow { color: var(--muted); padding: 2px 0 2px 18px; font-size: 1rem; line-height: 1.2; }
.ladder-note { margin-top: 14px; }

.series-list { display: flex; flex-wrap: wrap; gap: 8px; }
.series-list a {
  font-family: var(--font-ui); font-size: 0.9rem; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 14px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
}
.series-list a:hover { border-color: var(--accent); }
.series-list a.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.series-list a.has-mine::after { content: "●"; color: var(--accent); font-size: 0.7rem; }
.series-list a.active.has-mine::after { color: #fff; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 16px; }
.tabs button {
  font-family: var(--font-ui); font-size: 0.92rem; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
}
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Lessons ---------- */
.lesson-card { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px; }
.lesson-card:hover { border-color: var(--accent); }
.lesson-num { font-family: var(--font-ui); font-size: 0.8rem; font-weight: 700; color: var(--lilac-ink); }
.personal {
  background: var(--lilac); color: var(--lilac-ink); border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0 14px;
}
.personal strong { font-family: var(--font-ui); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.lesson-body { max-width: 72ch; }
.lesson-body p { font-size: 1.08rem; }

.quiz { display: grid; gap: 14px; max-width: 72ch; }
.quiz fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); margin: 0; }
.quiz legend { font-weight: 700; padding: 0 4px; }
.quiz label { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.quiz label:hover { background: var(--surface-2); }
.quiz input[type="radio"] { width: 20px; height: 20px; accent-color: var(--accent); }
.quiz .feedback { margin-top: 6px; font-size: 0.98rem; }
.quiz .right { color: var(--mint-ink); }
.quiz .wrong { color: var(--rose-ink); }
.progress-bar { height: 8px; background: #ece9e1; border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--lv4); }

/* ---------- Glossary ---------- */
.term, .rung.mine { scroll-margin-top: 150px; }
.term { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.term > summary { cursor: pointer; padding: 12px 14px; list-style: none; min-height: 52px; }
.term > summary::-webkit-details-marker { display: none; }
.term-title { font-weight: 700; font-size: 1.1rem; }
.term-full { color: var(--muted); font-size: 0.95rem; }
.term-quick { display: block; color: var(--ink); }
.term-body { padding: 4px 14px 14px; border-top: 1px dashed var(--line); }
.term-body h4 { font-family: var(--font-ui); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 0 4px; }
.term[open] { border-color: var(--accent); }

/* ---------- Compare ---------- */
.slots { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.slot .textarea { min-height: 130px; }
.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.slot-letter {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-ui); font-weight: 700; background: var(--accent); color: #fff;
}
.cmp-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.cmp-row { padding: 14px 16px; }
.cmp-row h4 { margin-bottom: 8px; }
.cmp-cells { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.cmp-cell { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; background: var(--surface-2); }
.cmp-cell.win { border-color: #8fc7a8; background: var(--mint); }
.cmp-cell .who { font-family: var(--font-ui); font-weight: 700; font-size: 0.85rem; color: var(--muted); }
.cmp-cell.win .who::after { content: " · tốt hơn"; color: var(--mint-ink); }
.machine-col h3 { display: flex; align-items: center; gap: 10px; }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; border-radius: 18px; padding: 0; width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); color: var(--ink); background: var(--surface);
}
dialog.modal::backdrop { background: rgba(38, 40, 58, 0.45); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 1.35rem; flex: 1; }
.modal-close { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1.3rem; line-height: 1; }
.modal-body { padding: 16px 20px 22px; overflow: auto; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-family: var(--font-ui); font-size: 0.95rem;
  box-shadow: var(--shadow);
}
