:root {
  --bg: #f5f5f5;
  --fg: #1a1a1a;
  --accent: #0b6a4a;
  --muted: #666;
  --card: #fff;
  --err: #b00020;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}

h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 0; }

.page-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.capture-button { width: 100%; }

button {
  font-size: 1rem;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.secondary { background: #ddd; color: #222; }
button.danger { background: var(--err); color: #fff; }
button:disabled { opacity: 0.5; cursor: default; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
.modal h2 { margin: 0 0 8px; }
.modal p { margin: 0 0 16px; color: #333; }
.modal-buttons { display: flex; flex-direction: column; gap: 8px; }

input[type=text] {
  font-size: 1rem;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #ccc;
  width: 100%;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.checkbox-label input { width: 20px; height: 20px; margin: 0; }

.row { display: flex; gap: 8px; align-items: center; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--err); }
.center { text-align: center; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #ddd;
  cursor: pointer;
  padding: 0;
  display: block;
  width: 100%;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Full-screen image viewer */
.viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.viewer-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

/* Annotation editor */
.editor {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  touch-action: none;
}
.editor img { max-width: 100%; max-height: 60vh; display: block; user-select: none; }
.overlay-text {
  position: absolute;
  left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-weight: 700;
  line-height: 1.15;
  text-shadow: 0 0 6px #000, 0 0 6px #000;
  padding: 0 2.5%;
  cursor: grab;
  touch-action: none;
  white-space: pre-wrap;
  word-break: break-word;
}
