:root {
  color-scheme: light;
  --slate-900: #0f172a;
  --slate-800: #cbd5e1;
  --slate-700: #e2e8f0;
  --slate-100: #1f2937;
  --sky-300: #0ea5e9;
  --surface-base: #ffffff;
  --surface-muted: #f8fafc;
  --surface-accent: #e0f2fe;
  --page-padding: clamp(16px, 4vw, 32px);
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #e0f2fe, #ffffff 55%);
  color: var(--slate-100);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--page-padding);
}

.app-shell {
  width: min(1200px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

.image-switcher {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-base);
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 9999px;
  padding: 8px 18px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

.switcher-link {
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.65);
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid transparent;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.switcher-link:hover,
.switcher-link:focus {
  color: rgba(7, 89, 133, 0.95);
  background: var(--surface-accent);
  border-color: rgba(14, 165, 233, 0.4);
  outline: none;
  transform: translateY(-1px);
}

.switcher-link.active {
  color: #0369a1;
  background: var(--surface-accent);
  border-color: rgba(14, 165, 233, 0.6);
}

.layout {
  width: min(1200px, 100%);
  height: min(720px, calc(100vh - (var(--page-padding) * 2)));
  max-height: calc(100vh - (var(--page-padding) * 2));
  min-height: min(360px, calc(100vh - (var(--page-padding) * 2)));
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
  padding: 20px;
  background: var(--surface-base);
  border: 1px solid var(--slate-700);
  border-radius: 20px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.canvas-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.image-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--slate-700);
  background: var(--surface-muted);
  cursor: grab;
}

.image-wrapper.is-panning {
  cursor: grabbing;
}

.image-wrapper.is-panning img,
.image-wrapper.is-panning #marker-layer {
  transition: none;
}

.image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  transition: transform 0.2s ease;
}

#marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: center;
  transition: transform 0.2s ease;
}

.image-wrapper:hover #marker-layer {
  pointer-events: auto;
}

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 9999px;
  border: 1px solid rgba(14, 116, 144, 0.6);
  background: var(--surface-accent);
  color: #0f172a;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
  font-size: 10px;
  line-height: 1;
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  pointer-events: none;
}

.image-wrapper:hover .marker {
  opacity: 0.55;
  pointer-events: auto;
}

.marker.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.05);
  pointer-events: auto;
}

.marker .tooltip {
  margin-top: 6px;
  width: 200px;
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--surface-base);
  border: 1px solid var(--slate-700);
  border-radius: 10px;
  padding: 10px;
  color: var(--slate-100);
  font-size: 12px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.marker.active .tooltip {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  background: var(--surface-muted);
  border: 1px solid var(--slate-700);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 20px;
  word-break: break-word;
}

.image-meta {
  margin: 8px 0 0;
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: rgba(71, 85, 105, 0.8);
}

.image-date {
  margin: 4px 0 0;
  font-size: 12px;
  color: rgba(71, 85, 105, 0.7);
}

.annotation-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(14, 165, 233, 0.4) rgba(148, 163, 184, 0.3);
}

.annotation-scroll::-webkit-scrollbar {
  width: 8px;
}

.annotation-scroll::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.15);
  border-radius: 9999px;
}

.annotation-scroll::-webkit-scrollbar-thumb {
  background: rgba(14, 165, 233, 0.4);
  border-radius: 9999px;
}

.annotation-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(14, 165, 233, 0.55);
}

.annotation-item {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-base);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.annotation-item:hover,
.annotation-item:focus {
  border-color: rgba(14, 165, 233, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
  outline: none;
}

.annotation-item.active {
  border-color: rgba(14, 165, 233, 0.8);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25);
}

.annotation-title {
  font-weight: 600;
  margin: 0;
  font-size: 14px;
  color: var(--slate-100);
}

.annotation-description {
  margin: 6px 0 0;
  font-size: 12px;
  color: rgba(71, 85, 105, 0.85);
}

.annotation-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: rgba(2, 132, 199, 0.95);
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-base);
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 9999px;
  padding: 6px 14px;
  width: fit-content;
  margin-left: auto;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.zoom-controls button {
  background: var(--surface-muted);
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: var(--slate-100);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
}

.zoom-controls button:hover {
  border-color: rgba(14, 165, 233, 0.6);
  color: rgba(2, 132, 199, 0.95);
}

#zoom-level {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .sidebar {
    order: -1;
  }
}
