:root {
  --bg: #f5f5f5;
  --surface: #fff;
  --border: #ddd;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #2563eb;
  --amber: #fef3c7;
  --amber-border: #f59e0b;
  --bug-badge: #92400e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Picker */
.picker-view {
  max-width: 640px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.picker-hint {
  color: var(--muted);
}

.export-list {
  list-style: none;
  padding: 0;
}

.export-list a {
  display: block;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  background: var(--bg);
  border-radius: 6px;
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
}

.export-list a:hover {
  background: #e8eef9;
}

/* App shell */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.page-select-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.page-select {
  font: inherit;
  font-size: 0.875rem;
  max-width: 100%;
  min-width: 12rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.page-title {
  margin: 0 0 0.25rem;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

.page-url {
  font-size: 0.875rem;
  color: var(--muted);
  word-break: break-all;
}

.bug-badge {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  background: #d97706;
  color: #fff;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: 57fr 43fr;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
    overflow: auto;
  }
}

.gallery {
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  overflow-y: auto;
}

.main-image-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

.main-image {
  width: 100%;
  height: auto;
  max-height: min(70vh, calc(100vh - 12rem));
  object-fit: contain;
  background: #eee;
  border: 1px solid var(--border);
  border-radius: 4px;
  vertical-align: top;
}

.slide-caption {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  flex-shrink: 0;
}

.thumbnails {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-bottom: 0.25rem;
  overflow-x: auto;
  flex-shrink: 0;
}

.thumb {
  flex: 0 0 72px;
  cursor: pointer;
  text-align: center;
}

.thumb img {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: #eee;
}

.thumb.active img {
  border-color: var(--accent);
}

.thumb-label {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.thumb.active .thumb-label {
  color: var(--accent);
  font-weight: 600;
}

.sections-panel {
  padding: 1rem 1.5rem;
  overflow-y: auto;
  background: var(--bg);
}

.note-section {
  margin-bottom: 1.25rem;
}

.note-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.note-section.bugs {
  background: var(--amber);
  border: 1px solid var(--amber-border);
  border-radius: 6px;
  padding: 1rem;
}

.note-section.bugs h3 {
  color: var(--bug-badge);
}

.note-section ul {
  margin: 0;
  padding-left: 1.25rem;
}

.note-section li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.note-section strong {
  font-weight: 700;
}

.note-section .note-sublist {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.25rem;
  list-style: circle;
}

.note-section .note-sublist li {
  margin-bottom: 0.35rem;
}

/* Editor */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
  background: var(--surface);
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.editor-toolbar h2 {
  margin: 0;
  font-size: 1rem;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.history-label {
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.version-select {
  min-width: 180px;
}

.json-editor {
  flex: 1;
  width: 100%;
  min-height: 300px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: vertical;
}

.editor-hint {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.editor-error {
  color: #b91c1c;
  font-size: 0.875rem;
  margin: 0 0 0.5rem;
}

/* Footer */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.dots {
  display: flex;
  gap: 0.35rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  border: none;
  padding: 0;
  cursor: pointer;
}

.dot.active {
  background: #1a1a1a;
}

.slide-counter {
  font-size: 0.8rem;
  color: var(--muted);
}

.btn {
  font: inherit;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-nav {
  min-width: 5rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
