/* Grafični kalkulator (public/graph/). Barve krivulj so podatkovne barve (kot pri simulacijah),
   zato so tu kot spremenljivke s svetlo in temno različico. Vse ostalo uporablja barve aplikacije. */
:root {
  --g-red: #c74440; --g-blue: #2d70b3; --g-green: #388c46; --g-purple: #6042a6;
  --g-orange: #d9650b; --g-black: #1f2937; --g-teal: #0e8a8a; --g-pink: #c2367f;
}
:root.dark {
  --g-red: #ff7d75; --g-blue: #6fabff; --g-green: #62d474; --g-purple: #b9a2ff;
  --g-orange: #ffad5e; --g-black: #e5e7eb; --g-teal: #4fd6c9; --g-pink: #f37fbd;
}

/* pogled: kalkulator zapolni prostor med zgornjo in spodnjo vrstico */
#view-graph { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#view-graph[hidden] { display: none !important; }
#view-graph .me-back { margin: 6px 10px 0; align-self: flex-start; }
.graph-slot { flex: 1; min-height: 0; display: flex; }

.gc {
  --gc-panel: 380px;
  position: relative; flex: 1; min-height: 0; min-width: 0;
  display: grid; grid-template-columns: var(--gc-panel) 1fr; grid-template-rows: 1fr auto;
  background: var(--bg);
}
.gc-panel {
  grid-row: 1 / 3; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.gc-stage { position: relative; min-height: 0; min-width: 0; display: flex; overflow: hidden; }
.gc-graph { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.gc-canvas { position: absolute; inset: 0; display: block; cursor: crosshair; outline: none; }
.gc-canvas.dragging { cursor: grabbing; }
.gc-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.gc-tip { position: absolute; pointer-events: none; }

/* orodna vrstica nad seznamom */
.gc-bar { display: flex; align-items: center; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.gc-bar-sp { flex: 1; }
.gc .gc-btn {
  min-height: 40px; min-width: 40px; padding: 6px 8px; border-radius: 10px; border: 0; background: none;
  color: var(--text); font-weight: 800; font-size: 0.88rem; gap: 6px;
}
.gc .gc-btn:hover:not(:disabled) { background: var(--surface-2); }
.gc .gc-btn:disabled { opacity: 0.35; cursor: default; }
.gc .gc-btn svg.i { width: 20px; height: 20px; }
.gc .gc-btn[data-act="add"] { background: var(--accent); color: var(--accent-text); }
.gc .gc-btn[data-act="add"]:hover { filter: brightness(1.06); background: var(--accent); }
.gc-text-btn { white-space: nowrap; }
.gc .gc-playall { color: var(--accent); background: var(--accent-soft); }
.gc .gc-playall:hover:not(:disabled) { background: var(--accent-soft); filter: brightness(0.97); }
.gc .gc-playall[hidden] { display: none; }
/* ob gumbu »Predvajaj vse« je vrstica polna: »Moji grafi« ostane samo ikona */
.gc-bar:has(.gc-playall:not([hidden])) [data-act="graphs"] span { display: none; }
.gc-text-btn svg.i { color: var(--accent); }

/* seznam izrazov */
.gc-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.gc-row {
  position: relative; display: grid; grid-template-columns: 44px 1fr auto; align-items: start;
  border-bottom: 1px solid var(--border); background: var(--surface); min-height: 56px;
}
.gc-row.selected, .gc-row.editing { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.gc-row.editing { box-shadow: inset 3px 0 0 var(--accent); }
.gc-side { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0 6px; background: var(--surface-2); align-self: stretch; }
.gc-num { font-size: 0.7rem; font-weight: 800; color: var(--muted); }
.gc .gc-dot {
  width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 50%;
  border: 2.5px solid var(--c); background: var(--c); color: var(--surface);
}
.gc .gc-dot svg.i { width: 15px; height: 15px; }
.gc-row:not(.plotted) .gc-dot { visibility: hidden; }
.gc-row.hidden-item .gc-dot { background: transparent; color: var(--c); }
.gc-row.hidden-item .gc-math, .gc-row.hidden-item .gc-input { opacity: 0.6; }
.gc-main { min-width: 0; padding: 6px 4px 6px 10px; }
.gc-math {
  min-height: 44px; display: flex; align-items: center; font-size: 1.12rem; overflow-x: auto; overflow-y: hidden;
  cursor: text; scrollbar-width: thin; padding: 2px 0;
}
.gc-input {
  width: 100%; min-height: 44px; border: 0; background: transparent; outline: none; padding: 6px 2px;
  font-size: 1.05rem; font-weight: 700; letter-spacing: 0.01em; color: var(--text);
}
.gc-input::placeholder { color: var(--muted); font-weight: 600; }
.gc-row:not(.editing):not(.empty) .gc-input { display: none; }
.gc-row.editing .gc-math, .gc-row.empty .gc-math { display: none; }
.gc-preview { display: none; font-size: 0.95rem; color: var(--muted); overflow-x: auto; padding: 0 2px 2px; }
.gc-row.editing .gc-preview:not(:empty) { display: block; }
.gc-note .gc-input { display: block !important; resize: none; font-weight: 600; font-size: 0.98rem; color: var(--muted); font-style: italic; overflow: hidden; }
.gc-note .gc-side { background: none; }
.gc-acts { display: flex; align-items: center; padding: 6px 2px 0 0; }
.gc .gc-x { min-height: 36px; min-width: 36px; padding: 6px; border: 0; background: none; color: var(--muted); border-radius: 10px; }
.gc .gc-x:hover { background: var(--surface-2); color: var(--text); }
.gc-row:not(:hover):not(.editing):not(.selected) .gc-acts .gc-x[data-act="del"] { opacity: 0; }
@media (hover: none) { .gc-row .gc-acts .gc-x[data-act="del"] { opacity: 1 !important; } }

.gc-extra:empty { display: none; }
.gc-extra { display: grid; gap: 6px; padding: 0 2px 4px; }
.gc-val { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); overflow-x: auto; font-size: 1rem; }
.gc-val svg.i { color: var(--muted); }
.gc-deriv { color: var(--muted); font-weight: 700; }
.gc-err { display: flex; gap: 6px; align-items: flex-start; color: var(--danger); font-weight: 700; font-size: 0.88rem; line-height: 1.35; }
.gc-err svg.i { margin-top: 2px; }
.gc .gc-chip {
  justify-self: start; min-height: 36px; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem;
  border: 1.5px solid var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 800;
}

/* drsnik */
.gc-slider { display: grid; grid-template-columns: 40px 52px 1fr 52px; align-items: center; gap: 6px; }
.gc .gc-play { width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%; border: 0; background: var(--accent-soft); color: var(--accent); }
.gc .gc-play svg.i { width: 18px; height: 18px; }
.gc-lim {
  width: 100%; min-width: 0; font-size: 0.82rem; font-weight: 700; text-align: center; color: var(--muted);
  border: 1px solid transparent; border-radius: 8px; background: none; padding: 4px 2px; min-height: 32px;
}
.gc-lim:hover, .gc-lim:focus { border-color: var(--border); outline: none; color: var(--text); background: var(--bg); }
.gc-range { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; }
.gc-domain { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.gc-domain .gc-lim { width: 64px; flex: none; }

/* tabela */
.gc-tbl { overflow-x: auto; padding: 6px 0 2px; }
.gc-table { border-collapse: collapse; font-size: 0.95rem; }
.gc-table th, .gc-table td { border: 1px solid var(--border); padding: 0; }
.gc-table th { background: var(--surface-2); }
.gc-cell { width: 86px; min-height: 36px; border: 0; background: transparent; padding: 6px 8px; font-weight: 700; text-align: right; outline: none; }
.gc-cell.gc-head { text-align: center; font-weight: 800; }
.gc-cell:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); }
.gc-cell[readonly] { color: var(--muted); }
.gc-reg { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.gc-reg-pick { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.88rem; }
.gc-fit { flex-wrap: wrap; }
.gc-r2 { color: var(--muted); font-weight: 700; }
.gc-check { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.92rem; min-height: 36px; cursor: pointer; }
.gc-check input { width: 18px; height: 18px; accent-color: var(--accent); }

.gc-help { padding: 10px 14px 14px; margin: 0; font-size: 0.85rem; line-height: 1.45; }
.gc-list:has(.gc-row:nth-child(4)) + .gc-help { display: none; }

/* gumbi na grafu */
.gc-zoom { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.gc .gc-fab {
  width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow);
}
.gc .gc-fab:hover { border-color: var(--accent); color: var(--accent); }
.gc .gc-fab svg.i { width: 19px; height: 19px; }
.gc .gc-expand { position: absolute; left: 10px; top: 10px; z-index: 2; display: none; }

/* pojavni meni */
.gc-pop {
  position: absolute; z-index: 30; max-height: min(70vh, 560px); overflow-y: auto; padding: 8px;
  background: var(--menu, var(--surface)); color: var(--menu-text, var(--text)); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.gc-pop-wide { width: 360px; }
.gc-pop-h { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 6px 4px; }
.gc-pop-sep { height: 1px; background: var(--border); margin: 6px 0; }
.gc .gc-menu-row {
  display: flex; width: 100%; justify-content: flex-start; gap: 10px; min-height: 44px; padding: 8px 10px;
  border: 0; background: none; border-radius: 10px; font-weight: 700; text-align: left; color: inherit;
}
.gc .gc-menu-row:hover { background: var(--surface-2); }
.gc .gc-menu-row svg.i { color: var(--muted); }
.gc .gc-menu-row[aria-pressed="true"] svg.i { color: var(--accent); }
.gc .gc-menu-row.danger { color: var(--danger); }
.gc .gc-menu-row.danger svg.i { color: var(--danger); }
.gc-swatches, .gc-styles { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 6px 6px; }
.gc .gc-swatch { width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--border); }
.gc .gc-swatch.on { box-shadow: 0 0 0 2.5px var(--accent); }
.gc .gc-ls { width: 60px; min-height: 38px; padding: 0 10px; }
.gc .gc-ls.on { border-color: var(--accent); background: var(--accent-soft); }
.gc-ls span { display: block; width: 100%; border-top: 3px solid var(--text); }
.gc-ls .ls-dash { border-top-style: dashed; }
.gc-ls .ls-dot { border-top-style: dotted; }
.gc-ex-list { display: grid; grid-template-columns: 1fr; gap: 4px; }
.gc .gc-ex { display: flex; justify-content: flex-start; gap: 10px; min-height: 48px; border: 0; background: none; border-radius: 10px; padding: 6px 8px; text-align: left; overflow-x: auto; }
.gc .gc-ex:hover { background: var(--surface-2); }
.gc-ex-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; }
.gc-ex-tex { font-size: 1rem; }
.gc-save-row { display: flex; gap: 8px; padding: 4px 4px 8px; }
.gc-save-row input { flex: 1; min-width: 0; min-height: 40px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg); padding: 6px 10px; font-weight: 700; }
.gc-saved-row { display: flex; align-items: center; gap: 4px; }
.gc .gc-saved-open { flex: 1; min-width: 0; display: flex; justify-content: flex-start; gap: 10px; border: 0; background: none; padding: 6px; border-radius: 10px; text-align: left; }
.gc .gc-saved-open:hover { background: var(--surface-2); }
.gc-saved-open img, .gc-thumb-empty { width: 64px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: none; display: grid; place-items: center; color: var(--muted); }
.gc-saved-open span { display: flex; flex-direction: column; min-width: 0; }
.gc-saved-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-seg { margin: 4px 6px 8px; }
.gc-win { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 2px 6px 6px; }
.gc-win input { width: 100%; min-height: 38px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--bg); padding: 4px 8px; font-weight: 700; }
.gc-win4 label { display: flex; align-items: center; gap: 6px; }

/* tipkovnica (telefon in tablica; na računalniku po izbiri) */
.gc-keypad {
  grid-column: 2; background: var(--surface-2); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); user-select: none; -webkit-user-select: none;
}
.gc-keypad[hidden] { display: none; }
.gc-kp-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.gc-kp-top .chip-row { flex: 1; }
.gc-kp-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.gc .gc-key {
  min-height: 44px; padding: 2px; border-radius: 10px; border: 0; background: var(--surface); color: var(--text);
  font-weight: 800; font-size: 1rem; box-shadow: 0 1px 0 var(--border); touch-action: manipulation; white-space: nowrap; overflow: hidden;
}
.gc .gc-key.num { background: var(--bg); font-size: 1.12rem; }
.gc .gc-key:active { background: var(--accent-soft); }
.gc .gc-key.enter { background: var(--accent); color: var(--accent-text); }
.gc-kp-nav { display: grid; grid-template-columns: 1fr 1fr 1fr 2fr; gap: 5px; margin-top: 5px; }
.gc-kp-sym .sym-keys { max-height: 190px; overflow-y: auto; }

/* odprt iz naloge ali inštruktorja: čez cel zaslon */
.graph-overlay { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--bg); }
.graph-overlay[hidden] { display: none; }
.go-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; padding-top: calc(6px + env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.go-head b { font-weight: 800; }
.go-body { flex: 1; min-height: 0; display: flex; }
body.graph-open { overflow: hidden; }

/* gumb v nalogi in pod odgovorom inštruktorja */
.task-calc { margin-left: auto; }
.task-top .task-calc + .count, .task-top .task-calc ~ .count { margin-left: 8px; }
.msg .graph-btn { margin-top: 10px; }

/* ---------- telefon in tablica pokončno: graf zgoraj, seznam spodaj ---------- */
@media (max-width: 860px) {
  .gc { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .gc-stage { grid-row: 1; }
  .gc-panel { grid-row: 2; border-right: 0; border-top: 1px solid var(--border); }
  .gc-keypad { grid-column: 1; grid-row: 3; }
  .gc.kp-open { grid-template-rows: minmax(0, 1fr) minmax(0, 0.9fr) auto; }
  .gc.gc-full { grid-template-rows: 1fr 0 auto; }
  .gc.gc-full .gc-panel { display: none; }
  .gc .gc-expand { display: grid; }
  .gc-text-btn span { display: none; }
  .gc-zoom { top: 8px; right: 8px; gap: 5px; flex-direction: row; }
  .gc .gc-fab { width: 38px; height: 38px; }
  .gc.kp-open .gc-help { display: none; }
  .gc.kp-open .gc .gc-key, .gc.kp-open .gc-key { min-height: 40px; }
  body.gc-kp .tabbar, body.gc-kp #mock-banner, body.gc-kp #view-graph .me-back, body.gc-kp #offline-banner { display: none !important; }
  .gc-pop { max-height: 60vh; }
  .gc-row:not(.editing) .gc-math { min-height: 40px; }
}
@media (max-width: 380px) {
  .gc-kp-grid { gap: 4px; }
  .gc .gc-key { font-size: 0.92rem; min-height: 42px; }
}
/* tablica ležeče: seznam ožji */
@media (min-width: 861px) and (max-width: 1100px) { .gc { --gc-panel: 330px; } }

/* ---------- izbira orodja: znanstveni | grafični | enote ---------- */
.calc-top { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px; flex-shrink: 0; }
.calc-top .me-back { margin: 0 !important; }
#view-graph .calc-top .me-back { margin: 0; }
.calc-modes { margin: 0 auto; }
.calc-modes > button { min-height: 36px; }
.go-head .calc-modes { flex: 0 1 auto; }
.calc-open svg.i { flex-shrink: 0; }

/* ---------- znanstveni kalkulator (public/graph/sci.js) ---------- */
.sc { flex: 1; min-height: 0; min-width: 0; display: grid; grid-template-columns: 1fr minmax(360px, 460px); background: var(--bg); }
.sc-screen { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }
.sc-bar { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sc-angle > button { padding: 4px 10px !important; font-size: 0.8rem; min-height: 34px; }
.sc-format { min-height: 36px; max-width: 46vw; border-radius: 8px; border: 1.5px solid var(--border); background: var(--bg); font-weight: 700; padding: 2px 6px; }
.sc-sp { flex: 1; }
.sc-bar .sc-angle { width: auto; flex: 0 0 auto; }
.sc-format-l { min-width: 0; flex: 0 1 auto; display: flex; }
.sc-format { min-width: 0; }
.sc-history { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; }
.sc-history[hidden] { display: none; }
.sc-history > :first-child { margin-top: auto; }
.sc-h-row { display: flex; flex-direction: column; align-items: flex-end; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.sc-h-expr, .sc-h-res { background: none; border: 0; padding: 2px 6px; border-radius: 8px; color: var(--text); text-align: right; max-width: 100%; overflow-x: auto; min-height: 34px; cursor: pointer; }
.sc-h-expr { color: var(--muted); font-size: 0.95rem; }
.sc-h-res { font-size: 1.15rem; font-weight: 700; }
.sc-h-expr:hover, .sc-h-res:hover { background: var(--surface-2); }
.sc-empty { margin: auto; text-align: center; max-width: 32ch; padding: 12px; }
.sc-entry { border-top: 1px solid var(--border); padding: 6px 12px 10px; flex-shrink: 0; }
.sc-entry:focus-within { box-shadow: inset 0 -3px 0 var(--accent); }
.sc-preview { min-height: 1.7em; text-align: right; overflow-x: auto; color: var(--muted); }
.sc-input { width: 100%; font-size: 1.6rem; font-weight: 700; text-align: right; border: 0; background: transparent; color: var(--text); padding: 2px 0; outline: none; font-variant-numeric: tabular-nums; }
.sc-input::placeholder { color: var(--muted); font-size: 1rem; font-weight: 600; }
.sc-live { min-height: 1.6em; text-align: right; font-size: 1.1rem; overflow-x: auto; }
.sc-err { color: var(--danger); display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-weight: 700; font-size: 0.9rem; }

.sc-keys { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--surface-2); user-select: none; -webkit-user-select: none; }
.sc-fn { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.sc-num { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sc-key {
  min-height: 42px; padding: 2px; border-radius: 10px; border: 0; background: var(--surface); color: var(--text);
  font-weight: 800; font-size: 0.95rem; box-shadow: 0 1px 0 var(--border); touch-action: manipulation; white-space: nowrap; overflow: hidden; cursor: pointer;
}
.sc-key.n { min-height: 54px; font-size: 1.15rem; }
.sc-key.digit { background: var(--bg); font-size: 1.3rem; }
.sc-key.eq { background: var(--accent); color: var(--accent-text); font-size: 1.4rem; }
.sc-key.warn { color: var(--danger); }
.sc-key.second[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.sc-2nd .sc-key[data-ins2] { color: var(--accent); background: var(--accent-soft); }
.sc-key:active { filter: brightness(0.92); }
.sc-key:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sc-consts { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.sc-consts[hidden] { display: none; }
.sc-consts-h { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sc-const { display: grid; grid-template-columns: 56px 1fr; grid-template-areas: "s n" "s v"; gap: 0 8px; width: 100%; text-align: left; padding: 8px; border: 0; background: none; border-radius: 10px; color: var(--text); cursor: pointer; }
.sc-const:hover, .sc-const:focus-visible { background: var(--surface-2); }
.sc-c-sym { grid-area: s; font-size: 1.2rem; align-self: center; text-align: center; }
.sc-c-name { grid-area: n; font-weight: 700; font-size: 0.9rem; }
.sc-c-val { grid-area: v; color: var(--muted); font-size: 0.85rem; overflow-x: auto; }

/* ---------- pretvornik enot ---------- */
.un { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; background: var(--bg); }
.un-wrap { max-width: 680px; margin: 0 auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.un-q { flex-wrap: wrap; }
.un-card { display: flex; flex-direction: column; gap: 12px; }
.un-field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 0.85rem; color: var(--muted); flex: 1; min-width: 0; }
.un-field input, .un-field select { min-height: 46px; font-size: 1.1rem; color: var(--text); background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px; padding: 4px 10px; width: 100%; }
.un-pair { display: flex; align-items: flex-end; gap: 8px; }
.un-swap { margin-bottom: 2px; }
.un-result { font-size: 1.3rem; text-align: center; padding: 6px 0; overflow-x: auto; }
.un-ins { align-self: center; }
.un-all-h { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.un-all { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.un-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); overflow: hidden; cursor: pointer; text-align: left; }
.un-row:hover { border-color: var(--accent); }

@media (max-width: 860px) {
  .sc { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .sc-screen { border-right: 0; }
  .sc-keys { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .sc-const-btn span { display: none; }
}
@media (max-width: 860px) and (max-height: 760px) {
  .sc-key { min-height: 36px; }
  .sc-key.n { min-height: 46px; }
  .sc-input { font-size: 1.35rem; }
}
@media (max-width: 380px) {
  .sc-fn { gap: 4px; }
  .sc-key { font-size: 0.85rem; }
}

/* gumbi »Kalkulator« v Učni poti, vadnici in Inštruktorju */
.path-label-row, .topic-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topic-top { margin-bottom: 4px; }
.topic-top .back { margin-bottom: 0; }
.chat-head .chat-calc { flex-shrink: 0; }
@media (max-width: 480px) {
  .calc-modes svg.i { display: none; }
  .calc-modes > button { padding: 6px 10px !important; }
  .go-head #graph-close-label { display: none; }
}
@media (max-width: 899px) { body.pad-open .topic-top .calc-open { display: none !important; } }

/* ---------- orodja (public/graph/tools.js) ---------- */
.tl, .pse, .fm { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; background: var(--bg); }
.tl { display: flex; flex-direction: column; }
.tl-top { padding: 10px 16px 0; max-width: 760px; width: 100%; margin: 0 auto; }
.tl-body { flex: 1; }
.tl-body > .tl-view { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.tl-body > .tl-units { padding: 0; }
.tl-card { display: flex; flex-direction: column; gap: 10px; }
.tl-field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 0.85rem; color: var(--muted); min-width: 0; flex: 1; }
.tl-field input, .tl-field select, .tl-field textarea { min-height: 44px; font-size: 1.05rem; color: var(--text); background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px; padding: 6px 10px; width: 100%; }
.tl-field textarea { font-family: inherit; resize: vertical; }
.tl-inline { flex-direction: row; align-items: center; gap: 10px; }
.tl-inline select { width: auto; }
.tl-narrow { flex: 0 0 110px; }
.tl-pair { display: flex; gap: 8px; align-items: flex-end; }
.tl-note { font-size: 0.85rem; margin: 0; }
.tl-err { display: flex; gap: 6px; align-items: center; color: var(--danger); font-weight: 700; margin: 0; }
.tl-row { display: flex; align-items: center; gap: 10px; min-height: 40px; border-bottom: 1px dashed var(--border); padding: 2px 0; }
.tl-row:last-child { border-bottom: 0; }
.tl-k { flex: 1; color: var(--muted); font-size: 0.9rem; font-weight: 700; }
.tl-v { overflow-x: auto; }
.tl-row .tl-v:only-child, .tl-row .tl-v:first-child { flex: 1; }
.tl-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; word-break: break-all; }
.tl-h { font-weight: 800; }
.tl-formula { font-size: 1.15rem; overflow-x: auto; }
.tl-coefs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.tl-sys { display: grid; grid-template-columns: repeat(var(--cols), minmax(64px, 1fr)); gap: 6px; }
.tl-cell { display: flex; align-items: center; gap: 4px; }
.tl-cell input { width: 100%; min-width: 0; min-height: 44px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); padding: 4px 8px; font-size: 1rem; text-align: right; }
.tl-mx { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tl-mx textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tl-ops { flex-wrap: wrap; }
.tl-mx-res { overflow-x: auto; }
/* dolga enačba reakcije se na telefonu prelomi pri + in → (inline KaTeX) */
.tl-rx-eq { text-align: center; font-size: 1.2em; line-height: 2; padding: 4px 0; }
.tl-seg { align-self: flex-start; }

/* periodni sistem */
.pse-wrap { padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 12px; max-width: 1180px; margin: 0 auto; }
.pse-mm-res { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 1.15rem; overflow-x: auto; }
.pse-tab { width: 100%; font-size: 0.9rem; }
.pse-tab th, .pse-tab td { padding: 6px 8px; text-align: right; }
.pse-tab th:first-child, .pse-tab td:first-child { text-align: left; font-weight: 800; }
.pse-d-top { display: flex; align-items: center; gap: 14px; }
.pse-big { width: 76px; height: 76px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; flex-shrink: 0; }
.pse-d-name { display: flex; flex-direction: column; gap: 2px; }
.pse-d-name b { font-size: 1.25rem; }
.pse-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; margin: 10px 0 4px; }
.pse-dl dt { font-size: 0.78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.pse-dl dd { margin: 0; }
.pse-act { margin-top: 6px; }
.pse-scroll { overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.pse-groups, .pse-grid { display: grid; grid-template-columns: repeat(18, minmax(46px, 1fr)); gap: 3px; min-width: 880px; }
.pse-groups span { text-align: center; font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.pse-grid { grid-template-rows: repeat(7, auto) 14px auto auto; }
.pse-el, .pse-ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 2px; border-radius: 8px;
  border: 1.5px solid transparent; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; cursor: pointer;
}
.pse-el small { font-size: 0.66rem; color: var(--muted); align-self: flex-start; padding-left: 2px; }
.pse-el b { font-size: 1.05rem; }
.pse-el span { font-size: 0.64rem; color: var(--muted); }
.pse-el:hover, .pse-el:focus-visible { border-color: var(--accent); outline: none; }
.pse-el.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pse-ph { font-size: 0.66rem; color: var(--muted); cursor: default; }
.pse-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.82rem; }
.pse-lg { display: inline-flex; align-items: center; gap: 6px; background: none !important; }
.pse-lg i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
/* barve skupin (z oznako v podrobnostih in legendi, zato ne nosijo informacije same) */
.cat-alkali { --c: var(--g-red); } .cat-alkaline { --c: var(--g-orange); } .cat-transition { --c: var(--g-blue); }
.cat-post { --c: var(--g-teal); } .cat-metalloid { --c: var(--g-green); } .cat-nonmetal { --c: #b8a200; }
.cat-halogen { --c: var(--g-pink); } .cat-noble { --c: var(--g-purple); } .cat-lanthanide { --c: #8a6d3b; } .cat-actinide { --c: #7a5c8a; }
.pse-el, .pse-ph, .pse-big { background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
.pse-lg i { background: color-mix(in srgb, var(--c) 45%, var(--surface)); }

/* formule */
.fm-wrap { max-width: 860px; margin: 0 auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.fm-bar { padding-top: 12px; }
/* kazalo poglavij ostane na vrhu, ko se pomikaš po zbirki */
.fm-sel { display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: center; }
.fm-toc { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 6px 0; margin: -6px 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.fm-toc::-webkit-scrollbar { display: none; }
.fm-toc > button { flex: none; }
.fm-body { display: flex; flex-direction: column; gap: 12px; }
.fm-body .fm-sec { margin: 0; padding: 16px 20px; }
.fm-sec h2 { font-size: 1.1rem; margin: 0 0 4px; }
.fm-list { display: flex; flex-direction: column; }
.fm-item { display: grid; grid-template-columns: minmax(120px, 32%) minmax(0, 1fr); gap: 4px 16px; padding: 10px 0; border-top: 1px solid var(--border); align-items: baseline; }
.fm-list .fm-item:first-child { border-top: 0; }
.fm-head { font-weight: 800; color: var(--muted); }
.fm-item.fm-cont { border-top-style: dashed; }
.fm-name { font-weight: 700; color: var(--muted); }
/* formula se ne prelomi sredi izraza: lomi se le med formulami; predolga se pomakne vodoravno */
.fm-f { min-width: 0; overflow-x: auto; overflow-y: hidden; line-height: 1.55; padding: 2px 0; }
.fm-f .katex { white-space: nowrap; }
.fm-f p { margin: 0; }
@media (max-width: 600px) {
  .fm-wrap { padding: 0 12px 20px; }
  .fm-sel .seg { width: 100%; }
  .fm-sel .seg > button { min-height: 36px; padding: 6px 10px !important; }
  .fm-body .fm-sec { padding: 14px 16px; }
  .fm-item { grid-template-columns: minmax(0, 1fr); padding: 10px 0 12px; }
  .fm-name { font-size: 0.85rem; }
  .fm-cont .fm-name { display: none; }
}

.calc-modes { max-width: 100%; overflow-x: auto; }
@media (max-width: 860px) {
  .calc-top { padding: 6px 8px; }
  .tl-mx { grid-template-columns: 1fr; }
}
.pse-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.pse-cards .pse-dl { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.sc-preview:empty { min-height: 0; }
@media (max-width: 860px) {
  .pse-cards { grid-template-columns: 1fr; }
  .sc-entry { padding: 4px 12px 6px; }
  .sc-input { font-size: 1.4rem; }
  .sc-live { min-height: 1.3em; font-size: 1rem; }
  .sc-bar { padding: 6px 8px; }
  .sc-key { min-height: 38px; }
  .sc-key.n { min-height: 46px; }
  .sc-fn { gap: 4px; }
  .sc-num { gap: 5px; }
}
@media (max-width: 480px) {
  .calc-top .me-back span { display: none; }
  .calc-modes { padding: 3px; }
  .calc-modes > button { flex: 1 1 auto; font-size: 0.84rem; padding: 6px 7px !important; }
}
@media (max-width: 380px) {
  .calc-modes > button { font-size: 0.78rem; padding: 6px 5px !important; letter-spacing: -0.01em; }
}
.tl-seg > button { min-width: 0; white-space: normal; line-height: 1.2; border-radius: 16px !important; }

/* ---------- kemija in verjetnost (tools-chem.js, tools-prob.js) ---------- */
.tl-sub { flex-wrap: wrap; }
.tl-grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tl-inline2 { display: flex; gap: 6px; }
.tl-inline2 input { flex: 1; min-width: 0; }
.tl-inline2 select { flex: 0 0 72px; width: 72px !important; }
.tl-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 800; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); vertical-align: middle; }
.tl-tag.muted { background: var(--surface-2); color: var(--muted); }
.tl-rx { display: flex; flex-direction: column; gap: 6px; }
.tl-rx-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px 130px; gap: 8px; align-items: center; }
.tl-rx-sp { display: flex; flex-direction: column; gap: 2px; overflow-x: auto; }
.tl-rx-sp small { font-size: 0.78rem; }
.tl-rx-tab td:first-child { white-space: nowrap; }
.tl-ph-kind { margin: 4px 0 0; }
.pse-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pse-bar .seg { width: auto; }
.pse-bond-kind { margin: 4px 0 0; font-size: 1.05rem; }
.pse-cards .pse-bond { grid-column: 2; }
/* tabela topnosti: barva + črka (T, M, N, –) */
.sol-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sol-tab { border-collapse: separate; border-spacing: 3px; min-width: 520px; }
.sol-tab th { font-weight: 700; padding: 2px 4px; white-space: nowrap; font-size: 0.85rem; }
.sol-tab thead th { text-align: center; }
.sol-tab tbody th { text-align: left; position: sticky; left: 0; z-index: 1; background: var(--surface); }
.sol-tab td { padding: 0; }
.sol-c { display: inline-grid; place-items: center; width: 100%; min-width: 40px; min-height: 36px; border-radius: 8px; font-weight: 800; border: 1.5px solid transparent; color: var(--text); font-style: normal; }
.sol-t { background: color-mix(in srgb, var(--g-green) 22%, var(--surface)); }
.sol-m { background: color-mix(in srgb, var(--g-orange) 24%, var(--surface)); }
.sol-n { background: color-mix(in srgb, var(--g-red) 22%, var(--surface)); }
.sol-x { background: var(--surface-2); color: var(--muted); }
button.sol-c:hover, button.sol-c:focus-visible, .sol-c.sel { border-color: var(--accent); outline: none; }
.sol-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; }
.sol-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sol-legend .sol-c { width: 28px; min-width: 28px; min-height: 24px; font-size: 0.8rem; }
/* graf porazdelitve */
.pr-svg { width: 100%; height: auto; max-height: 220px; display: block; }
.pr-ax { stroke: var(--muted); stroke-width: 1; }
.pr-line { fill: none; stroke: var(--g-blue); stroke-width: 2; }
.pr-area { fill: color-mix(in srgb, var(--g-blue) 30%, transparent); }
.pr-on { fill: var(--g-blue); }
.pr-off { fill: color-mix(in srgb, var(--g-blue) 22%, var(--surface)); }
.pr-t { font-size: 10px; fill: var(--muted); text-anchor: middle; }
@media (max-width: 860px) {
  .pse-cards .pse-bond { grid-column: auto; }
}
@media (max-width: 520px) {
  .tl-rx-row { grid-template-columns: 1fr 1fr; }
  .tl-rx-sp { grid-column: 1 / -1; }
}
/* 3D graf (plot3d.js) */
.p3-card { gap: 8px; }
.p3 { width: 100%; height: min(62vh, 460px); min-height: 280px; display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; border-radius: 10px; background: var(--surface); }
.p3:active { cursor: grabbing; }
.p3:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.p3-scale { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.p3-scale i { flex: 1; height: 10px; border-radius: 5px; background: linear-gradient(90deg, hsl(230 70% 38%), hsl(140 70% 49%), hsl(50 70% 60%)); }

/* ---------- znanstveni kalkulator: enačbe, spremenljivke, meni funkcij (sci.js, scisolve.js) ---------- */
/* shranjene spremenljivke in funkcije so v vrstici z DEG/RAD (na telefonu ni prostora za še eno vrstico) */
.sc-vars { display: flex; align-items: center; gap: 6px; padding: 0 2px; overflow-x: auto; flex: 1 1 auto; min-width: 0; scrollbar-width: none; }
.sc-vars:not([hidden]) + .sc-sp { display: none; }
.sc-vars::-webkit-scrollbar { display: none; }
.sc-vars[hidden] { display: none; }
.sc-vars-l { font-size: 0.75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0; }
.sc-var { flex-shrink: 0; min-height: 34px; white-space: nowrap; font-weight: 700; }
.sc-h-note { font-size: 0.85rem; text-align: right; padding: 0 6px 2px; max-width: 100%; overflow-x: auto; }
.sc-bool { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.sc-bool.ok { color: var(--ok); }
.sc-bool.no { color: var(--danger); }
.sc-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 4px 0 2px; }
.sc-act { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.sc-act:hover, .sc-act:focus-visible { border-color: var(--accent); color: var(--accent); }
.sc-act svg.i { width: 16px; height: 16px; flex-shrink: 0; }
.sc-empty p { margin: 0 0 6px; }
.sc-try { font-weight: 800; color: var(--text); margin-top: 10px !important; }
.sc-examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.sc-ex { min-height: 40px; font-weight: 700; }
.sc-live-hint { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.sc-key.more { font-size: 1.2rem; }
.sc-key.more[aria-expanded="true"] { background: var(--accent); color: var(--accent-text); }
.sc-keys { position: relative; }
.sc-panel { position: absolute; inset: 0; z-index: 2; overflow-y: auto; padding: 0 8px 8px; background: var(--surface); border-left: 1px solid var(--border); }
.sc-panel[hidden] { display: none; }
.sc-panel .sc-consts-h { background: var(--surface); }
.sc-more-g { padding: 6px 4px; }
.sc-more-h { font-size: 0.75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.sc-more-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.sc-mk { min-height: 42px; padding: 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; overflow: hidden; }
.sc-mk:hover, .sc-mk:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.sc-h-row.last .sc-h-res { font-size: 1.3rem; }
.sc-live:empty { min-height: 0; }
.sc-parts { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; column-gap: 18px; row-gap: 2px; max-width: 100%; }
/* Na telefonu znanstveni kalkulator skrije zgornjo vrstico (ostaneta ← in spodnji zavihki), da ostane prostor za zgodovino. */
@media (max-width: 760px) {
  body:has(#view-graph:not([hidden]) #graph-slot > .sc) .topbar,
  body:has(#view-graph:not([hidden]) #graph-slot > .sc) #mock-banner { display: none !important; }
  .sc-key { min-height: 40px; }
  .sc-key.n { min-height: 44px; }
  .sc-parts { display: flex; flex-wrap: wrap; justify-content: flex-end; column-gap: 14px; }
  .sc-fn { gap: 4px; }
  .sc-keys { gap: 5px; }
  .sc-h-row { padding: 4px 0; }
  .sc-panel { border-left: 0; border-top: 1px solid var(--border); }
  .sc-vars-l { display: none; }
  .sc-var { min-height: 40px; padding-top: 2px; padding-bottom: 2px; }
  .sc-bar { flex-wrap: wrap; row-gap: 4px; }
  .sc-vars { order: 9; flex: 1 0 100%; }
  .sc-vars:not([hidden]) + .sc-sp { display: block; }
  .sc-format-l { flex: 0 1 auto; }
  .sc-format-l .dd { max-width: min(124px, 34vw); }
  /* prazna zgodovina: primeri v eni vrstici, ki se pomika, da so vidni nad tipkovnico */
  .sc-empty { max-width: none; width: 100%; padding: 4px 0; }
  .sc-empty p { margin-bottom: 2px; }
  .sc-try { margin-top: 4px !important; }
  .sc-examples { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .sc-examples::-webkit-scrollbar { display: none; }
  .sc-ex { flex-shrink: 0; white-space: nowrap; }
  .sc-h-expr, .sc-h-res { min-height: 30px; }
}
/* Desno na levo (arabščina, perzijščina, urdu): matematika, vnos in tipke ostanejo od leve proti desni
   (sicer se KaTeX obrne in < postane >), rezultati pa so poravnani desno kot pri LTR. */
.sc .katex, .sc-input, .sc-preview, .sc-var, .sc-ex, .sc-fn, .sc-num, .sc-parts { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .sc-h-row { align-items: flex-start; }
[dir="rtl"] .sc-acts, [dir="rtl"] .sc-err { justify-content: flex-start; }
[dir="rtl"] .sc-const { text-align: right; }
