.side-panel {
  flex: 1 1 58%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow: hidden;
}

.side-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  flex: 0 0 auto;
}

.tab-button {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  padding: var(--space-2) var(--space-3);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
}

.tab-button.active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

.tab-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--space-2) var(--space-3);
  overflow: hidden;
}

.tab-content[hidden] { display: none; }

/* Master-detail: list-view and detail-view are mutually exclusive, each
   filling the full tab-content height when shown, so the detail view never
   has to compete with the list for space. */
.list-view,
.detail-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.list-view[hidden],
.detail-view[hidden] { display: none; }

.detail-back-button {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-bottom: var(--space-2);
  padding: 4px 10px 4px 6px;
  border: none;
  background: none;
  color: var(--color-accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
}

.detail-back-button:hover {
  background: rgba(122, 92, 46, 0.08);
}

.typeahead {
  position: relative;
  flex: 0 0 auto;
  margin-bottom: var(--space-2);
}

.typeahead-input {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.typeahead-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

.entity-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.entity-list-group-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 6px var(--space-2);
  margin-top: var(--space-1);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.entity-list-group-header:first-child {
  margin-top: 0;
}

.entity-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  border-radius: var(--radius);
}

.entity-row:hover,
.entity-row.is-active-cursor {
  background: rgba(122, 92, 46, 0.08);
}

.entity-row-side {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  align-self: center;
}

.entity-row-side--achaean { background: var(--color-achaean); }
.entity-row-side--trojan  { background: var(--color-trojan); }
.entity-row-side--ally    { background: var(--color-ally); }
.entity-row-side--neutral { background: var(--color-neutral); }

.entity-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.entity-row-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.entity-row-name mark {
  background: #fdf0d5;
  color: inherit;
  padding: 0;
}

.entity-row-name-greek {
  font-family: var(--font-greek);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.entity-row-desc {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entity-row-badge {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0 4px;
}

.entity-detail {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px var(--space-2) 2px;
}

.entity-detail[hidden] { display: none; }

.entity-detail-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 3px solid var(--entity-accent, var(--color-border));
}

.entity-detail-header h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.2;
}

.entity-detail-header .entity-detail-subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.entity-detail-name-greek {
  font-family: var(--font-greek);
  font-weight: 400;
  font-size: 1rem;
  color: var(--color-text-muted);
}

.entity-detail .detail-section {
  margin-bottom: var(--space-4);
}

.entity-detail .detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  margin-bottom: 4px;
}

.entity-detail .detail-body {
  font-size: 0.95rem;
  line-height: 1.5;
}

.entity-detail .occurrence-link {
  display: inline-block;
  margin: 0 var(--space-2) 4px 0;
  padding: 2px 8px;
  font-size: 0.85rem;
  color: var(--color-accent);
  background: rgba(122, 92, 46, 0.08);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
}

.entity-detail .occurrence-link:hover {
  background: rgba(122, 92, 46, 0.18);
  text-decoration: underline;
}

.entity-detail .relationship-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 0.95rem;
}

.entity-detail-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

.entity-detail-actions button {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-accent);
  cursor: pointer;
}

.entity-detail-actions button:hover {
  background: var(--color-accent);
  color: #fff;
}
