/* Đồ thị, hình học (/cong-cu/do-thi). Tệp nạp ở mọi trang → mọi lớp có tiền tố dth-. Ưu tiên màn chiếu 1280–1920px. */
.chinh:has(> .dth) { max-width: 1600px; }
.dth:fullscreen { background: var(--bg); padding: 16px clamp(12px, 2vw, 28px); overflow: auto; }
.dth-an-chu { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: 0; }
.dth-dau { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.dth-dau h1 { margin: 0; }
.dth-dau .phu { margin: 2px 0 0; }
.dth-h { font-size: 1rem; margin: 0 0 8px; }

/* Thẻ */
.dth-tab { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.dth-tab [role="tab"] { flex: none; min-height: 46px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--vien); background: var(--the);
  color: var(--chu); font: inherit; font-weight: 700; cursor: pointer; }
.dth-tab [role="tab"]:hover { border-color: var(--c-vien); color: var(--c-dam); }
.dth-tab [role="tab"][aria-selected="true"] { background: var(--c-dam); border-color: var(--c-dam); color: #fff; }

/* Bảng vẽ JSXGraph */
.dth-bang { width: 100%; max-width: 100%; height: clamp(380px, 66vh, 820px); background: #fff; border: 1px solid var(--vien); border-radius: var(--r); overflow: hidden; touch-action: none; }
.dth:fullscreen .dth-bang { height: calc(100vh - 190px); }
.dth-bang[data-cc]:not([data-cc="chon"]) { cursor: crosshair; }
.dth-bang .JXGtext { font-family: var(--font); }

/* Đồ thị hàm số */
.dth-khung { display: grid; gap: 14px; align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .dth-khung { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); } }
.dth-ben { margin: 0; padding: 14px; }
.dth-ham { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.dth-ham__muc { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 6px;
  border-left: 5px solid var(--dth-mau, var(--c)); padding-left: 8px; }
.dth-ham__hien { width: 20px; height: 20px; accent-color: var(--dth-mau, var(--c)); margin: 0; }
.dth-ham__y { font-weight: 700; color: var(--dth-mau, var(--c)); white-space: nowrap; }
.dth-ham__o { min-width: 0; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid #cfd6d1; border-radius: var(--r-nho);
  font: inherit; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; background: #fff; color: var(--chu); }
.dth-ham__o:focus { border-color: var(--c); outline: 3px solid var(--c-nhat); }
.dth-ham__xoa { width: 40px; height: 40px; color: var(--phu); }
.dth-ham__loi { grid-column: 3 / -1; }
.dth-ham__loi:empty { display: none; }
.dth-goi-y { margin: 10px 0 12px; }
.dth-goi-y code, .dth .field__hint code { background: var(--c-nhat); color: var(--c-dam); padding: 0 4px; border-radius: 4px; }
.dth-ts { display: grid; gap: 10px; margin-bottom: 12px; }
.dth-ts__dong { display: grid; grid-template-columns: 5.5em minmax(0, 1fr); align-items: center; gap: 4px 10px; }
.dth-ts__ten { font-weight: 700; font-variant-numeric: tabular-nums; }
.dth-ts__dong input[type="range"] { width: 100%; accent-color: var(--c); min-height: 32px; }
.dth-ts__khoang { grid-column: 2; display: flex; align-items: center; gap: 6px; font-size: .8125rem; color: var(--phu); }
.dth-ts__bien { width: 5.5em; min-height: 34px; padding: 4px 8px; border: 1px solid #cfd6d1; border-radius: var(--r-nho); font: inherit; font-size: .875rem; background: #fff; }
.dth-chon { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; min-height: 36px; }
.dth-chon input { width: 20px; height: 20px; accent-color: var(--c); margin: 0; }
.dth-diem { list-style: none; margin: 6px 0 0; padding: 0; font-size: .9375rem; max-height: 280px; overflow: auto; }
.dth-diem li { padding: 3px 0; font-variant-numeric: tabular-nums; }
.dth-diem__cham { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.dth-thu-phong { margin-top: 8px; }
.dth-gt { margin-top: 14px; }
.dth-gt summary { cursor: pointer; font-weight: 700; font-size: 1.05rem; }
.dth-gt__chon { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.dth-gt__chon .field { width: 130px; }
.dth-gt__cuon { overflow-x: auto; }
.dth-gt__bang { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.dth-gt__bang th, .dth-gt__bang td { border: 1px solid var(--vien); padding: 6px 10px; text-align: center; white-space: nowrap; }
.dth-gt__bang th { text-align: left; background: var(--bg); max-width: 22em; overflow: hidden; text-overflow: ellipsis; }

/* Hình học: thanh công cụ */
.dth-cc { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; }
.dth-cc__nhom { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.dth-cc__ten { font-size: .75rem; font-weight: 700; color: var(--phu); text-transform: uppercase; letter-spacing: .05em; margin-right: 2px; }
.dth-cc button { min-height: 40px; padding: 6px 12px; border-radius: var(--r-nho); border: 1px solid var(--vien); background: var(--the);
  color: var(--chu); font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer; }
.dth-cc button:hover { border-color: var(--c-vien); color: var(--c-dam); }
.dth-cc button[aria-pressed="true"] { background: var(--c-dam); border-color: var(--c-dam); color: #fff; }
.dth-huong { min-height: 1.6em; margin: 0 0 8px; color: var(--c-dam); font-weight: 600; }
.dth-hinh-duoi { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; margin-top: 10px; }
.dth-mau { min-width: 280px; }
.dth-bao-noi { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); margin: 0; }

/* Hình học không gian */
.dth-kg-mt { margin: 10px 0 14px; font-size: .9375rem; line-height: 1.55; }
.dth-kg-ts__dong { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.dth-kg-ts__dong .dth-ts__ten { font-weight: 600; }
.dth-kg-tt { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 0 0 12px; font-variant-numeric: tabular-nums; }
.dth-kg-tt dt { font-size: .8125rem; color: var(--phu); margin-top: 8px; }
.dth-kg-tt dd { margin: 0; font-weight: 700; color: var(--c-dam); overflow-wrap: anywhere; }
.dth-kg-chon { display: grid; gap: 2px; border-top: 1px solid var(--vien); padding-top: 8px; }
.dth-bang--kg { cursor: grab; }
.dth-bang--kg .dth-kg-nhan { paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; font-weight: 600; }
.dth-bang--kg:active { cursor: grabbing; }
.dth-bang--kg svg :focus { outline: none; }
#dth-kg-xoay[aria-pressed="true"] { background: var(--c-dam); border-color: var(--c-dam); color: #fff; }

/* Máy tính */
.dth-may { display: grid; gap: 14px; align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .dth-may { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.dth-may .the { margin: 0; }
.dth-mt__o { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.25rem !important; min-height: 54px !important; }
.dth-mt__kq { min-height: 2.6em; margin: 10px 0; font-size: clamp(1.4rem, 2.6vw, 2.2rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--c-dam); }
.dth-mt__kq span { color: var(--nhan-dam); font-weight: 700; }
.dth-mt__kq--loi { font-size: 1rem; color: var(--do); }
.dth-mt__dong { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dth-goc { border: 0; margin: 0; padding: 0; display: flex; gap: 14px; }
.dth-goc label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; min-height: 40px; }
.dth-goc input { width: 18px; height: 18px; accent-color: var(--c); }
.dth-phim { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 14px 0 10px; }
.dth-phim button { min-height: 46px; border-radius: var(--r-nho); border: 1px solid var(--vien); background: var(--bg); color: var(--chu);
  font: inherit; font-weight: 700; cursor: pointer; }
.dth-phim button:hover { background: var(--c-nhat); color: var(--c-dam); border-color: var(--c-vien); }
.dth-ls__ds { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.dth-ls__muc { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--vien);
  background: none; font: inherit; color: var(--chu); cursor: pointer; }
.dth-ls__muc:hover { background: var(--c-nhat); }
.dth-ls__bt { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--phu); font-size: .9375rem; }
.dth-ls__kq { font-weight: 700; color: var(--c-dam); font-variant-numeric: tabular-nums; }
.dth-gpt h2 { font-size: 1.05rem; }
.dth-pt { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dth-pt__mau { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: 1.1rem; font-weight: 600; width: 100%; }
.dth-pt__mau input { width: 5.2em; min-height: 42px; padding: 6px 8px; border: 1px solid #cfd6d1; border-radius: var(--r-nho); font: inherit; text-align: center; background: #fff; }
.dth-pt__kq { margin-top: 10px; font-variant-numeric: tabular-nums; }
.dth-pt__kq p { margin: 0 0 4px; }
.dth-pt__kq p:last-child { font-weight: 700; color: var(--c-dam); }

@media (max-width: 640px) {
  .dth-bang { height: 62vh; min-height: 340px; }
  .dth-cc { gap: 6px 10px; }
  .dth-cc button { min-height: 38px; padding: 5px 9px; font-size: .875rem; }
  .dth-phim { grid-template-columns: repeat(4, 1fr); }
  .dth-mau { min-width: 0; width: 100%; }
  .dth-pt__mau { font-size: 1rem; gap: 4px; }
  .dth-pt__mau input { width: 3.8em; padding: 6px 4px; }
}
