:root {
  --ink: #1c1915;
  --muted: #6e655c;
  --paper: #f4f0e8;
  --card: #fffdf8;
  --line: #e3d9cc;
  --teal: #0f5e56;
  --teal-soft: #e6f3f0;
  --clay: #8d4030;
  --gold: #7a5b1e;
  --bs-primary: #0f5e56;
  --bs-primary-rgb: 15, 94, 86;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-body-font-family: "Segoe UI", "Liberation Sans", "Nimbus Sans", sans-serif;
  --bs-link-color: var(--teal);
  --bs-border-radius: 0.55rem;
  color-scheme: light;
}

body {
  min-height: 100vh;
}

.app-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.45rem;
  background: var(--teal);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.1;
}

.brand-sub,
.kicker,
.app-footer,
.hit-count {
  color: var(--muted);
}

.brand-sub {
  display: block;
  font-size: 0.86rem;
}

.kicker {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.dropzone {
  max-width: 46rem;
  margin: 6vh auto;
  background: var(--card);
  border: 1.5px dashed #c3b6a4;
  border-radius: 1rem;
  padding: 3rem 1.5rem;
  text-align: center;
}

.dropzone h1,
.file-name {
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0;
}

.lead-quiet {
  color: var(--muted);
  max-width: 36rem;
  margin: 0.75rem auto 0;
}

.welcome-error {
  color: var(--clay);
  margin-top: 1rem;
}

.workspace-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 1rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.7rem 0.85rem;
}

.stat b {
  display: block;
  font-weight: 600;
  margin-top: 0.1rem;
}

.stat.ok b { color: var(--teal); }
.stat.bad b { color: var(--clay); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.9rem 0.7rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.panel-head h2 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

.panel-head .btn-link {
  color: var(--teal);
  text-decoration: none;
  padding-inline: 0.2rem;
}

.search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

#search {
  margin: 0.45rem 0 0.55rem;
  background: #fbf8f2;
  border-color: var(--line);
}

.tree,
.detail {
  overflow: auto;
  max-height: calc(100vh - 18.5rem);
  padding-right: 0.2rem;
}

.t-kids {
  margin-left: 0.7rem;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line);
}

.t-line {
  display: flex;
  align-items: stretch;
  gap: 0.1rem;
}

.chev,
.t-row,
.child-link {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.chev {
  width: 1.35rem;
  flex: none;
  color: var(--muted);
  border-radius: 0.3rem;
}

.chev svg {
  display: block;
  margin: 0.45rem auto 0;
  transition: transform 0.12s linear;
}

.chev[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

.t-row,
.child-link {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  width: 100%;
  border-radius: 0.4rem;
  padding: 0.22rem 0.35rem;
}

.t-row:hover,
.child-link:hover,
.chev:hover {
  background: #f3efe6;
}

.t-row.is-selected,
.child-link.is-selected {
  background: var(--teal-soft);
  box-shadow: inset 2px 0 0 var(--teal);
}

.t-label {
  min-width: 0;
}

.t-meta {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.t-value {
  margin-left: auto;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.fk,
.obj-id,
code.source {
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.fk {
  flex: none;
  font-size: 0.75rem;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 0.25rem;
  padding: 0 0.32rem;
}

.fk.satz {
  color: var(--clay);
  background: #f8ece7;
}

.obj-id {
  font-size: 0.75rem;
  color: var(--gold);
}

.meaning {
  color: var(--teal);
}

.muted {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

mark {
  background: #f3e2a4;
  padding: 0 0.1rem;
  border-radius: 0.15rem;
}

.detail h3 {
  font-size: 1.25rem;
  margin: 0 0 0.25rem;
}

.crumbs {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.7rem;
}

.crumbs button {
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 0;
}

.value-block {
  font-size: 1.25rem;
  margin: 0.4rem 0 0.8rem;
  overflow-wrap: anywhere;
}

.field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.field-table th {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.field-table th,
.field-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.38rem 0.3rem;
  vertical-align: top;
  text-align: left;
}

.field-table tr.is-selected td {
  background: var(--teal-soft);
}

.child-link {
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  margin-top: 0.35rem;
}

code.source {
  display: block;
  background: #f6f1e8;
  border-radius: 0.4rem;
  padding: 0.45rem 0.6rem;
  overflow-x: auto;
  font-size: 0.82rem;
}

.app-footer {
  padding: 1.2rem 1rem 1.6rem;
  font-size: 0.82rem;
  text-align: center;
}

#drop-overlay {
  position: fixed;
  inset: 0.6rem;
  z-index: 40;
  border: 3px dashed var(--teal);
  border-radius: 1rem;
  background: rgba(244, 240, 232, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--teal);
  pointer-events: none;
}

.alert {
  border-radius: 0.7rem;
}

@media (max-width: 991px) {
  .tree,
  .detail {
    max-height: none;
  }

  .panel {
    min-height: 0;
  }
}
