 @import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Poiret+One&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Macondo&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Mountains+of+Christmas:wght@400;700&display=swap");

:root {
  --fnt-macondo: "Macondo", cursive;
  --fnt-mountains: "Mountains of Christmas", cursive;
  --fnt-poiret: "Poiret One", sans-serif;
  --fnt-quicksand: "Quicksand", "Segoe UI", sans-serif;

  --bgi: none;
  --bgi1: none;

  --bg:
    radial-gradient(
      circle at 0% 0%,
      rgba(255, 255, 255, 0.035) 0%,
      rgba(255, 255, 255, 0) 28%
    ),
    radial-gradient(
      circle at 100% 0%,
      rgba(255, 255, 255, 0.028) 0%,
      rgba(255, 255, 255, 0) 28%
    ),
    radial-gradient(
      circle at 100% 100%,
      rgba(255, 255, 255, 0.02) 0%,
      rgba(255, 255, 255, 0) 32%
    ),
    radial-gradient(
      circle at 0% 100%,
      rgba(255, 255, 255, 0.018) 0%,
      rgba(255, 255, 255, 0) 30%
    ),
    linear-gradient(180deg, #090909 0%, #111214 45%, #17181b 100%);

  --panel: rgba(18, 18, 19, 0.96);
  --glass: rgba(24, 24, 26, 0.94);
  --card: rgba(24, 24, 26, 0.98);
  --card-soft: rgba(31, 31, 34, 0.96);

  --accent: #d5d9df;
  --accent-soft: rgba(213, 217, 223, 0.1);
  --accent-strong: #f5f7fa;
  --accent-2: #8f959d;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --danger: #ff6b6b;

  --text-main: #f3f4f6;
  --text-muted: #a3a9b2;
  --text-soft: #7d848d;
  --pill: rgba(32, 32, 35, 0.95);

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-pill: 999px;

  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.42), 0 14px 36px rgba(0, 0, 0, 0.42);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.42), 0 10px 28px rgba(0, 0, 0, 0.36);
  --shadow-pop:
    0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 14px 32px rgba(0, 0, 0, 0.48);

  --blr: blur(10px);
}

* {
  box-sizing: border-box;
  font-family: var(--fnt-quicksand);
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  color: var(--text-main);
  align-items: stretch;
  justify-content: center;
}

/* =========================
     Material Symbols
     ========================= */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings:
    "FILL" 0,
    "wght" 500,
    "GRAD" 0,
    "opsz" 24;
}

.icon-tonal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-strong);
}

.btn-primary .material-symbols-outlined.icon-tonal,
.btn-accent .material-symbols-outlined.icon-tonal,
.btn-outline .material-symbols-outlined.icon-tonal,
.btn-chip .material-symbols-outlined.icon-tonal {
  font-size: 20px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
}

/* =========================
     App layout
     ========================= */
.app-shell {
  max-width: 95%;
  width: 100%;
  margin: 20px auto;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

/* =========================
     Sidebar
     ========================= */
.sidebar {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 18px 16px 14px;
  backdrop-filter: var(--blr);
  -webkit-backdrop-filter: var(--blr);
  position: relative;
  overflow: hidden;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.01)
  );
  pointer-events: none;
}

.sidebar-header {
  padding-top: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-title h1 {
  font-size: 16px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text-main);
}

.sidebar-title span {
  font-size: 11px;
  color: var(--text-muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: #1b1c1f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  color: var(--accent-strong) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #d7dbe0;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
}

.sidebar-search {
  margin: 10px 0 10px;
  position: relative;
  z-index: 1;
}

.sidebar-search input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 12px;
  font-size: 12px;
  background: #111214;
  color: var(--text-main);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.sidebar-search input::placeholder {
  color: var(--text-soft);
}

.sidebar-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 4px 2px;
}

.sidebar-list {
  margin-top: 4px;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 6px;
  position: relative;
  z-index: 1;
}

.entry-toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 12px;
}

.tiny-label {
  font-size: 11px;
  opacity: 0.84;
  color: var(--text-muted);
}

#entrySortMode {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #111214;
  color: var(--text-main);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.entry-item {
  width: 100%;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  background: linear-gradient(180deg, #18191b 0%, #141517 100%);
  color: var(--text-main);
  cursor: pointer;
  font-size: 12px;
  min-height: 78px;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.entry-item:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #1d1e21 0%, #17181b 100%);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.entry-item.selected {
  border-color: rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, #202225 0%, #191b1e 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 12px 28px rgba(0, 0, 0, 0.42);
}

.entry-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #2a2b2f 0%, #1d1e22 100%);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
  align-self: start;
  flex-shrink: 0;
}

.entry-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.entry-main {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  padding-top: 2px;
}

.entry-name {
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
}

.entry-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.entry-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-self: start;
  justify-self: end;
  padding-top: 2px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0;
  font-size: 12px;
  cursor: pointer;
  background: linear-gradient(180deg, #1c1d20 0%, #151619 100%);
  color: var(--text-main);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 8px 18px rgba(0, 0, 0, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: linear-gradient(180deg, #24262a 0%, #1b1d20 100%);
}

@media (max-width: 640px) {
  .entry-item {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    padding: 10px 12px;
    gap: 10px;
    min-height: 72px;
  }

  .entry-avatar {
    width: 48px;
    height: 48px;
  }

  .entry-name {
    font-size: 12px;
  }

  .icon-btn {
    width: 28px;
    height: 28px;
  }
}

.sidebar-footer {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}

/* =========================
     Buttons
     ========================= */
.btn-primary,
.btn-ghost,
.btn-secondary {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 9px 12px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #1c1d20 0%, #151619 100%);
  color: var(--text-main);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 8px 18px rgba(0, 0, 0, 0.24);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.btn-primary:hover,
.btn-ghost:hover,
.btn-secondary:hover,
.btn-outline:hover,
.btn-chip:hover,
.btn-accent:hover,
.btn-icon-only:hover {
  transform: translateY(-1px);
}

.btn-primary {
  border-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #2a2c30 0%, #1e2024 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--shadow-pop);
}

.btn-ghost:hover,
.btn-secondary:hover {
  background: linear-gradient(180deg, #24262a 0%, #1b1d20 100%);
}

#addEntryBtn {
  background: linear-gradient(180deg, #2a2c30 0%, #1e2024 100%);
  border-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 16px;
  padding-inline: 16px;
  font-weight: 700;
  box-shadow: var(--shadow-pop);
}

.btn-outline,
.btn-chip {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 7px 11px;
  font-size: 11px;
  cursor: pointer;
  background: linear-gradient(180deg, #1c1d20 0%, #151619 100%);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 8px 18px rgba(0, 0, 0, 0.22);
}

.btn-chip.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #2b2e33 0%, #202329 100%);
}

.btn-accent {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 9px 13px;
  font-size: 12px;
  cursor: pointer;
  background: linear-gradient(180deg, #2a2c30 0%, #1e2024 100%);
  color: #ffffff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-pop);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-icon-only {
  width: 30px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #1c1d20 0%, #151619 100%);
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 8px 18px rgba(0, 0, 0, 0.22);
}

/* =========================
     Main panel
     ========================= */
.main {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  backdrop-filter: var(--blr);
  -webkit-backdrop-filter: var(--blr);
  overflow: hidden;
}

.main::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.01)
  );
  pointer-events: none;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 2px;
  position: relative;
  z-index: 1;
}

.main-title-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.main-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.badge {
  font-size: 10px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: #1b1c1f;
  color: var(--accent-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.main-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.main-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.tag-row span {
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: #1b1c1f;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* =========================
     Search / tabs
     ========================= */
.record-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 16px;
  padding: 10px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.record-search-wrap .material-symbols-outlined {
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.record-search-wrap input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: #111214;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.record-search-wrap input::placeholder,
.field-row input::placeholder,
.field-row textarea::placeholder,
.image-name-input::placeholder,
.image-url-input::placeholder,
.entry-input::placeholder {
  color: var(--text-soft);
  opacity: 1;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.record-search-wrap input:focus,
.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus,
.entry-input:focus,
.image-name-input:focus,
.image-url-input:focus,
.sidebar-search input:focus,
#entrySortMode:focus {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

#clearRecordSearchBtn,
#clearEntrySearchBtn {
  height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #1c1d20 0%, #151619 100%);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 8px 18px rgba(0, 0, 0, 0.2);
}

#clearRecordSearchBtn:hover,
#clearEntrySearchBtn:hover {
  background: linear-gradient(180deg, #24262a 0%, #1b1d20 100%);
}

#clearRecordSearchBtn:active,
#clearEntrySearchBtn:active {
  transform: translateY(1px);
}

.tabs {
  border-radius: 18px;
  padding: 4px;
  margin-top: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.03);
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.tab-btn.active {
  background: linear-gradient(180deg, #2b2e33 0%, #202329 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

/* =========================
     View shell
     ========================= */
.view-shell {
  margin-top: 8px;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.view-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.view-header-row strong {
  color: var(--text-main);
}

.view-header-row .filters {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1b1c1f;
  color: var(--text-muted);
  font-size: 11px;
}

.chip strong {
  color: var(--accent-strong);
}

.empty-state {
  padding: 32px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.empty-state h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--text-main);
}

.empty-state p {
  margin: 0 0 10px;
}

/* =========================
     Gallery
     ========================= */
.gallery-grid {
  column-count: 4;
  column-gap: 14px;
  align-items: start;
}

.gallery-card {
  width: 100%;
  display: inline-block;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 14px;
  background: var(--card);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px;
  box-shadow: var(--shadow-card);
  vertical-align: top;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.gallery-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pill-type {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1b1c1f;
  color: var(--text-main);
}

.pill-type.both_versions,
.pill-type.behavior,
.pill-type.academic {
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--accent-strong);
  background: #202226;
}

.gallery-card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--text-main);
}

.gallery-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.gallery-card-notes {
  font-size: 12px;
  color: var(--text-main);
  margin-bottom: 8px;
  word-break: break-word;
  line-height: 1.45;
}

.gallery-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  gap: 8px;
}

.gallery-card-footer-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gallery-card-actions,
.timeline-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.emoji-bubble {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  background: #202226;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.gallery-card-image {
  margin: 10px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #111214;
  display: block;
  cursor: pointer;
  padding: 0;
}

.gallery-card-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  border: 0;
  border-radius: 0;
}

.gallery-card-image-info {
  font-size: 11px;
  color: var(--text-muted);
  padding: 9px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: #18191c;
  min-width: 0;
}

/* =========================
     Table
     ========================= */
.table-wrapper {
  overflow-x: auto;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead {
  background: #18191c;
  color: var(--text-main);
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

/* =========================
     Timeline
     ========================= */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
}

.timeline-group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.timeline-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  font-size: 12px;
  align-items: flex-start;
}

.timeline-date {
  color: var(--text-muted);
  padding-top: 8px;
}

.timeline-card {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--card);
  padding: 10px 12px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.timeline-card-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-main);
}

.timeline-card-body {
  font-size: 12px;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.45;
}

.timeline-card-footer {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  color: var(--text-muted);
  background: #1b1c1f;
  flex-shrink: 0;
}

/* =========================
     Import / export
     ========================= */
.import-export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: #1b1c1f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.mode-toggle select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 11px;
  outline: none;
}

.tiny {
  font-size: 10px;
  color: var(--text-muted);
}

.hint {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.45;
}

.list-chip-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.list-item-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  position: relative;
  overflow: visible;
}

.list-item-row input,
.list-item-row select {
  flex: 1;
  min-width: 0;
}

.list-item-row select,
.field-row select,
#entrySortMode,
#recordEntrySelect,
#recordSubject,
#recordTopic,
#newTopicSubject {
  min-width: 0;
  width: 100%;
  position: relative;
  z-index: 1;
  transition:
    min-width 0.18s ease,
    width 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.list-item-row select:hover,
.list-item-row select:focus,
.field-row select:hover,
.field-row select:focus,
#entrySortMode:hover,
#entrySortMode:focus,
#recordEntrySelect:hover,
#recordEntrySelect:focus,
#recordSubject:hover,
#recordSubject:focus,
#recordTopic:hover,
#recordTopic:focus,
#newTopicSubject:hover,
#newTopicSubject:focus {
  min-width: 320px;
  width: auto;
  z-index: 20;
}

/* =========================
     Original modal system
     ========================= */
.modal-backdrop {
  width: 100%;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: linear-gradient(180deg, #1a1b1e 0%, #151619 100%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
  padding: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.field-row select,
.list-item-row select,
#entrySortMode,
#recordEntrySelect,
#recordSubject,
#recordTopic,
#newTopicSubject {
  white-space: nowrap;
}
.modal-close {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #1c1d20 0%, #151619 100%);
  color: var(--text-main);
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 8px 18px rgba(0, 0, 0, 0.22);
}

.modal-close:hover {
  background: linear-gradient(180deg, #24262a 0%, #1b1d20 100%);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
  font-size: 13px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-row label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.field-row input,
.field-row select,
.field-row textarea,
.image-name-input,
.image-url-input {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #111214;
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 12px;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.field-row textarea {
  resize: vertical;
  min-height: 88px;
}

/* =========================
     Entry modal-specific inner styling
     ========================= */
.entry-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
  font-size: 13px;
}

.entry-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entry-field-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.entry-input {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #111214;
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 12px;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.entry-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* =========================
     Image editor rows
     ========================= */
.image-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.image-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 16px;
  background: #18191c;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.image-row-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.image-row-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-row .btn-icon-only {
  width: 28px;
  height: 28px;
}

/* =========================
     Image viewer modal
     ========================= */
.image-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#imageModalImg {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-card);
  background: #111214;
}

/* =========================
     Scrollbars
     ========================= */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #0f1012;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: #2a2c30;
  border-radius: 999px;
  border: 2px solid #0f1012;
}

*::-webkit-scrollbar-thumb:hover {
  background: #35383d;
}

/* =========================
     Responsive
     ========================= */
@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    order: 1;
  }

  .main {
    order: 2;
  }
}

@media (max-width: 1100px) {
  .gallery-grid {
    column-count: 3;
  }
}

@media (max-width: 720px) {
  .gallery-grid {
    column-count: 2;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .main-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .record-search-wrap {
    flex-wrap: wrap;
  }

  .record-search-wrap button,
  .record-search-wrap input,
  #clearRecordSearchBtn {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .gallery-grid {
    column-count: 1;
  }

  .modal,
  .modal-backdrop {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .image-row {
    grid-template-columns: 1fr;
  }

  .image-row-controls {
    flex-direction: row;
  }
}
