html, body {
  margin: 0;
  border-radius: 0 !important;
  height: 100%;
  background: #ffffff;
  background-image: radial-gradient(rgba(0,0,0,0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
}

/* Graafi ala */
#network {
  width: 100%;
  height: 88vh;
  background: #ffffff;
  background-image: radial-gradient(rgba(0,0,0,0.02) 1px, transparent 1px);
  background-size: 32px 32px;
}

.col-md-8 {
  flex: 0 0 75%;
  max-width: 75%;
}
.col-md-4 {
  flex: 0 0 25%;
  max-width: 25%;
}

#loading {
  font-style: italic;
  color: #888;
  display: none;
}

.row.same-height {
  align-items: flex-start;
}

/* === HEADER === */
header {
  position: sticky;
  top: 0;
  z-index: 1200;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  color: #222;
}

/* Otsinguvorm */
#searchForm {
  position: relative;
  background: rgba(255,255,255,0.8);
  border-radius: 40px;
  padding: 8px 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.06);
}

/* Input */
#skillInput {
  background: transparent;
  border: none;
  color: #222;
}
#skillInput::placeholder { color: #999; }

/* Luuubi nupp */
#searchForm .btn {
  border: none;
  border-radius: 30px;
  background: linear-gradient(90deg, #007aff, #00c6ff);
  color: #fff;
  transition: 0.25s;
}
#searchForm .btn:hover { background: linear-gradient(90deg, #0062d1, #00a0e0); }

/* DROPDOWN */
#searchDropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1300;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  margin-top: 6px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
#searchDropdown .dropdown-item { color: #222; cursor: pointer; }
#searchDropdown .dropdown-item:hover { background: #f0f6ff; }

/* Logo wrapper */
.logo-link {
  color: #222;
  font-weight: 700;
  font-size: 1.5rem;
  transition: color 0.2s;
}
.logo-link:hover { color: #007aff; }

.logo-img {
  height: 45px;
  width: auto;
  filter: brightness(1) contrast(1.1);
}

/* Logo tekst */
.logo-text {
  font-weight: 700;
  font-size: 1.7rem;
  background: linear-gradient(90deg, #007aff, #8b6cff, #c07dff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Filter chip */
.filter-chip {
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 20px;
  padding: 4px 12px;
  background: #f8f9fa;
  color: #222;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.filter-chip:hover {
  background: #eaf3ff;
  color: #007aff;
  border-color: #007aff;
}

/* === SKILL INFO === */
#skillInfo {
  position: fixed;
  top: 90px;
  right: 20px;
  max-width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  background: #ffffff;
  border-radius: 18px;
  padding: 20px;
  color: #222;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.05);
  display: none;
}
#skillInfo.show {
  display: flex;
  flex-direction: column;
}

/* Pealkiri gradient */
.skill-info h5 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #007aff, #9b5dff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Tekstid */
.skill-info p,
.skill-info div {
  margin-bottom: 10px;
  color: #444;
  font-size: 1rem;
  line-height: 1.6;
}

/* Lingid */
.skill-info a {
  color: #007aff;
  text-decoration: none;
  font-weight: 500;
}
.skill-info a:hover {
  text-decoration: underline;
  color: #005ecb;
}

/* Nupud */
.skill-info a.btn {
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.9rem;
  background: #007aff;
  color: #fff;
  border: none;
  transition: background 0.2s, transform 0.2s;
}
.skill-info a.btn:hover {
  background: #005ecb;
  transform: translateY(-2px);
}

/* InfoLink */
#infoLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-top: 12px;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  background: #007aff;
  color: #fff;
  border: none;
  transition: all 0.25s ease;
}
#infoLink:hover {
  background: #005ecb;
  transform: translateY(-2px);
}

/* === MODAL === */
.modal-content {
  background: #ffffff;
  border-radius: 18px;
  color: #222;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

/* Modal header */
.modal-header {
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.modal-title {
  font-weight: 700;
  font-size: 1.3rem;
  background: linear-gradient(90deg, #007aff, #b67cff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Modal body */
.modal-body {
  color: #333;
}
.modal-body h6 {
  margin-top: 1rem;
  font-size: 1rem;
  color: #555;
}

/* Modal footer */
.modal-footer {
  border-top: 1px solid rgba(0,0,0,0.08);
}
.modal-footer .btn {
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.9rem;
  background: #007aff;
  color: #fff;
  border: none;
  transition: background 0.2s, transform 0.2s;
}
.modal-footer .btn:hover {
  background: #005ecb;
  transform: translateY(-2px);
}

/* Vorm */
.modal-body .form-select,
.modal-body .form-control {
  background: #f8f9fa;
  border: 1px solid rgba(0,0,0,0.1);
  color: #222;
}
.modal-body .form-select:focus,
.modal-body .form-control:focus {
  background: #fff;
  border-color: #007aff;
  box-shadow: 0 0 0 2px rgba(0,122,255,0.25);
}

/* Checkbox */
.form-check-input {
  background-color: #e9e9e9;
  border: 1px solid rgba(0,0,0,0.2);
}
.form-check-input:checked {
  background-color: #007aff;
  border-color: #007aff;
}

/* Select */
#levelSelect.form-select {
  background: #f8f9fa;
  border: 1px solid rgba(0,0,0,0.1);
  color: #333;
}
#levelSelect.form-select option {
  background: #fff;
  color: #333;
}
#levelSelect.form-select:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 2px rgba(0,122,255,0.25);
}

/* --- Sync Overlay --- */
.sync-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 20, 0.75);
  backdrop-filter: blur(8px);
  z-index: 4000;
  transition: opacity 0.3s ease;
}

.sync-overlay.d-none {
  display: none;
}

.sync-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 2.5rem 3rem;
  text-align: center;
  color: #fff;
  min-width: 400px;
  max-width: 90%;
  animation: popIn 0.25s ease-out;
  backdrop-filter: blur(12px);
}

.sync-spinner .spinner-border {
  width: 3rem;
  height: 3rem;
}

.progress {
  border-radius: 12px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.1);
}

@keyframes popIn {
  from { transform: translateY(10px) scale(0.97); opacity: 0; }
  to { transform: translateY(0); scale: 1; opacity: 1; }
}

/* === SEOSTE HALDUSE MODAAL === */

/* Header on sticky z-index: 1200 peal, Bootstrapi modaal vaikimisi 1055 —
   ilma selleta jääks päis modaali ette. */
.modal { z-index: 1400; }
.modal-backdrop { z-index: 1390; }

/* Atribuudirida tipu tüüpide vormis: property → välja nimi → eemalda */
.attr-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.attr-row .attr-arrow {
  color: #9097a3;
  font-size: 0.9rem;
}

#addRelationModal .modal-dialog,
#addNodeTypeModal .modal-dialog {
  /* --bs-modal-margin hoiab Bootstrapi tsentreerimis- ja kõrgusarvutused
     terved; siin annab see päisest ja põhjast 1.75rem õhku. */
  --bs-modal-margin: 1.75rem;
  /* Lai, aga alati aknasse mahtuv: horisontaalset kerimist ei teki. */
  max-width: min(1080px, calc(100vw - 3rem));
}

#addRelationModal .modal-header,
#addNodeTypeModal .modal-header {
  align-items: flex-start;
  padding: 1.25rem 1.75rem 1rem;
}
#addRelationModal .modal-header code,
#addNodeTypeModal .modal-header code {
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 5px;
  color: #555;
}

#addRelationModal .modal-body,
#addNodeTypeModal .modal-body {
  padding: 1.25rem 1.75rem 1.75rem;
}

/* Vormi ja tabeli vaheline eraldus */
#addRelationModal .relation-form-grid,
#addNodeTypeModal .relation-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.5rem;
}
@media (max-width: 767px) {
  #addRelationModal .relation-form-grid,
#addNodeTypeModal .relation-form-grid { grid-template-columns: 1fr; }
}
#addRelationModal .relation-form-grid .grid-full,
#addNodeTypeModal .relation-form-grid .grid-full { grid-column: 1 / -1; }

/* Allikatüüpide ja seosefiltrite linnukesed — ühtlane "chip" välimus */
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  background: #f8f9fa;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.type-chip:hover { background: #eef4ff; border-color: rgba(0, 122, 255, 0.35); }
.type-chip input { cursor: pointer; margin: 0; }
.type-chip:has(input:checked) {
  background: #eaf3ff;
  border-color: #007aff;
  color: #0a58ca;
}

/* Seoste tabel: sisu murrab rida, mitte ei aja akent laiaks */
#addRelationModal .relation-table,
#addNodeTypeModal .relation-table { table-layout: fixed; width: 100%; }
#addRelationModal .relation-table th,
#addRelationModal .relation-table td,
#addNodeTypeModal .relation-table th,
#addNodeTypeModal .relation-table td {
  vertical-align: middle;
  overflow-wrap: anywhere;
}
#addRelationModal .relation-table .col-dot,
#addNodeTypeModal .relation-table .col-dot { width: 28px; }
#addRelationModal .relation-table .col-actions,
#addNodeTypeModal .relation-table .col-actions { width: 150px; }
#addRelationModal .relation-table code,
#addNodeTypeModal .relation-table code {
  font-size: 0.8rem;
  color: #0a58ca;
  background: rgba(10, 88, 202, 0.07);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ===================== STARDIVALIKU EKRAAN ===================== */
#startScreen {
  min-height: calc(100vh - 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 32px;
  background: #f5f7fb;
}
#startScreen .start-card {
  width: 100%;
  max-width: 860px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(20, 40, 80, 0.10);
  overflow: hidden;
}
#startScreen .start-head { padding: 36px 40px 8px; }
#startScreen .start-head h1 { font-weight: 700; font-size: 1.7rem; letter-spacing: -0.01em; margin-bottom: 6px; }
#startScreen .start-head p { color: #6b7280; margin: 0; }
#startScreen .start-body { padding: 20px 40px 8px; }
#startScreen .section-label {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
  color: #9097a3; font-weight: 600; margin: 22px 0 12px;
}

/* --- Avalehe 2 valikukasti --- */
#startScreen .choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 620px) { #startScreen .choice-grid { grid-template-columns: 1fr; } }
#startScreen .choice-card {
  border: 1.5px solid #e3e7ef; background: #fff; border-radius: 16px;
  padding: 28px 20px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center;
  min-height: 160px; color: #2c3340; transition: all .15s ease;
}
#startScreen .choice-card:hover { border-color: #bcd0ff; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20,40,80,.10); }
#startScreen .choice-card .ic { font-size: 2rem; color: #2f6bff; line-height: 1; }
#startScreen .choice-card .name { font-size: 1.15rem; font-weight: 700; }
#startScreen .choice-card .desc { font-size: .9rem; color: #6b7280; }

/* --- Explore-kontrollid: vasaku serva sakk + hover-flyout --- */
/* Hõljub graafi peal, et mitte lisada layout-kõrgust (muidu tekib scroll). */
#graphContainer { position: relative; }
.explore-panel { position: absolute; top: 70px; left: 0; z-index: 6; }
.explore-handle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 34px; min-height: 76px; padding: 8px 0;
  background: rgba(245, 247, 251, 0.97); border: 1px solid #e3e7ef; border-left: none;
  border-radius: 0 12px 12px 0; cursor: pointer; color: #2f6bff;
  box-shadow: 0 4px 12px rgba(20, 40, 80, .08);
}
.explore-handle .explore-chevron { font-size: .8rem; transition: transform .18s ease; }
.explore-panel:hover .explore-handle .explore-chevron { transform: rotate(180deg); }
.explore-flyout {
  position: absolute; top: 0; left: 34px; width: 280px;
  padding: 12px 14px;
  background: rgba(245, 247, 251, 0.98); border: 1px solid #e3e7ef;
  border-radius: 0 12px 12px 0; box-shadow: 0 8px 24px rgba(20, 40, 80, .12);
  opacity: 0; visibility: hidden; transform: translateX(-8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.explore-panel:hover .explore-flyout { opacity: 1; visibility: visible; transform: translateX(0); }
.depth-stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.depth-stepper .depth-label { font-weight: 600; color: #2c3340; }
.depth-stepper .depth-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid #cfd6e4;
  background: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; color: #2c3340;
}
.depth-stepper .depth-btn:hover { border-color: #2f6bff; color: #2f6bff; }
.depth-stepper .depth-value { min-width: 22px; text-align: center; font-weight: 700; }
.pieces-wrap { display: block; }
.pieces-wrap .pieces-label { display: block; font-weight: 600; color: #6b7280; margin-bottom: 6px; }
.pieces-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 40vh; overflow-y: auto; }
.piece-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef3ff; color: #1c47b8; border: 1px solid #cddcff;
  border-radius: 999px; padding: 3px 8px; font-size: .9rem;
}
.piece-chip.piece-hidden { opacity: .5; }
.piece-chip .piece-eye {
  border: none; background: transparent; color: #1c47b8; cursor: pointer;
  font-size: .9rem; line-height: 1; padding: 0 2px; display: inline-flex; align-items: center;
}
.piece-chip .piece-eye:hover { color: #2f6bff; }
.piece-chip .piece-remove {
  border: none; background: transparent; color: #1c47b8; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0 2px;
}
.piece-chip .piece-remove:hover { color: #d63031; }

