/* ---------------------------------------------------------------- tlacitka */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, transform 80ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: 2px;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn--secondary {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
}

.btn--danger {
  background: var(--danger-100);
  color: var(--on-danger-tint);
  border-color: transparent;
}

.btn--block {
  width: 100%;
}

.btn--compact {
  min-height: 38px;
  padding: 0 var(--space-3);
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn:active {
  background: rgba(127, 127, 127, 0.18);
}

.icon-btn:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: -3px;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fab {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.2, 0, 0, 1);
}

.fab:active {
  transform: scale(0.94);
}

.fab svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.fab.is-open svg {
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.fab-mini {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-3) 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-2);
  cursor: pointer;
  white-space: nowrap;
}

.fab-mini span.dot {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--forest-100);
  color: var(--on-forest-tint);
  font-size: 0.8rem;
}

.fab-mini img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* ----------------------------------------------------------------- karty */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.stat {
  flex: none;
  min-width: 84px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
  text-align: center;
}

.stat b {
  display: block;
  font-family: var(--font-numeric);
  font-size: 1.06rem;
  line-height: 1.2;
}

.stat small {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------- seznamy */

.record-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.record {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 64px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.record:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: 2px;
}

.record.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.record.is-done {
  opacity: 0.62;
}

.record h4 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
}

.record p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.record-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--species-color, var(--forest-500)) 18%, var(--surface));
  overflow: hidden;
}

.record-badge img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.record-badge.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-value {
  font-family: var(--font-numeric);
  font-size: 0.95rem;
  font-weight: 650;
  white-space: nowrap;
}

.empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-muted);
}

.empty-state strong {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--text);
}

/* ---------------------------------------------------------------- pilulky */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}

.pill.is-done {
  background: var(--forest-100);
  color: var(--on-forest-tint);
}

.pill.is-warn {
  background: var(--amber-100);
  color: var(--on-amber-tint);
}

.pill.is-danger {
  background: var(--danger-100);
  color: var(--on-danger-tint);
}

.pill .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--swatch, var(--forest-500));
}

/* --------------------------------------------------------------- formulare */

.field {
  display: block;
  margin-bottom: var(--space-3);
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid var(--amber-500);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.field-hint {
  margin: -6px 0 var(--space-3);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.field-error {
  margin: -6px 0 var(--space-3);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger-600);
}

/* Prepinac mezi prumerem a obvodem. */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: var(--space-3);
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.photo-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-drop {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  min-height: 132px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2) center / cover no-repeat;
  color: var(--text-muted);
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  padding: var(--space-3);
}

.photo-drop.has-image {
  color: #ffffff;
  border-style: solid;
  border-color: transparent;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.photo-drop svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.estimate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  border-radius: var(--radius);
  background: var(--forest-100);
  color: var(--on-forest-tint);
  font-weight: 650;
}

.estimate b {
  font-family: var(--font-numeric);
  font-size: 1.2rem;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.form-actions .btn--block {
  grid-column: 1 / -1;
}

/* ------------------------------------------------------------------ taby */

.tab {
  flex: none;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--forest-700);
  color: var(--text-inverse);
}

.tab:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- drawer */

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.is-active {
  background: var(--forest-100);
  color: var(--on-forest-tint);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item .trail {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.nav-item:disabled {
  cursor: default;
  opacity: 0.6;
}

/* Project list: a parent row with its chevron, and indented subprojects. */
.nav-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-group > .nav-item {
  flex: 1 1 auto;
  min-width: 0;
}

.nav-chevron {
  flex: none;
  color: var(--text-muted);
}

.nav-chevron svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 150ms ease-out;
}

.nav-chevron.is-open svg {
  transform: rotate(90deg);
}

.nav-item--child {
  width: calc(100% - var(--space-5));
  margin-left: var(--space-5);
  font-weight: 500;
}

.nav-item--child svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

/* Long project names are cut with an ellipsis instead of wrapping the row. */
.nav-item .nav-item__text {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item .nav-item__text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item--link {
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
  text-decoration: none;
}

.nav-item__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-item__text small {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
}

.switch-row:hover {
  background: var(--surface-2);
}

.switch-row input {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.switch-row .label {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.switch-row .label small {
  display: block;
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.account-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--forest-600);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  flex: none;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------------------------------------------------------------- bannery */

.banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: 0.88rem;
}

.banner.is-warn {
  background: var(--amber-100);
  color: var(--on-amber-tint);
}

.banner.is-info {
  background: var(--forest-100);
  color: var(--on-forest-tint);
}

.banner .grow {
  flex: 1;
  min-width: 0;
}

.banner strong {
  display: block;
}

.toast {
  pointer-events: auto;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--surface-inverse);
  color: var(--text-inverse);
  box-shadow: var(--shadow-3);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--forest-300);
  flex: none;
}

.status-dot.is-offline {
  background: var(--amber-300);
}

.status-dot.is-error {
  background: var(--danger-500);
}

/* --------------------------------------------------------- znacky v mape */

.map-pin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 2px solid var(--pin-color, var(--forest-500));
  box-shadow: var(--shadow-1);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
}

.map-pin img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.map-pin.is-selected {
  outline: 3px solid var(--amber-500);
  outline-offset: 1px;
  transform: scale(1.12);
}

.map-pin.is-processed {
  opacity: 0.62;
  filter: grayscale(0.55);
}

.pile-pin {
  background: var(--amber-500);
  border-color: #fff;
  color: #2b1a04;
}

.pending-pin {
  background: var(--amber-300);
  border-color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.14);
  }
}

.draw-vertex {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: #fff;
  border: 2px solid var(--amber-500);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--amber-600);
  box-shadow: var(--shadow-1);
}

.draw-vertex.is-last {
  background: var(--amber-500);
  color: #fff;
}

/* --------------------------------------------------------------- legenda */

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.82rem;
}

.legend-swatch {
  width: 22px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex: none;
}

.legend-row .count {
  margin-left: auto;
  font-family: var(--font-numeric);
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- detail */

.detail-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 0;
  padding: 0;
  cursor: zoom-in;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.metric {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}

.metric b {
  display: block;
  font-family: var(--font-numeric);
  font-size: 1.06rem;
}

.metric span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.detail-actions .btn {
  flex: 1 1 40%;
}

/* ------------------------------------------------------- prohlizec fotky */

/*
  Prohlizec fotek. Pozadi je vzdy tmave (i ve svetlem rezimu), protoze fotka
  na tmavem pozadi vynikne a oko se nemusi prizpusobovat; texty jsou proto
  pevne svetle, ne z tokenu rezimu.
*/
.lightbox {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 10);
  background: #050a07;
  color: #f2f5f3;
  overscroll-behavior: contain;
}

.lightbox[hidden] {
  display: none;
}

html.lightbox-open,
html.lightbox-open body {
  overflow: hidden;
}

.lightbox-top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: calc(var(--space-2) + var(--safe-top)) var(--space-3) var(--space-2);
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
  pointer-events: none;
}

.lightbox-top > * {
  pointer-events: auto;
}

.lightbox-counter {
  font-family: var(--font-numeric);
  font-size: 0.9rem;
  font-weight: 650;
}

.lightbox .icon-btn {
  color: #ffffff;
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.18);
}

.lightbox-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.lightbox-stage.is-zoomed {
  cursor: move;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
  -webkit-user-drag: none;
}

.lightbox-stage img[hidden] {
  display: none;
}

.lightbox-status {
  max-width: 280px;
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.85;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
}

.lightbox-nav.is-prev {
  left: var(--space-2);
}

.lightbox-nav.is-next {
  right: var(--space-2);
}

.lightbox-caption {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  margin: 0;
  padding: var(--space-5) var(--space-4) calc(var(--space-3) + var(--safe-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  text-align: center;
  font-size: 0.9rem;
  pointer-events: none;
}

.lightbox-caption[hidden],
.lightbox-nav[hidden] {
  display: none;
}

/* --------------------------------------------------------- galerie fotek */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--space-2);
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}

.photo-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fotka, ktera je jen na serveru a bez signalu se nestahla. */
.photo-thumb.is-missing img {
  visibility: hidden;
}

.photo-thumb.is-missing::after {
  content: "";
  position: absolute;
  inset: 30%;
  background: currentColor;
  opacity: 0.18;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 8h4l1.5-2h5L16 8h4v11H4z'/%3E%3Ccircle cx='12' cy='13.5' r='3.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 8h4l1.5-2h5L16 8h4v11H4z'/%3E%3Ccircle cx='12' cy='13.5' r='3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.photo-more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  font-family: var(--font-numeric);
  font-size: 1.1rem;
  font-weight: 700;
}

.detail-gallery {
  display: grid;
  gap: var(--space-2);
}

.photo-hero {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  overflow: hidden;
  cursor: zoom-in;
}

.photo-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-hero.is-missing img {
  visibility: hidden;
}

.photo-hero.is-missing[data-missing]::after {
  content: attr(data-missing);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-3);
  color: var(--text-muted);
  font-size: 0.84rem;
  text-align: center;
}

.photo-count {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 650;
}

.inspection-photos {
  margin-top: var(--space-2);
}

/* Editor seznamu fotek ve formulari. */
.photo-editor {
  display: grid;
  gap: var(--space-2);
}

.photo-thumb-open {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.photo-thumb.is-main {
  border: 2px solid var(--accent);
}

.photo-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 700;
}

.photo-star {
  position: absolute;
  left: 2px;
  bottom: 2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  cursor: pointer;
}

.photo-star svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.photo-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  cursor: pointer;
}

.photo-remove svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.photo-actions .btn {
  cursor: pointer;
}

/* -------------------------------------------------------- import z fotek */

.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-2);
}

.import-tile {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  padding: 0;
  cursor: pointer;
}

.import-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.import-tile.is-selected {
  border-color: var(--accent);
}

.import-tile.no-gps {
  opacity: 0.55;
}

.import-tile .flag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
}

.import-tile .check {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ------------------------------------------------------------- pomocnici */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stack-lg {
  gap: var(--space-4);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.muted {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.section-title {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.divider {
  height: 1px;
  margin: var(--space-3) 0;
  background: var(--border);
  border: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------- ovladani mapy Leaflet */

/*
  Spodni panel prekryva spodni cast mapy, takze ovladani zoomu i podpis
  zdroje musime zvednout nad nej. Vyska panelu se meni tazenim, proto se
  ridime toutez promennou.
*/
.leaflet-bottom {
  bottom: var(--sheet-height, 42vh);
  transition: bottom 220ms cubic-bezier(0.2, 0, 0, 1);
}

@media (min-width: 900px) {
  .leaflet-bottom {
    bottom: 0;
  }
}

.leaflet-control-zoom a {
  width: 42px;
  height: 42px;
  line-height: 42px;
  font-size: 1.3rem;
  color: var(--text);
  background: var(--surface);
  border-bottom-color: var(--border);
}

.leaflet-control-zoom a:hover,
.leaflet-control-zoom a:focus {
  background: var(--surface-2);
  color: var(--text);
}

.leaflet-bar {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}

.leaflet-control-attribution {
  padding: 2px 8px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--text-muted);
  font-size: 0.68rem;
  border-radius: var(--radius-sm) 0 0 0;
}

.leaflet-control-attribution a {
  color: var(--text-muted);
}

/* Leaflet kresli popisky svetle, na tmavem podkladu by zmizely. */
.leaflet-container {
  background: var(--surface-2);
  font-family: var(--font);
}

/* ----------------------------------------------------- legendy vrstev */

.legend-box {
  margin: 0 var(--space-3) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.legend-box summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
  cursor: pointer;
}

.legend-box[open] summary {
  border-bottom: 1px solid var(--border);
}

/*
  Legendy z WMS jsou obrazky s pevnou sirkou a nekdy pres tisic pixelu
  na vysku, takze potrebuji vlastni posuvnik. Bily podklad je nutny:
  vetsina legend ma cerny text na pruhlednem pozadi, ktery by v tmavem
  rezimu zmizel.
*/
.legend-image {
  max-height: 260px;
  overflow: auto;
  padding: var(--space-2);
  background: #ffffff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.legend-image img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Latinsky nazev dreviny v detailu. Kurziva je u botanickych jmen zvykem. */
.species-latin {
  margin: -6px 0 0;
  font-style: italic;
}

.species-latin a {
  font-style: normal;
  font-weight: 650;
  color: var(--accent);
}

/* ------------------------------------------------------ arboristicky rezim */

/*
  Barvy nalehavosti jsou pevne (--urgency), protoze nesou vyznam i v mape.
  Na plochach se proto nepouzivaji jako pozadi pod textem, jen jako tecka,
  okraj a jemny nadech; text zustava v barve rezimu a ma kontrast v obou.
*/

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
}

.form-section {
  margin: var(--space-5) 0 var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

.mode-choice {
  display: grid;
  gap: var(--space-2);
}

.mode-option {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.mode-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.mode-option input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex: none;
}

.mode-option b {
  display: block;
}

.mode-option small {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.scale-field {
  margin-bottom: var(--space-3);
}

.scale-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px var(--space-2);
  margin-bottom: 6px;
}

.scale-head span {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
}

.scale-head small {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.scale-buttons {
  margin-bottom: 0;
}

.scale-buttons button {
  min-height: 44px;
  font-family: var(--font-numeric);
  font-size: 1rem;
}

.chip-row,
.quick-row,
.chip-line {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip-row {
  margin-bottom: var(--space-3);
}

.quick-row {
  margin: -6px 0 var(--space-3);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.chip span {
  font-family: var(--font-numeric);
  color: var(--text-muted);
}

.chip.is-active {
  border-color: var(--accent);
  background: var(--forest-100);
  color: var(--on-forest-tint);
}

.chip.is-active span {
  color: inherit;
}

.measure-card {
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.measure-card .row-between {
  margin-bottom: var(--space-2);
}

.urgency-buttons {
  margin-bottom: var(--space-2);
  background: var(--surface);
}

.urgency-buttons button {
  min-height: 44px;
  border: 2px solid transparent;
  font-family: var(--font-numeric);
  font-size: 1rem;
}

.urgency-buttons button::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--urgency);
  vertical-align: 1px;
}

.urgency-buttons button.is-active {
  border-color: var(--urgency);
  background: color-mix(in srgb, var(--urgency) 16%, var(--surface));
  color: var(--text);
}

.pill.urgency-pill {
  background: color-mix(in srgb, var(--urgency) 16%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--urgency) 55%, transparent);
  white-space: normal;
}

.pill.urgency-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--urgency);
  flex: none;
}

.assess-card {
  display: grid;
  gap: var(--space-2);
}

.assess-card .section-title {
  margin: 0;
}

.assess-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.assess-row > span {
  color: var(--text-muted);
  flex: none;
}

.assess-row b {
  text-align: right;
  font-family: var(--font-numeric);
}

.assess-row b small {
  font-family: var(--font);
  font-weight: 500;
}

.measure-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.measure-line:last-child {
  border-bottom: 0;
}

.measure-line small {
  display: block;
  color: var(--text-muted);
}

.measure-line.is-done .grow {
  opacity: 0.7;
}

.done-measures summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--text-muted);
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  position: relative;
  padding: 0 0 var(--space-3) var(--space-4);
  border-left: 2px solid var(--border);
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline p {
  margin: 2px 0 4px;
  font-size: 0.88rem;
}

.stat.is-warn b {
  color: var(--on-amber-tint);
}

.stat.is-danger b {
  color: var(--danger-500);
}

.record-badge.area-badge {
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

/* Strom v arboristicke mape: okraj nese nalehavost, proto silnejsi. */
.map-pin.is-arbor {
  border-width: 3px;
}

/* Strom po terminu kontroly: cerveny odznak v rohu znacky. */
.map-pin.is-overdue {
  position: relative;
}

.map-pin.is-overdue::after {
  content: "!";
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #c9432f;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.legend-swatch.is-round {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.legend-swatch.is-overdue-sample {
  background: #c9432f;
  box-shadow: inset 0 0 0 3px #ffffff;
  border-color: #c9432f;
}

.tree-number {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  font-family: var(--font-numeric);
  font-size: 0.82em;
  text-align: center;
}

.tree-number:empty {
  display: none;
}

/* Prvky schovavane podle rezimu projektu; jejich display by jinak prebil atribut hidden. */
.fab-mini[hidden],
.estimate[hidden],
.icon-btn[hidden] {
  display: none;
}

.measure-line .urgency-pill {
  flex: none;
  white-space: nowrap;
}

.coords-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.88rem;
}

.coords-row .muted {
  font-family: var(--font-numeric);
}

.nav-item.is-danger {
  color: var(--danger-500);
}

/* Tlacitko pro vyber fotky z galerie pod polem fotoaparatu. */
.photo-field + .photo-gallery {
  margin: calc(var(--space-2) * -1) 0 var(--space-3);
  cursor: pointer;
}

.share-link {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.share-link input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

/* V editoru vetsi nahledy, at jdou tlacitka odebrat a hlavni trefit prstem. */
.photo-grid.is-editable {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.photo-grid.is-editable .photo-remove,
.photo-grid.is-editable .photo-star {
  width: 36px;
  height: 36px;
}

/* Vyber ciloveho projektu pri presunu stromu; podprojekty odsazene pod rodicem. */
.move-targets {
  display: grid;
  gap: 2px;
  max-height: 50vh;
  overflow-y: auto;
}

.move-target.is-child {
  padding-left: var(--space-5);
}

.move-heading {
  margin: var(--space-2) 0 0;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
}
