:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --line: #d6d6d1;
  --line2: #e8e8e4;
  --ink: #1d1d1b;
  --mute: #6b6b66;
  --accent: #c2410c;
  --accent-bg: #fbe9df;
  --hover: #ececea;
  --canvas: #e3e3df;
  --danger: #b91c1c;
  --ok: #15803d;
  font-family: "Inter", "Liberation Sans", "DejaVu Sans", system-ui, sans-serif;
  font-size: 13px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

body { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; height: 100vh; }

/* ---------- izvēlne */
#top { display: flex; align-items: stretch; justify-content: space-between; background: var(--panel); border-bottom: 1px solid var(--line); height: 30px; }
#menubar { display: flex; }
.menu { position: relative; }
.menu > button { height: 100%; padding: 0 12px; background: none; border: 0; }
.menu > button:hover, .menu.open > button { background: var(--hover); }
.menu .items { position: absolute; top: 100%; left: 0; min-width: 240px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0,0,0,.12); z-index: 50; padding: 4px 0; display: none; }
.menu.open .items { display: block; }
.menu .items button { display: flex; width: 100%; justify-content: space-between; gap: 24px; padding: 6px 14px; background: none; border: 0; text-align: left; white-space: nowrap; }
.menu .items button:hover { background: var(--accent-bg); }
.menu .items button kbd { color: var(--mute); font: inherit; font-size: 12px; }
.menu .items hr { border: 0; border-top: 1px solid var(--line2); margin: 4px 0; }
#docinfo { display: flex; align-items: center; gap: 12px; padding-right: 8px; }
#docname { font-weight: 600; }
#savestate { color: var(--mute); font-size: 12px; }
.langbtn { border: 1px solid var(--line); background: var(--bg); padding: 2px 10px; font-weight: 600; }
.langbtn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- rīkjoslas */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 1px; padding: 3px 6px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 36px; }
.toolbar .sep, .vtoolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.vtoolbar .sep { width: 24px; height: 1px; margin: 4px 0; }
.ib { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 1px solid transparent; background: none; padding: 0; color: var(--ink); }
.ib:hover { background: var(--hover); border-color: var(--line); }
.ib.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.ib:disabled { opacity: .35; cursor: default; background: none; border-color: transparent; }
.props label { display: inline-flex; align-items: center; gap: 4px; color: var(--mute); margin-right: 4px; }
.props input[type=number], .props input[type=text] { width: 76px; height: 24px; border: 1px solid var(--line); padding: 0 4px; background: #fff; color: var(--ink); }
.props input.pct { width: 54px; }
.props .unit { color: var(--mute); font-size: 11px; margin-right: 6px; }
.anchor { display: inline-grid; grid-template-columns: repeat(3, 8px); gap: 2px; padding: 3px; border: 1px solid var(--line); margin: 0 6px; }
.anchor i { width: 8px; height: 8px; border: 1px solid var(--mute); cursor: pointer; }
.anchor i.on { background: var(--accent); border-color: var(--accent); }

/* ---------- galvenā daļa */
#main { display: grid; grid-template-columns: 44px minmax(0, 1fr) 320px; min-height: 0; }
.vtoolbar { display: flex; flex-direction: column; align-items: center; padding: 4px 0; gap: 1px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.vtoolbar .ib { width: 34px; height: 32px; }

/* Audekli ir absolūti novietoti: to pikseļu izmērs (width/height atribūti, kas ar Windows 125–150%
   mērogošanu ir lielāki par CSS izmēru) nedrīkst ietekmēt izkārtojumu, citādi laukums aug bezgalīgi. */
#stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--canvas); }
#corner { position: absolute; left: 0; top: 0; width: 22px; height: 22px; background: var(--panel); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); box-sizing: border-box; }
#rulerX { position: absolute; left: 22px; top: 0; width: calc(100% - 22px); height: 22px; display: block; }
#rulerY { position: absolute; left: 0; top: 22px; width: 22px; height: calc(100% - 22px); display: block; }
#cv { position: absolute; left: 22px; top: 22px; width: calc(100% - 22px); height: calc(100% - 22px); display: block; outline: none; touch-action: none; }
.floatbar { position: absolute; top: 30px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 40px); flex-wrap: wrap; justify-content: center; display: flex; gap: 2px; align-items: center; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: 3px 6px; z-index: 5; }
.floatbar button.txt { height: 28px; padding: 0 10px; border: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.floatbar button.txt:hover { border-color: var(--accent); }
.floatbar .info { padding: 0 8px; color: var(--mute); white-space: nowrap; }
#textedit { position: absolute; z-index: 6; min-width: 160px; min-height: 40px; border: 1px solid var(--accent); background: rgba(255,255,255,.95); padding: 4px; font-size: 16px; resize: both; }

/* ---------- labais panelis */
#side { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 7px 4px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--mute); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabbody { flex: 1; overflow: auto; padding: 8px; min-height: 0; }
table.layers { width: 100%; border-collapse: collapse; font-size: 12px; }
table.layers th { text-align: left; font-weight: 600; color: var(--mute); border-bottom: 1px solid var(--line); padding: 4px; }
table.layers td { border-bottom: 1px solid var(--line2); padding: 3px 4px; }
table.layers tr { cursor: pointer; }
table.layers tr.sel td { background: var(--accent-bg); }
table.layers .sw { width: 28px; height: 16px; border: 1px solid rgba(0,0,0,.25); }
.row { display: flex; gap: 6px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 5px 12px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
fieldset { border: 1px solid var(--line); padding: 8px; margin: 0 0 10px; }
legend { color: var(--mute); padding: 0 4px; }
.field { display: grid; grid-template-columns: 1fr 120px; gap: 6px; align-items: center; margin: 5px 0; }
.field.c3 { grid-template-columns: 1fr 90px 30px; }
.field input, .field select, .dlg input, .dlg select, .dlg textarea { height: 26px; border: 1px solid var(--line); padding: 0 6px; background: #fff; width: 100%; }
.field input[type=checkbox], .dlg input[type=checkbox], .dlg input[type=radio] { width: auto; height: auto; }
.dlg textarea { height: auto; padding: 6px; }
.muted { color: var(--mute); }
.small { font-size: 11.5px; }
.objlist { list-style: none; padding: 0; margin: 0; }
.objlist li { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-bottom: 1px solid var(--line2); cursor: pointer; }
.objlist li.sel { background: var(--accent-bg); }
.objlist .sw { width: 12px; height: 12px; flex: none; border: 1px solid rgba(0,0,0,.25); }
.objlist .num { margin-left: auto; color: var(--mute); font-size: 11px; }
#jobbox { border-top: 1px solid var(--line); padding: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#jobbox .title { grid-column: 1 / -1; color: var(--mute); font-size: 12px; }

/* ---------- apakša */
#bottom { background: var(--panel); border-top: 1px solid var(--line); }
#palette { display: flex; gap: 2px; padding: 4px 6px; align-items: center; overflow-x: auto; }
#palette button.pal { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 12px 0 6px; border: 1px solid var(--line); background: var(--panel); flex: none; }
#palette button.pal i { width: 22px; height: 14px; border: 1px solid rgba(0,0,0,.25); }
#palette button.pal:hover { border-color: var(--accent); }
#palette button.pal.on { border-color: var(--accent); background: var(--accent-bg); font-weight: 600; }
#palette .lbl { color: var(--mute); font-size: 11px; margin-right: 6px; white-space: nowrap; }
#status { display: flex; gap: 20px; padding: 3px 10px; border-top: 1px solid var(--line2); color: var(--mute); font-size: 12px; }
#status #st-hint { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status span { white-space: nowrap; }

/* ---------- dialogi */
#modal { position: fixed; inset: 0; background: rgba(20,20,18,.35); display: grid; place-items: center; z-index: 100; }
.dlg { background: var(--panel); border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(0,0,0,.25); min-width: 360px; max-width: min(720px, 95vw); max-height: 90vh; overflow: auto; }
.dlg h3 { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.dlg .body { padding: 12px 14px; }
.dlg .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.dlg .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.dlg label.f { display: grid; gap: 3px; color: var(--mute); }
.dlg .issues { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.dlg .issues li { padding: 5px 6px; border-bottom: 1px solid var(--line2); cursor: pointer; }
.dlg .issues li:hover { background: var(--accent-bg); }
.dlg .projlist { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; min-width: 460px; }
.dlg .projlist li { display: flex; gap: 10px; align-items: center; padding: 7px 6px; border-bottom: 1px solid var(--line2); }
.dlg .projlist li .n { flex: 1; cursor: pointer; font-weight: 600; }
.dlg .projlist li .n:hover { color: var(--accent); }
.bmpwrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bmpwrap canvas { width: 100%; border: 1px solid var(--line); background: #fff; image-rendering: pixelated; }
#toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; z-index: 120; max-width: 80vw; }
#toast.err { background: var(--danger); }

/* ---------- konts un pieteikšanās */
#account { display: flex; align-items: center; gap: 6px; }
#account .who, #paccount .who { font-weight: 600; padding: 0 6px; border-left: 1px solid var(--line); }
.btn.small { padding: 2px 10px; font-size: 12px; text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
#login { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.loginbox { width: 100%; max-width: 420px; justify-self: center; background: var(--panel); border: 1px solid var(--line); padding: 22px; display: grid; gap: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.loginbox .logo { display: flex; gap: 12px; align-items: center; }
.loginbox .logo > div { flex: 1; }
.loginbox label.f { display: grid; gap: 4px; color: var(--mute); }
.loginbox select, .loginbox input { height: 34px; border: 1px solid var(--line); padding: 0 8px; background: #fff; font-size: 14px; }
.loginbox .btn.primary { height: 36px; font-size: 14px; }
.loginbox .err { color: var(--danger); }

/* ---------- darbu režģis (mape) */
.dlg.wide { width: min(920px, 95vw); }
.workgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 8px; max-height: 60vh; overflow: auto; }
.workcard { display: grid; gap: 3px; border: 1px solid var(--line); padding: 6px; cursor: pointer; background: var(--panel); align-content: start; }
.workcard:hover { border-color: var(--accent); }
.workcard img, .workcard .nothumb { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: #fff; border: 1px solid var(--line2); }
.workcard b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workcard .btn { justify-self: start; margin-top: 4px; }
.workcard.sel { border-color: var(--accent); background: var(--accent-bg); }
.dlg input[type=search] { height: 28px; border: 1px solid var(--line); padding: 0 8px; }

/* ---------- tiešraide */
#livebar { top: auto; bottom: 14px; }
#livebar select { height: 28px; border: 1px solid var(--line); max-width: 240px; }
#livebar label.info { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.live-on { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; }
#livebanner { position: absolute; top: 30px; right: 14px; z-index: 6; display: flex; align-items: center; gap: 8px; padding: 6px 12px; color: #fff; background: #dc2626; box-shadow: 0 4px 14px rgba(0,0,0,.15); max-width: 60%; font-weight: 600; }
#livebanner.watched { background: #2563eb; }
#livebanner.watching { background: #1d4ed8; }
#livebanner .dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: livepulse 1.2s infinite; flex: none; }
#livebanner .btn { color: var(--ink); }
.live-hl { outline: 3px solid #dc2626 !important; outline-offset: 2px; animation: livehl 0.9s infinite; position: relative; z-index: 3; }
@keyframes livepulse { 50% { opacity: .3; } }
@keyframes livehl { 50% { outline-color: rgba(220,38,38,.35); } }

/* ---------- palīdzības lūgumi */
.helpbtn { border-color: #dc2626; color: #b91c1c; font-weight: 600; }
.helpbtn.waiting { background: #dc2626; color: #fff; animation: livepulse 1.4s infinite; }
#livebanner.acked { background: #15803d; }
#helpdesk { position: fixed; top: 74px; right: 16px; z-index: 150; display: grid; gap: 8px; width: 320px; max-height: 70vh; overflow: auto; }
#helpdesk .helpcard { background: #fff; border: 1px solid var(--line); border-left: 5px solid #dc2626; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 10px 12px; display: grid; gap: 4px; animation: helpin .25s ease-out; }
#helpdesk .who { font-weight: 700; font-size: 14px; }
#helpdesk .meta { color: var(--mute); font-size: 12px; }
#helpdesk .acts { display: flex; gap: 6px; margin-top: 4px; }
#helpdesk .notifyask { justify-self: end; }
@keyframes helpin { from { transform: translateX(30px); opacity: 0; } }

.who-btn { gap: 6px; font-weight: 600; }
.who-btn i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
/* ---------- skolotāja izvēle */
.teacherpick .tp-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 50vh; overflow: auto; }
.teacherpick .tp-name { display: flex; align-items: center; gap: 8px; padding: 9px 10px; text-align: left; font-size: 14px; }
.teacherpick .tp-name i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.teacherpick .tp-name:hover { border-color: var(--accent); background: var(--accent-bg); }
/* ---------- Uzmanību! */
#attention { position: fixed; inset: 0; z-index: 300; background: rgba(20,20,18,.88); color: #fff; display: grid; place-items: center; text-align: center; padding: 20px; }
#attention .big { font-size: clamp(40px, 7vw, 88px); line-height: 1; margin-bottom: 18px; }
#attention h1 { font-size: clamp(26px, 4vw, 46px); margin: 0 0 10px; }
#attention p { font-size: 18px; opacity: .85; margin: 0; }

/* mazi skolu klēpjdatoru ekrāni (piem., 1366×768 vai 1280×720 ar 125–150% mērogošanu) */
@media (max-width: 1100px) {
  #main { grid-template-columns: 40px minmax(0, 1fr) 250px; }
  .vtoolbar .ib { width: 32px; height: 30px; }
  .tabs button { padding: 6px 2px; font-size: 12px; }
  table.layers { font-size: 11px; }
  #jobbox { grid-template-columns: 1fr; }
}

@media print { body > * { display: none !important; } }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { border-color: var(--line); }
