/* Copyright © 2026 Kshanti Greene. All rights reserved. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --text: #e8e8e8;
  --panel-bg: #1a1a1a;
  --panel-border: #2e2e2e;
  --input-bg: #44445d;
  --input-focus-border: #555;
  --btn-bg: #2e2e2e;
  --btn-border: #444;
  --btn-hover-bg: #3a3a3a;
}

body.light-theme {
  --bg: #f5f5f5;
  --text: #1a1a1a;
  --panel-bg: #ffffff;
  --panel-border: #d0d0d0;
  --input-bg: #eef0f8;
  --input-focus-border: #999;
  --btn-bg: #e6e6e6;
  --btn-border: #bbb;
  --btn-hover-bg: #d6d6d6;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh; /* prevents iOS Safari address-bar overlap */
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

#top-row {
  display: flex;
  gap: 8px;
  height: 140px;
  flex-shrink: 0;
}

.panel-top-side {
  width: 200px;
  flex-shrink: 0;
}

.panel-top-center {
  flex: 1;
}

#bottom-row {
  display: flex;
  gap: 8px;
  height: 140px;
  flex-shrink: 0;
}

.panel-bottom-side {
  width: 200px;
  flex-shrink: 0;
}

.panel-bottom-center {
  flex: 1;
}

#middle-row {
  flex: 1;
  display: flex;
  gap: 8px;
  min-height: 0;
}

.panel-left,
.panel-right {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  overflow-y: auto;
}

/* Right panel overrides for the persistent search bar + scrollable content */
#panel-right {
  overflow-y: hidden;
  gap: 0;
  padding: 0;
}

#panel-right.connect-mode {
  background: #737598;
}

body.light-theme #panel-right.connect-mode {
  color: #ffffff;
}

body.light-theme #panel-right.connect-mode .connect-input,
body.light-theme #panel-right.connect-mode .block-action {
  color: var(--text);
}

#panel-right.connect-mode .related-block {
  border-color: rgba(255,255,255,0.2);
}

#panel-right.connect-mode .related-block:hover {
  background: rgba(255,255,255,0.15);
}

.connect-search-bar {
  display: flex;
  gap: 6px;
  padding: 8px;
  flex-shrink: 0;
}

.connect-input {
  flex: 1;
  min-width: 0;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* ≥16px prevents iOS Safari auto-zoom on focus */
  padding: 4px 8px;
  outline: none;
  resize: none;
  overflow-y: hidden;
  line-height: 1.4;
}

.connect-input:focus {
  border-color: var(--input-focus-border);
}

.connect-cancel {
  display: block;
  width: 100%;
  padding: 8px;
  font-size: 0.8rem;
  opacity: 0.7;
}

.right-panel-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 8px 8px;
}

.panel-section-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
  padding: 4px 2px 6px;
  flex-shrink: 0;
}

.related-block {
  flex-shrink: 0;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.related-block:hover {
  background: var(--btn-hover-bg);
}

.block-action {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: var(--panel-bg);
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.related-block:hover .block-action {
  opacity: 1;
}

.block-action:hover {
  background: var(--btn-hover-bg);
  border-color: var(--text);
}

/* Touch devices have no hover; keep action buttons faintly visible */
@media (hover: none) {
  .block-action {
    opacity: 0.45;
  }
}

.related-text {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.create-note-block {
  border-style: dashed;
  opacity: 0.75;
}

.create-note-block:hover {
  opacity: 1;
}

.related-weight {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-top: 4px;
}

#center {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.nav-side {
  padding: 12px 14px;
  overflow-y: auto;
  white-space: pre-wrap;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
}

.nav-side:hover {
  background: var(--btn-hover-bg);
}

.panel-empty-hint {
  font-size: 0.9rem;
  font-style: italic;
  opacity: 0.3;
  padding: 8px 12px;
}

.seq-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.seq-position-label {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.45;
}

.seq-jump-glyph {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.35;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}

.seq-jump-glyph:hover {
  opacity: 0.85;
}

.nav-side.inactive {
  cursor: default;
  opacity: 0.25;
  pointer-events: none;
}

.nav-focused-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 12px;
}

.textarea-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.nav-focused-inner textarea {
  width: 100%;
  min-height: 80px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  outline: none;
  overflow-y: hidden;
  white-space: pre-wrap;
  padding: 10px;
}

.nav-focused-inner textarea:focus {
  border-color: var(--input-focus-border);
}

.nav-focused-inner .note-display {
  flex: 1;
  width: 100%;
  background: #737598;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  overflow-y: auto;
  white-space: pre-wrap;
  padding: 12px;
}

.btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.focus-search-wrap {
  position: relative;
  flex: 1;
  max-width: 270px;
}

.focus-search-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* ≥16px prevents iOS Safari auto-zoom on focus */
  padding: 6px 10px;
  outline: none;
}

.focus-search-input:focus {
  border-color: var(--input-focus-border);
}

.focus-search-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
}

.focus-search-item {
  padding: 8px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-search-item:hover {
  background: var(--btn-hover-bg);
}

.btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px 24px;
}

.btn:hover {
  background: var(--btn-hover-bg);
}

.file-mode-indicator {
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #737598;
  border-left: 3px solid #737598;
  margin: 8px;
}

.hamburger-wrap {
  position: relative;
  padding: 8px;
}

.hamburger-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px 10px;
}

.hamburger-btn:hover {
  background: var(--btn-hover-bg);
}

.hamburger-menu {
  position: absolute;
  top: calc(100% - 4px);
  right: 0;
  min-width: 160px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  z-index: 100;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.menu-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 16px;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--btn-hover-bg);
}

.menu-divider {
  height: 1px;
  background: var(--panel-border);
  margin: 2px 0;
}
