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

html, body {
  height: 100%;
  overflow: hidden;
  background: #1a1a1a;
  color: #d4c5a9;
  font-family: 'Georgia', serif;
}

.layout {
  display: flex;
  height: 100vh;
}

/* ── Image panel ── */
.image-panel {
  flex: 0 0 55%;
  position: relative;
  background: #111;
  border-right: 1px solid #1e2a3a;
}

#osd-viewer {
  width: 100%;
  height: 100%;
}

#loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  z-index: 10;
  transition: opacity 0.4s;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  color: #7090a0;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}

/* ── SVG overlay rects ── */
.bbox-rect {
  fill: transparent;
  stroke: rgba(91, 155, 213, 0.4);
  stroke-width: 0.003;
  cursor: pointer;
  transition: fill 0.15s, stroke 0.15s;
}

.bbox-rect:hover {
  fill: rgba(91, 155, 213, 0.12);
  stroke: rgba(91, 155, 213, 0.8);
}

.bbox-rect.selected {
  fill: rgba(91, 155, 213, 0.28);
  stroke: #5b9bd5;
  stroke-width: 0.004;
}

/* ── Text panel ── */
.text-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #181c20;
  overflow: hidden;
}

/* ── Upload screen ── */
#upload-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  z-index: 100;
}

.upload-card {
  background: #18202a;
  border: 1px solid #1e2a3a;
  border-radius: 6px;
  padding: 40px 48px;
  width: 480px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.upload-title {
  font-size: 1.1rem;
  font-weight: normal;
  letter-spacing: 0.12em;
  color: #d4c5a9;
  text-align: center;
}

.upload-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.upload-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.upload-field-title {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5a7090;
}

.upload-field-hint {
  font-size: 0.75rem;
  color: #3a4a5a;
  margin-bottom: 4px;
}

.file-drop {
  border: 1px solid #1e2a3a;
  border-radius: 4px;
  padding: 12px 16px;
  color: #5a7090;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
  position: relative;
  overflow: hidden;
}

.file-drop.has-file {
  border-color: #5b9bd5;
  color: #d4c5a9;
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-label:hover .file-drop {
  border-color: #2a3a52;
  color: #7090a0;
}

#load-btn {
  background: #1a2030;
  border: 1px solid #1e2a3a;
  border-radius: 4px;
  color: #5a7090;
  font-family: 'Georgia', serif;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  padding: 10px;
  cursor: not-allowed;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

#load-btn:not(:disabled) {
  border-color: #5b9bd5;
  color: #5b9bd5;
  cursor: pointer;
}

#load-btn:not(:disabled):hover {
  background: #1e2a38;
}

.upload-error {
  font-size: 0.78rem;
  color: #a05040;
  text-align: center;
  min-height: 1em;
}

/* ── Panel header ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5a7090;
  border-bottom: 1px solid #1e2a3a;
  flex-shrink: 0;
}

#new-file-btn {
  background: none;
  border: 1px solid #1e2a3a;
  border-radius: 3px;
  color: #4a5060;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  cursor: pointer;
  font-family: 'Georgia', serif;
  transition: border-color 0.15s, color 0.15s;
}

#new-file-btn:hover {
  border-color: #5b9bd5;
  color: #5b9bd5;
}

#block-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

#block-list::-webkit-scrollbar {
  width: 6px;
}

#block-list::-webkit-scrollbar-track {
  background: #1a1a1a;
}

#block-list::-webkit-scrollbar-thumb {
  background: #1e2a3a;
  border-radius: 3px;
}

/* ── Block items ── */
.block-item {
  padding: 10px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.block-item:hover {
  background: #1e2028;
  border-left-color: rgba(91, 155, 213, 0.4);
}

.block-item.selected {
  background: #1a1e28;
  border-left-color: #5b9bd5;
}

.block-type {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5a7090;
  margin-bottom: 4px;
  font-family: 'Georgia', serif;
}

.block-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #d4c5a9;
}
