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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #112231;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: #112231;
  padding: 0 2rem;
  height: 56px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 0.75rem; }
.header-logo { height: 24px; width: auto; }
.header-divider { width: 1px; height: 20px; background: #2a4a60; }
.header-title { font-size: 0.85rem; font-weight: 500; color: #8a9bb0; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.last-updated { font-size: 0.7rem; color: #5a7a90; }
.refresh-btn {
  background: transparent; border: 1px solid #2a4a60; color: #8a9bb0;
  padding: 0.35rem 0.75rem; border-radius: 6px; font-size: 0.75rem;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  display: flex; align-items: center; gap: 0.4rem;
}
.refresh-btn:hover { border-color: #00b4d8; color: #fff; }
.refresh-btn svg { flex-shrink: 0; }

/* ===== Layout ===== */
.layout { display: flex; min-height: calc(100vh - 56px); }

/* ===== Sidebar ===== */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: #fff; border-right: 1px solid #e5e9ef;
  padding: 1.25rem 0; overflow-y: auto;
}
.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-label {
  font-size: 0.6rem; font-weight: 700; color: #00b4d8;
  text-transform: uppercase; letter-spacing: 0.12em;
  padding: 0 1.25rem; margin-bottom: 0.5rem;
}
.sidebar-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 0.5rem 1.25rem;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.8rem; color: #374151;
  text-align: left; transition: all 0.15s;
}
.sidebar-item:hover { background: #f0fafb; color: #112231; }
.sidebar-item.active { background: #f0fafb; color: #00b4d8; font-weight: 600; border-right: 2px solid #00b4d8; }
.sidebar-count {
  font-size: 0.65rem; color: #9ca3af; background: #f3f4f6;
  padding: 0.1rem 0.4rem; border-radius: 9999px; min-width: 18px; text-align: center;
}
.sidebar-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.sidebar-dot-pass { background: #0d9488; }
.sidebar-dot-fail { background: #dc2626; }
.sidebar-dot-unknown { background: #d1d5db; }
.sidebar-item-left { display: flex; align-items: center; gap: 0.5rem; }

.sidebar-filter {
  display: inline-block; margin: 0.15rem 0 0.15rem 1.25rem;
  padding: 0.25rem 0.6rem; border-radius: 9999px;
  border: 1px solid #e5e9ef; background: #fff;
  font-size: 0.7rem; color: #6b7b8d; cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.sidebar-filter:hover { border-color: #00b4d8; color: #00b4d8; }
.sidebar-filter.active { background: #00b4d8; color: #fff; border-color: #00b4d8; }

.sidebar-page-filter {
  display: inline-block; margin: 0.15rem 0 0.15rem 1.25rem;
  padding: 0.25rem 0.6rem; border-radius: 9999px;
  border: 1px solid #e5e9ef; background: #fff;
  font-size: 0.7rem; color: #6b7b8d; cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.sidebar-page-filter:hover { border-color: #00b4d8; color: #00b4d8; }
.sidebar-page-filter.active { background: #112231; color: #fff; border-color: #112231; }

/* ===== Main ===== */
.main { flex: 1; padding: 1.5rem; overflow-y: auto; }

/* ===== Viewfinder ===== */
.viewfinder-bar {
  background: #fff; border: 1px solid #e5e9ef; border-radius: 8px;
  padding: 0.75rem 1rem; margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.viewfinder-label {
  font-size: 0.65rem; font-weight: 700; color: #00b4d8;
  text-transform: uppercase; letter-spacing: 0.1em; white-space: nowrap;
}
.viewfinder-presets { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.vf-preset {
  padding: 0.3rem 0.65rem; border-radius: 6px;
  border: 1px solid #e5e9ef; background: #fff;
  font-size: 0.72rem; color: #374151; cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.vf-preset:hover { border-color: #00b4d8; color: #00b4d8; }
.vf-preset.active { background: #112231; color: #fff; border-color: #112231; }
.vf-custom-btn { border-style: dashed; }
.vf-custom-btn.active { border-style: solid; }
.viewfinder-hint {
  font-size: 0.65rem; color: #9ca3af; margin-left: auto;
}

/* ===== Summary ===== */
.summary {
  display: flex; gap: 0.75rem; margin-bottom: 1.5rem;
}
.summary-item {
  flex: 1; text-align: center;
  padding: 1rem; border-radius: 8px;
  background: #fff; border: 1px solid #e5e9ef;
}
.summary-value { font-size: 1.5rem; font-weight: 700; }
.summary-label { font-size: 0.6rem; color: #6b7b8d; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 0.15rem; }
.s-total .summary-value { color: #112231; }
.s-pass .summary-value { color: #0d9488; }
.s-fail .summary-value { color: #dc2626; }
.s-shots .summary-value { color: #00b4d8; }

/* ===== Thumbnail Grid ===== */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1rem;
}

.thumb-card {
  background: #fff; border: 2px solid #e5e9ef; border-radius: 8px;
  overflow: hidden; cursor: pointer; transition: all 0.2s;
  position: relative;
}
.thumb-card:hover { border-color: #00b4d8; box-shadow: 0 2px 12px rgba(0,180,216,0.1); }
.thumb-card.selected { border-color: #00b4d8; box-shadow: 0 0 0 1px #00b4d8; }
.thumb-card:focus { outline: 2px solid #00b4d8; outline-offset: 2px; }

.thumb-img-wrapper {
  width: 100%; height: 320px; overflow: hidden; position: relative;
  background: #f8f9fb;
}
.thumb-img {
  width: 100%; display: block; position: absolute; top: 0; left: 0;
  transform-origin: 0 0; transition: transform 0.3s ease;
  user-select: none; -webkit-user-drag: none;
}
body.focus-mode .thumb-img-wrapper { cursor: grab; }
body.focus-mode .thumb-img-wrapper:active { cursor: grabbing; }
.thumb-placeholder {
  width: 100%; height: 320px; display: flex; align-items: center;
  justify-content: center; background: #f8f9fb; color: #c4cdd5; font-size: 0.8rem;
}

.thumb-footer {
  padding: 0.6rem 0.75rem;
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #eef1f5;
}
.thumb-site { font-size: 0.75rem; font-weight: 600; color: #112231; }
.thumb-page { font-size: 0.65rem; color: #6b7b8d; }
.thumb-status {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.thumb-status-pass { background: #0d9488; }
.thumb-status-fail { background: #dc2626; }
.thumb-time { font-size: 0.6rem; color: #9ca3af; }

/* ===== Detail Panel ===== */
.detail-panel {
  background: #fff; border: 1px solid #e5e9ef; border-radius: 10px;
  margin-top: 1.5rem; overflow: hidden; position: relative;
}
.detail-close {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 2;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 1px solid #e5e9ef;
  font-size: 18px; color: #6b7b8d; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.detail-close:hover { border-color: #dc2626; color: #dc2626; }

.detail-preview {
  background: #f8f9fb; padding: 1.5rem;
  display: flex; justify-content: center; align-items: flex-start;
  min-height: 300px;
}
.detail-preview img {
  max-width: 100%; max-height: 500px; object-fit: contain;
  border-radius: 6px; border: 1px solid #e5e9ef;
  cursor: pointer;
}

.detail-info { padding: 1.25rem 1.5rem; }

.detail-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid #eef1f5;
}
.detail-title { font-size: 1.1rem; font-weight: 600; }
.detail-meta { display: flex; align-items: center; gap: 1rem; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.25rem 0.625rem; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 600;
}
.badge-passing { background: #ecfdf5; color: #0d9488; }
.badge-failing { background: #fef2f2; color: #dc2626; }
.badge-unknown { background: #f3f4f6; color: #9ca3af; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-passing .badge-dot { background: #0d9488; }
.badge-failing .badge-dot { background: #dc2626; }

.visit-link {
  color: #00b4d8; font-size: 0.8rem; text-decoration: none;
  display: flex; align-items: center; gap: 0.25rem;
}
.visit-link:hover { text-decoration: underline; }

/* Detail sections */
.detail-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.detail-section h4 {
  font-size: 0.6rem; font-weight: 700; color: #00b4d8;
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.5rem;
}

.check-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0; font-size: 0.8rem;
}
.check-icon {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0;
}
.check-icon-pass { background: #ecfdf5; color: #0d9488; }
.check-icon-fail { background: #fef2f2; color: #dc2626; }
.check-desc { font-size: 0.65rem; color: #8a9bb0; margin-left: 1.6rem; }

.commit-item {
  display: flex; gap: 0.5rem; align-items: baseline;
  padding: 0.25rem 0; font-size: 0.78rem; color: #374151;
}
.commit-sha {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  color: #00b4d8; font-size: 0.7rem;
  background: #f0fafb; padding: 0.1rem 0.35rem; border-radius: 3px;
}
.commit-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.commit-date { color: #9ca3af; font-size: 0.65rem; white-space: nowrap; }

/* ===== Crop overlay ===== */
.crop-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(17,34,49,0.75); display: none;
}
.crop-overlay.active { display: block; }
.crop-overlay > img {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 80vw; max-height: 75vh;
  user-select: none; -webkit-user-drag: none;
}
.crop-rect {
  position: absolute; border: 2px solid #00b4d8;
  background: rgba(0,180,216,0.08);
  cursor: move; display: none;
  box-shadow: 0 0 0 9999px rgba(17,34,49,0.5);
}
.crop-handle {
  position: absolute; width: 14px; height: 14px;
  background: #fff; border: 2px solid #00b4d8;
  border-radius: 50%; cursor: pointer; z-index: 2;
}
.crop-handle-tl { top: -7px; left: -7px; cursor: nw-resize; }
.crop-handle-tr { top: -7px; right: -7px; cursor: ne-resize; }
.crop-handle-bl { bottom: -7px; left: -7px; cursor: sw-resize; }
.crop-handle-br { bottom: -7px; right: -7px; cursor: se-resize; }
.crop-toolbar {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: #112231; padding: 0.6rem 1rem;
  border-radius: 8px; z-index: 501;
  display: flex; align-items: center; gap: 0.75rem;
}
.crop-apply {
  background: #00b4d8; color: #fff; border: none;
  padding: 0.4rem 1rem; border-radius: 6px; font-size: 0.8rem;
  font-family: inherit; cursor: pointer; font-weight: 600;
}
.crop-apply:hover { background: #0098b8; }
.crop-cancel {
  background: transparent; color: #8a9bb0; border: 1px solid #2a4a60;
  padding: 0.4rem 1rem; border-radius: 6px; font-size: 0.8rem;
  font-family: inherit; cursor: pointer;
}
.crop-cancel:hover { color: #fff; border-color: #5a7a90; }
.crop-hint { font-size: 0.7rem; color: #5a7a90; }

/* ===== Loading ===== */
.loading {
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; min-height: 400px; color: #9ca3af; gap: 1rem;
}
.spinner {
  width: 2rem; height: 2rem;
  border: 3px solid #e5e9ef; border-top-color: #00b4d8;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Lightbox ===== */
.lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(17,34,49,0.92); z-index: 1000;
  justify-content: center; align-items: center;
  cursor: pointer; backdrop-filter: blur(4px);
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,0.3); }

/* ===== Focus mode (hides sidebar + summary when viewfinder active) ===== */
body.focus-mode .sidebar { display: none; }
body.focus-mode .summary { display: none !important; }
body.focus-mode .main { padding: 0.75rem; }
body.focus-mode .header { padding: 0 1rem; height: 44px; }
body.focus-mode .header-logo { height: 20px; }
body.focus-mode .viewfinder-bar { margin-bottom: 0.75rem; }
body.focus-mode .thumb-grid { gap: 0.75rem; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid #e5e9ef; padding: 0.75rem 0; display: flex; flex-wrap: wrap; gap: 0; }
  .sidebar-section { margin-bottom: 0; display: flex; flex-wrap: wrap; align-items: center; padding: 0 0.5rem; }
  .sidebar-label { padding: 0 0.5rem; margin: 0; }
  .sidebar-item { width: auto; padding: 0.4rem 0.75rem; }
  .detail-sections { grid-template-columns: 1fr; }
}
