/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  color: #1a1a1a;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  height: 52px;
}

#app-header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #111;
}

#logo {
  height: 28px;
  opacity: 0.85;
}

/* Main Layout */
#app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Panel: Score */
#score-panel {
  width: 45%;
  min-width: 400px;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  position: relative;
  overflow: hidden;
}

#score-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#score-page-wrapper {
  position: relative;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
}

#pdf-canvas {
  display: block;
}

#score-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: all;
}

#score-overlay.highlight-draw-mode {
  cursor: crosshair;
}

#score-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 10px;
  border: 1px solid rgba(229, 231, 235, 0.95);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 12;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

#score-nav button {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 3px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  transition: all 0.15s;
}

#score-nav button:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

#score-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

#page-indicator {
  font-size: 12px;
  color: #6b7280;
  min-width: 80px;
  text-align: center;
}

/* Right Panel */
#right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Session Tabs */
#session-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
  flex-shrink: 0;
}

.session-tab {
  padding: 6px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  color: #6b7280;
  transition: all 0.15s;
  white-space: nowrap;
}

.session-tab:hover {
  background: #f9fafb;
  color: #374151;
}

.session-tab.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
  font-weight: 500;
}

/* Measure Range Bar */
#measure-range-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
  flex-wrap: wrap;
}

#measure-range-bar input[type="number"] {
  width: 50px;
  padding: 3px 4px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  outline: none;
}

#measure-range-bar input[type="number"]:focus {
  border-color: #3b82f6;
}

.range-dash {
  color: #9ca3af;
  font-size: 13px;
}

#measure-range-bar button {
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: #374151;
  transition: all 0.15s;
}

#measure-range-bar button:hover {
  background: #f3f4f6;
}

#measure-go {
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
  color: #fff !important;
}

#measure-go:hover {
  background: #2563eb !important;
}

.range-divider {
  width: 1px;
  height: 18px;
  background: #e5e7eb;
  margin: 0 4px;
}

.audio-btn {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  color: #374151;
  transition: all 0.15s;
  min-width: 30px;
  text-align: center;
}

.audio-btn:hover:not(:disabled) {
  background: #f3f4f6;
}

.audio-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

#audio-play:not(:disabled) {
  color: #16a34a;
  border-color: #86efac;
}

#audio-stop:not(:disabled) {
  color: #dc2626;
  border-color: #fca5a5;
}

.audio-time {
  font-size: 11px;
  color: #9ca3af;
  font-family: 'SF Mono', 'Menlo', monospace;
  min-width: 40px;
}

/* Section Labels */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

/* Piano Roll */
#piano-roll-section {
  flex: 1.55;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #e5e7eb;
  min-height: 0;
  min-height: 220px;
}

#piano-roll-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #fafafa;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

#piano-roll-info {
  font-size: 11px;
  color: #9ca3af;
}

#piano-roll-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
  min-height: 0;
}

#piano-roll-canvas {
  display: block;
}

/* Pedal */
#pedal-section {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #e5e7eb;
  min-height: 0;
  min-height: 230px;
  background: #fff;
}

#pedal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  background: #fafafa;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
  flex-wrap: wrap;
}

#pedal-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pedal-info {
  font-size: 11px;
  color: #9ca3af;
}

#pedal-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#pedal-toggles label {
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

#pedal-toggles input[type="checkbox"] {
  accent-color: #3b82f6;
}

#pedal-container {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  min-height: 0;
  min-height: 150px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 0.95)),
    linear-gradient(90deg, rgba(226, 232, 240, 0.45) 1px, transparent 1px);
}

#pedal-canvas {
  display: block;
  transform-origin: left top;
}

/* Curves */
#curves-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #e5e7eb;
  min-height: 0;
  min-height: 200px;
}

#curves-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #fafafa;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

#curve-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#curve-toggles label {
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

#curve-toggles input[type="checkbox"] {
  accent-color: #3b82f6;
}

.curve-divider {
  width: 1px;
  height: 14px;
  background: #e5e7eb;
}

#overlay-session-btns {
  display: flex;
  gap: 3px;
  align-items: center;
}

.overlay-session-btn {
  padding: 2px 8px;
  border-radius: 10px;
  border: 1.5px solid currentColor;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1.4;
}

.overlay-session-btn.active {
  opacity: 1;
  background: currentColor;
}

.overlay-session-btn.active span {
  color: #fff;
  mix-blend-mode: normal;
}

.overlay-session-btn span {
  pointer-events: none;
}

#curves-container {
  flex: 1;
  position: relative;
  min-height: 0;
}

#curves-canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Annotations */
#memo-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #fafafa;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}

#memo-panel-label {
  font-size: 12px;
  color: #6b7280;
}

.memo-panel-btn {
  padding: 2px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.15s;
}

.memo-panel-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

#memo-panel-text {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: #374151;
  background: #fff;
}

#memo-panel-text:disabled {
  background: #f9fafb;
  color: #9ca3af;
}

#memo-panel-text::placeholder {
  color: #d1d5db;
}


.memo-panel-save-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 4px 14px;
  font-size: 12px;
  cursor: pointer;
}

.memo-panel-save-btn:disabled {
  background: #93c5fd;
  cursor: default;
}

.memo-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.memo-panel-edit-btn {
  /* Match Save: same padding + font-size, different color so the two roles
     stay visually distinct. */
  background: #6b7280;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 4px 14px;
  font-size: 12px;
  cursor: pointer;
}

.memo-panel-edit-btn:disabled {
  background: #d1d5db;
  cursor: default;
}

.memo-panel-delete-btn {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 14px;
  font-size: 12px;
  cursor: pointer;
}

.memo-panel-delete-btn:hover {
  background: #dc2626;
}

/* Score overlay styles */
.measure-rect {
  fill: rgba(59, 130, 246, 0.03);
  stroke: rgba(59, 130, 246, 0.15);
  stroke-width: 1.5;
  cursor: pointer;
  transition: all 0.15s;
}

.measure-rect:hover {
  fill: rgba(59, 130, 246, 0.08);
  stroke: rgba(59, 130, 246, 0.4);
}

.measure-rect.active {
  fill: rgba(59, 130, 246, 0.12);
  stroke: #3b82f6;
  stroke-width: 2.5;
}

.measure-label {
  font-size: 22px;
  fill: #9ca3af;
  pointer-events: none;
  font-family: -apple-system, sans-serif;
}

.measure-rect {
  vector-effect: non-scaling-stroke;
}

/* Annotation tooltip on score */
#annotation-tooltip {
  position: absolute;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #92400e;
  max-width: 200px;
  line-height: 1.4;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Note overlays on score - invisible by default */
.note-rect {
  fill: transparent;
  stroke: transparent;
  stroke-width: 1;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
  transition: all 0.15s;
}

.note-rect:hover {
  fill: rgba(59, 130, 246, 0.04);
  stroke: rgba(59, 130, 246, 0.25);
}

.note-rect.active {
  fill: rgba(245, 158, 11, 0.06);
  stroke: rgba(245, 158, 11, 0.5);
  stroke-width: 1.5;
}

/* Annotation dot on annotated notes */
.note-annot-dot {
  cursor: pointer;
  transition: all 0.15s;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.note-annot-dot:hover {
  r: 10;
}

/* Note icon on score - SVG scaling */
.note-icon-group {
  cursor: pointer;
}

/* Symbol Toolbar */
#symbol-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 12;
}

#symbol-toolbar-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  padding-right: 42px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: 14px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  flex-wrap: wrap;
  transition: transform 0.24s ease, opacity 0.18s ease;
}

#symbol-toolbar-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#symbol-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

#symbol-buttons {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

#symbol-toolbar.collapsed #symbol-toolbar-body {
  transform: translateY(calc(-100% - 12px));
  opacity: 0;
  pointer-events: none;
}

#symbol-toolbar.collapsed .toolbar-toggle-btn {
  top: 6px;
  transform: translateY(0);
}

#symbol-toolbar:not(.collapsed) .toolbar-toggle-btn {
  font-size: 15px;
}

.toolbar-toggle-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  will-change: top, transform;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  cursor: pointer;
  font-size: 12px;
  color: #475569;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
  z-index: 2;
  pointer-events: auto;
}

.toolbar-toggle-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.annotation-note-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 17px;
  color: #059669;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.annotation-note-btn:hover {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.annotation-note-btn.active {
  background: #d1fae5;
  border-color: #059669;
  box-shadow: 0 0 0 1px #059669;
}

.annotation-pencil-btn {
  color: #059669;
  font-size: 16px;
  font-weight: 700;
  margin-left: 2px;
}

.annotation-pencil-btn:hover {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.annotation-pencil-btn.active {
  background: #d1fae5;
  border-color: #059669;
  box-shadow: 0 0 0 1px #059669;
}

.symbol-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  color: #3b82f6;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.symbol-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.symbol-btn.active {
  background: #dbeafe;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

.guideline-btn {
  width: auto;
  min-width: 118px;
  padding: 0 10px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  margin-right: 4px;
}

.symbol-btn-memo {
  color: #3b82f6 !important;
  background: #fff;
}

.symbol-btn-memo:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.symbol-btn-memo.active {
  background: #dbeafe;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

.symbol-btn-highlight {
  background: #bae6fd;
  color: #0c4a6e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.symbol-btn-highlight:hover {
  background: #7dd3fc;
  border-color: #38bdf8;
}

.symbol-btn-highlight.active {
  background: #7dd3fc;
  border-color: #0284c7;
  box-shadow: 0 0 0 1px #0284c7;
}

.hairpin-svg {
  width: 24px;
  height: 16px;
  display: block;
  overflow: visible;
}

.hairpin-svg path {
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  fill: none;
}

.accent-icon {
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  transform: scaleX(0.72);
}

.accent-icon-double {
  font-size: 13px;
  transform: scaleX(0.78);
}

#symbol-form {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
}

#symbol-form-label {
  font-weight: 600;
  color: #3b82f6;
  font-size: 11px;
  text-transform: uppercase;
}

#symbol-form label {
  font-size: 11px;
  color: #9ca3af;
}

#symbol-form input[type="number"] {
  width: 42px;
  padding: 2px 4px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  outline: none;
}

#symbol-form input[type="number"]:focus {
  border-color: #3b82f6;
}

#sym-text {
  width: 110px;
  padding: 2px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

#sym-text:focus {
  border-color: #d97706;
}

#sym-range-arrow {
  color: #9ca3af;
  font-size: 12px;
}

#symbol-form button {
  padding: 3px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  color: #374151;
  transition: all 0.15s;
}

#memo-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

#sym-add {
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
  color: #fff !important;
}

#sym-add:hover {
  background: #2563eb !important;
}

#sym-cancel:hover {
  background: #f3f4f6;
}

#guideline-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#guideline-modal.open {
  display: flex;
}

#guideline-modal-inner {
  width: min(620px, 100%);
  max-height: min(760px, 88vh);
  overflow-y: auto;
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

#guideline-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

#guideline-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
}

#guideline-modal-close {
  width: 30px;
  height: 30px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

#guideline-modal-close:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #2563eb;
}

#guideline-list {
  display: grid;
  gap: 10px;
  padding: 16px 22px 20px 40px;
  color: #374151;
  font-size: 13px;
  line-height: 1.55;
}

#guideline-list li::marker {
  color: #2563eb;
  font-weight: 700;
}

#guideline-list strong {
  display: block;
  color: #111827;
  font-size: 13px;
  margin-bottom: 2px;
}

#guideline-list span {
  display: block;
}

/* Symbol SVG elements on score */
.symbol-group {
  cursor: pointer;
}

.symbol-group:hover {
  opacity: 0.7;
}

/* Compare button in curve header */
.compare-btn {
  padding: 3px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: #374151;
  transition: all 0.15s;
  margin-left: 4px;
}

.compare-btn:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #3b82f6;
}

/* Compare Modal */
#compare-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#compare-modal.open {
  display: flex;
}

#compare-modal-inner {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

#compare-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#compare-modal-title {
  font-size: 14px;
  font-weight: 600;
  color: #111;
}

#compare-modal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.compare-toggle {
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

#compare-modal-close {
  width: 28px;
  height: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

#compare-modal-close:hover {
  background: #f3f4f6;
  color: #111;
}

#compare-session-select {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 20px 8px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
  align-items: center;
}

.compare-session-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.compare-session-check input[type="checkbox"] {
  cursor: pointer;
}

#compare-session-select .select-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-right: 4px;
}

#compare-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 20px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #374151;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

#compare-charts-row {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.compare-chart-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 16px 6px;
  min-width: 0;
  border-right: 1px solid #f3f4f6;
}

.compare-chart-panel:last-child {
  border-right: none;
}

.compare-chart-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.compare-chart-container {
  flex: 1;
  position: relative;
  min-height: 0;
}

/* Similarity section */
#similarity-section {
  padding: 12px 20px 16px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.compare-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 10px;
}

#similarity-matrix {
  overflow-x: auto;
}

.similarity-table {
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}

.similarity-table th,
.similarity-table td {
  padding: 5px 8px;
  text-align: center;
  border: 1px solid #f3f4f6;
  min-width: 60px;
  font-weight: 400;
}

.similarity-table thead th {
  font-weight: 600;
  background: #fafafa;
  white-space: nowrap;
}

.similarity-table tbody th {
  font-weight: 600;
  background: #fafafa;
  white-space: nowrap;
  text-align: left;
}

#similarity-summary {
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.6;
}

.sim-highlight {
  font-weight: 600;
  color: #374151;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ── Login Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 36px 40px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.login-box h2 {
  font-size: 15px;
  font-weight: 700;
  color: #111;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 20px;
  line-height: 1.6;
}

.login-field {
  margin-bottom: 14px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 5px;
}

.login-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.login-field input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}

.login-error {
  font-size: 12px;
  color: #ef4444;
  margin-bottom: 12px;
}

.login-submit-btn {
  width: 100%;
  padding: 9px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.login-submit-btn:hover { background: #4f46e5; }
.login-submit-btn:disabled { background: #a5b4fc; cursor: not-allowed; }

/* ── Header user info ── */
#header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

#user-name-display {
  font-size: 12px;
  color: #374151;
  font-weight: 500;
}

.logout-btn {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
}

.logout-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

/* ── Others' annotations ── */
#others-annotations {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px 8px;
}

.other-annotation {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #6366f1;
  border-radius: 6px;
  padding: 7px 10px;
}

.other-annotation-user {
  font-size: 11px;
  font-weight: 600;
  color: #6366f1;
  display: block;
  margin-bottom: 3px;
}

.other-annotation-text {
  font-size: 12px;
  color: #374151;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ── History Modal ── */
#history-modal {
  display: none;
}

#history-modal.open {
  display: flex;
}

#history-modal-inner {
  background: #fff;
  border-radius: 12px;
  width: 580px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}

#history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#history-modal-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #111;
}

#history-modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
}

#history-modal-close:hover { color: #374151; }

#history-list {
  overflow-y: auto;
  padding: 12px 20px;
  flex: 1;
}

.history-loading {
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.history-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 12px;
}

.history-item:last-child { border-bottom: none; }

.history-user {
  font-weight: 600;
  color: #111;
}

.history-action {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}

.action-create { background: #dcfce7; color: #166534; }
.action-update { background: #dbeafe; color: #1e40af; }
.action-delete { background: #fee2e2; color: #991b1b; }

.history-key {
  color: #6b7280;
  flex: 1;
}

.history-time {
  color: #9ca3af;
  font-size: 11px;
  margin-left: auto;
}

.history-text {
  width: 100%;
  color: #374151;
  background: #f9fafb;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: pre-wrap;
  margin-top: 2px;
}
