/* ألوان هادئة ومريحة للعين، وخطوط النظام فقط (لا خطوط خارجية) */
:root {
  --bg: #f1f6f7;
  --card: #ffffff;
  --text: #22323a;
  --muted: #5d7079;
  --line: #d3e1e4;
  --primary: #2e7d86;
  --primary-dark: #236a72;
  --primary-soft: #e4f1f2;
  --danger: #a73d36;
  --danger-soft: #fbecea;
  --ok: #2d7650;
  --font: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.8;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.head { text-align: center; margin-bottom: 20px; }
.head h1 { margin: 0 0 6px; font-size: clamp(26px, 5vw, 34px); color: var(--primary-dark); }
.sub { margin: 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-title { margin: 0 0 14px; font-size: 20px; }

.dropzone {
  border: 2px dashed #9cc3c7;
  background: var(--primary-soft);
  border-radius: 16px;
  padding: 28px 16px;
  text-align: center;
  transition: background .15s, border-color .15s;
}
.dropzone.is-over { background: #cfe7e9; border-color: var(--primary); }
.drop-main { margin: 0; font-size: 19px; font-weight: 600; }
.drop-or { margin: 4px 0 10px; color: var(--muted); }
.drop-hint { margin: 14px auto 0; max-width: 46ch; color: var(--muted); font-size: 15px; }

.btn {
  font: inherit;
  min-height: 48px;
  padding: 8px 22px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn:focus-visible, .dropzone:focus-within { outline: 3px solid #f0b429; outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }

.busy { margin: 14px 0 0; color: var(--muted); }
.error {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #efc5c1;
  font-weight: 600;
}

.canvas-wrap {
  background: #e9f0f1;
  border-radius: 14px;
  padding: 8px;
  text-align: center;
  overflow: auto;
}
.canvas-wrap.zoomed { max-height: 75vh; }
.canvas-wrap.zoomed .stack { max-width: none; cursor: grab; }
.canvas-wrap.zoomed #preview { max-width: none; width: 100%; }
.canvas-wrap.pixelated canvas { image-rendering: pixelated; }
.canvas-wrap.smooth canvas { image-rendering: auto; }
.stack { user-select: none; -webkit-user-select: none; }
.stack.tool, .canvas-wrap.zoomed .stack { touch-action: none; }
.zoom-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.btn-sm { min-height: 40px; padding: 4px 14px; width: auto; }
.check-inline { margin: 0; margin-inline-start: 12px; }
.view-label { font-weight: 600; }
.healthy-only { display: none; }
.type-note { margin: 8px 0 0; font-weight: 600; color: var(--primary-dark); }
.type-note.warn { color: #9a5b00; }
.type-note.ask { color: var(--danger); }
#analysis.healthy .healthy-only { display: revert; }
#analysis.healthy .plaque-only { display: none !important; }
.jaw-table-wrap { overflow-x: auto; margin: 4px 0 12px; }
.jaw-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.jaw-table th, .jaw-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.jaw-table th { background: var(--primary-soft); }
.jaw-table tr.total td { font-weight: 700; background: var(--bg); }
.stain-box { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.stain-box .clean-note { margin: 6px 0 0; }
.view-select { font: inherit; min-height: 40px; padding: 4px 10px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.zoom-label { color: var(--muted); font-weight: 600; min-width: 4em; }
.stack { position: relative; display: inline-block; max-width: 100%; line-height: 0; vertical-align: middle; }
#preview { max-width: 100%; height: auto; border-radius: 8px; display: block; }
.picking { cursor: crosshair; }
.sample-box { margin: 0 0 14px; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; pointer-events: none; }

.info { margin: 12px 0 4px; color: var(--ok); font-weight: 600; }
.clean-note { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.result-box { text-align: center; background: var(--primary-soft); border-radius: 14px; padding: 14px 12px; margin-bottom: 14px; }
.result-label { margin: 0; color: var(--muted); }
.result-percent { margin: 0; font-size: clamp(36px, 9vw, 56px); font-weight: 700; color: var(--primary-dark); line-height: 1.3; }
.result-counts { margin: 0; color: var(--muted); font-size: 15px; }

.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; }
.legend { list-style: none; margin: 0 0 12px; padding: 0; color: var(--muted); font-size: 15px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-inline-end: 4px; }
.swatch-tooth { background: #28aa5a; }
.swatch-plaque { background: #dc3228; }
.formula { margin: 0 0 14px; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: 15px; color: var(--text); }

.groups { display: grid; gap: 14px; margin-bottom: 8px; }
@media (min-width: 720px) { .groups { grid-template-columns: 1fr 1fr; } }
.group { border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px 12px; margin: 0; min-width: 0; }
.group legend { padding: 0 8px; font-weight: 600; }
.slider-row { display: grid; grid-template-columns: 8.5em 1fr 3em; align-items: center; gap: 10px; margin-top: 6px; }
.slider-row label { font-size: 15px; }
.slider-row input[type="range"] { width: 100%; direction: ltr; accent-color: var(--primary); }
.slider-value { text-align: center; font-variant-numeric: tabular-nums; color: var(--primary-dark); font-weight: 600; }
@media (max-width: 480px) { .slider-row { grid-template-columns: 7em 1fr 2.6em; gap: 6px; } }

.engine { margin: 0 0 8px; text-align: center; color: var(--muted); font-size: 14px; }
.engine.ok { color: var(--ok); }
.engine.fail { color: var(--danger); }

.foot { text-align: center; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.foot p { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .card { padding: 16px; }
  .dropzone { padding: 22px 12px; }
  .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .dropzone { transition: none; }
}
