/* Goodie Label Studio — tmavé studiové rozhraní, aby vynikla grafika etikety. */

:root {
  --bg: #0c0d11;
  --surface: #14161d;
  --surface-2: #1a1d26;
  --surface-3: #21252f;
  --line: #262a35;
  --line-soft: #1e212a;
  --text: #e9ebf1;
  --muted: #8d93a5;
  --dim: #5d6376;
  --accent: #c452d4;
  --accent-2: #8a3aa8;
  --accent-soft: rgba(196, 82, 212, 0.14);
  --accent-line: rgba(196, 82, 212, 0.45);
  --ok: #3ecf94;
  --warn: #f3b13c;
  --err: #f2585f;
  --canvas-bg: #08090c;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  --radius: 10px;
  --radius-sm: 7px;
  --rail: 268px;
  --inspector: 304px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef0f5;
  --surface: #ffffff;
  --surface-2: #f5f6fa;
  --surface-3: #eaecf3;
  --line: #d9dde7;
  --line-soft: #e6e9f0;
  --text: #171a22;
  --muted: #626a7d;
  --dim: #8d94a5;
  --accent: #9b2fb0;
  --accent-2: #7a2590;
  --accent-soft: rgba(155, 47, 176, 0.1);
  --accent-line: rgba(155, 47, 176, 0.4);
  --canvas-bg: #dfe2ea;
  --shadow: 0 18px 44px rgba(20, 24, 40, 0.16);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 ui-sans-serif, system-ui, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--line); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- layout */

.app {
  display: grid;
  grid-template-rows: 52px 1fr;
  height: 100vh;
}

.workspace {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--inspector);
  min-height: 0;
}

.workspace.no-doc { grid-template-columns: 1fr; }

/* ------------------------------------------------------------------- bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand .mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.brand small {
  color: var(--dim);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.doc-name {
  color: var(--muted);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.topbar .spacer { flex: 1; }

/* --------------------------------------------------------------- ovládací */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s, border-color .13s, opacity .13s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: #333846; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 560;
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn.sm { height: 25px; padding: 0 8px; font-size: 12px; }
.btn.danger:hover:not(:disabled) { background: rgba(242, 88, 95, .14); border-color: rgba(242, 88, 95, .5); color: #ff8b90; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  height: 24px;
  min-width: 28px;
  padding: 0 8px;
  border-radius: 5px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  transition: border-color .13s, background .13s;
}
textarea { height: auto; padding: 6px 8px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-line);
  background: var(--surface-3);
}
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: var(--surface-3);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--surface);
}

label.check {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--muted);
}
label.check input { width: 14px; height: 14px; accent-color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 7px;
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: .01em;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: rgba(62, 207, 148, .13); color: var(--ok); }
.badge.warn { background: rgba(243, 177, 60, .13); color: var(--warn); }
.badge.err { background: rgba(242, 88, 95, .13); color: var(--err); }

/* ---------------------------------------------------------------- jazyky */

.lang-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 42vw;
}
.lang-tabs::-webkit-scrollbar { display: none; }

.lang-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.lang-tab:hover { background: var(--surface-2); color: var(--text); }
.lang-tab[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 580;
}
.lang-tab .code { text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.lang-tab .fill {
  font-size: 10px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.lang-tab[aria-selected="true"] .fill { color: var(--accent); opacity: .8; }
.lang-tab.src .code::after {
  content: "zdroj";
  margin-left: 5px;
  font-size: 9px;
  letter-spacing: .06em;
  opacity: .6;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ rail */

.rail, .inspector {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rail { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }

.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: 1;
  height: 30px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.pane { flex: 1; overflow-y: auto; min-height: 0; }
.pane.pad { padding: 12px; }

.section {
  padding: 12px 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.section:last-child { border-bottom: 0; }

.section h3 {
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section h3 .spacer { flex: 1; }

.field { margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.row { display: flex; gap: 7px; align-items: center; }
.row > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }

.num-field { position: relative; }
.num-field span {
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--dim);
  pointer-events: none;
}
.num-field input { padding-left: 22px; text-align: right; padding-right: 8px; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------- seznam vrstev */

.layer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  border: 1px solid transparent;
}
.layer:hover { background: var(--surface-2); color: var(--text); }
.layer.sel {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}
.layer .txt {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.layer .sec { font-size: 10px; color: var(--dim); }
.layer .mini {
  opacity: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}
.layer:hover .mini, .layer .mini.on { opacity: 1; }
.layer .mini:hover { color: var(--text); background: var(--surface-3); }
.layer .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }

/* ---------------------------------------------------------- seznam textů */

.trow {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.trow:hover { background: var(--surface-2); }
.trow.sel { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.trow .src { color: var(--dim); font-size: 11.5px; margin-bottom: 4px; line-height: 1.4; }
.trow .dst { color: var(--text); font-size: 12.5px; line-height: 1.4; white-space: pre-wrap; }
.trow .dst.empty { color: var(--err); opacity: .75; font-style: italic; }
.trow .meta { margin-top: 5px; display: flex; gap: 5px; align-items: center; }

/* ---------------------------------------------------------------- plátno */

.stage {
  position: relative;
  min-width: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.045) 1px, transparent 0) 0 0/22px 22px,
    var(--canvas-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
:root[data-theme="light"] .stage {
  background:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,.06) 1px, transparent 0) 0 0/22px 22px,
    var(--canvas-bg);
}

.viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: default;
  min-height: 0;
}
.viewport.panning { cursor: grabbing; }
.viewport.space { cursor: grab; }

.scene {
  position: absolute;
  transform-origin: 0 0;
  will-change: transform;
}

.paper {
  position: relative;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
}
.paper img.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.paper svg.art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.paper svg.art text { white-space: pre; }

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.hitbox {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  border: 1px solid transparent;
}
.hitbox:hover { border-color: rgba(196, 82, 212, .5); }
.hitbox.locked { cursor: default; }
.hitbox.sel { border-color: var(--accent); }
.hitbox.issue { border-color: var(--err); border-style: dashed; }
.hitbox.hidden-el { opacity: .35; border-style: dotted; }

.handle {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -5px 0 0 -5px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  pointer-events: auto;
}
.handle.rot {
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
}
.guide {
  position: absolute;
  background: #35d6ff;
  pointer-events: none;
}
.guide.v { width: 1px; top: 0; bottom: 0; }
.guide.h { height: 1px; left: 0; right: 0; }

.marquee {
  position: absolute;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  pointer-events: none;
}

.text-editor {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: rgba(255, 255, 255, .92);
  color: #000;
  outline: none;
  resize: none;
  overflow: hidden;
  pointer-events: auto;
  transform-origin: 0 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stage-bar {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}
.stage-bar .spacer { flex: 1; }
.stage-bar .zoom-val {
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stage-hint {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 60%;
  pointer-events: none;
}
.stage-hint .badge { backdrop-filter: blur(8px); background: rgba(20, 22, 29, .78); }

/* --------------------------------------------------------------- uvítání */

.welcome {
  display: grid;
  place-items: center;
  padding: 32px;
  overflow-y: auto;
}
.welcome-inner { width: min(880px, 100%); }
.welcome h1 {
  font-size: 30px;
  margin: 0 0 6px;
  letter-spacing: -0.03em;
  font-weight: 680;
}
.welcome p.lead { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  padding: 34px;
  text-align: center;
  background: var(--surface);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.dropzone .big { font-size: 15px; font-weight: 570; margin-bottom: 5px; }
.dropzone .sub { color: var(--muted); font-size: 12.5px; }

.start-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  margin-top: 18px;
}
@media (max-width: 900px) { .start-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.card h3 {
  margin: 0 0 10px;
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 620;
}

.recent-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px;
  border-radius: 8px;
  cursor: pointer;
}
.recent-item:hover { background: var(--surface-2); }
.recent-item img {
  width: 46px; height: 34px;
  object-fit: cover;
  border-radius: 5px;
  background: var(--surface-3);
  flex: none;
}
.recent-item .t { flex: 1; min-width: 0; }
.recent-item .t b {
  display: block;
  font-weight: 520;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-item .t span { color: var(--dim); font-size: 11px; }

/* ---------------------------------------------------------------- dialog */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 10, .66);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 20px;
}
.modal {
  width: min(520px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.modal.wide { width: min(760px, 100%); }
.modal header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal header h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.modal header .spacer { flex: 1; }
.modal .body { padding: 16px; }
.modal footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.lang-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface-2);
  font-size: 12px;
}
.lang-chip:hover { border-color: var(--accent-line); }
.lang-chip input { accent-color: var(--accent); }
.lang-chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* -------------------------------------------------------------- oznámení */

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  min-width: 240px;
  max-width: 380px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise .18s ease-out;
  pointer-events: auto;
}
.toast .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--accent); }
.toast.ok .bar { background: var(--ok); }
.toast.err .bar { background: var(--err); }
.toast.warn .bar { background: var(--warn); }
.toast .msg { flex: 1; font-size: 12.5px; line-height: 1.4; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.spinner {
  width: 13px; height: 13px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.busy {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 13, .7);
  backdrop-filter: blur(2px);
}
.busy .box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.busy .spinner { width: 18px; height: 18px; }

.empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
}

.menu {
  position: absolute;
  min-width: 208px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 70;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
}
.menu button:hover { background: var(--surface-3); }
.menu button kbd { margin-left: auto; color: var(--dim); font-size: 10.5px; font-family: inherit; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }

kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 10.5px;
  color: var(--muted);
}

.issue-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  font-size: 12px;
}
.issue-row:hover { background: var(--surface-2); }
.issue-row .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: none; }
.issue-row .dot.error { background: var(--err); }
.issue-row .dot.warn { background: var(--warn); }
.issue-row .who { color: var(--dim); font-size: 11px; margin-top: 2px; }

.hint { color: var(--dim); font-size: 11px; line-height: 1.5; margin-top: 6px; }

.override-note {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: 11.5px;
  margin-bottom: 10px;
}
.override-note .spacer { flex: 1; }
