/* ── ColorMeter — style.css ─────────────────────────────────────────── */

:root {
  --bg:        #0d0d0d;
  --surface:   #161616;
  --border:    #2a2a2a;
  --text:      #e8e8e8;
  --dim:       #666;
  --accent:    #00e5ff;
  --danger:    #ff3b3b;
  --ch-color:  rgba(0, 229, 255, 0.75);
  --box-color: rgba(0, 229, 255, 0.55);
  --font-mono: 'Courier New', Courier, monospace;
  --radius:    4px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  min-height: 100vh;
  overscroll-behavior: none;
}

/* ── Header ────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.12em;
}
.logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}
.logo em {
  font-style: normal;
  color: var(--text);
}
.subtitle {
  color: var(--dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

/* ── Viewfinder ─────────────────────────────────────────────────────── */
.viewfinder-wrap {
  padding: 12px 14px 0;
}

.viewfinder {
  position: relative;
  width: 100%;
  /* Square: height = width via padding-bottom trick */
  aspect-ratio: 1 / 1;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Crosshairs */
.crosshair {
  position: absolute;
  background: var(--ch-color);
  pointer-events: none;
}
.crosshair-h {
  top: 50%;
  left: 0; right: 0;
  height: 1px;
  transform: translateY(-50%);
}
.crosshair-v {
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  transform: translateX(-50%);
}

/* Status badge */
.status-badge {
  position: absolute;
  top: 7px; right: 8px;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: rgba(0,0,0,0.55);
  padding: 3px 6px;
  border-radius: 2px;
  text-transform: uppercase;
}
.status-badge.stopped {
  color: var(--dim);
}

/* ── Readout ────────────────────────────────────────────────────────── */
.readout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.swatch-wrap {
  flex-shrink: 0;
}
.swatch {
  width: 48px;
  height: 48px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: #222;
  transition: background 0.15s;
}

.values {
  flex: 1;
  min-width: 0;
}

.hex-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
  line-height: 1.1;
}

.rgb-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--dim);
}
.channel.r { color: #ff6b6b; }
.channel.g { color: #69db7c; }
.channel.b { color: #74c0fc; }

.stability-wrap {
  margin-top: 6px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.stability-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.2s, background 0.2s;
}

.save-btn {
  flex-shrink: 0;
  padding: 0 16px;
  height: 48px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.save-btn:disabled {
  background: var(--border);
  color: var(--dim);
  cursor: default;
}
.save-btn:not(:disabled):active {
  transform: scale(0.95);
}

/* ── Saved list ─────────────────────────────────────────────────────── */
.saved-section {
  padding: 10px 14px 24px;
}

.saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.saved-title {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--dim);
  text-transform: uppercase;
}
.count-badge {
  display: inline-block;
  background: var(--border);
  color: var(--text);
  border-radius: 2px;
  padding: 1px 5px;
  font-size: 10px;
  margin-left: 4px;
}

.saved-actions {
  display: flex;
  gap: 6px;
}

.action-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.action-btn:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}
.action-btn.danger:not(:disabled):hover {
  border-color: var(--danger);
  color: var(--danger);
}
.action-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Color list */
.color-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-state {
  color: var(--dim);
  font-size: 11px;
  padding: 10px 0;
  text-align: center;
  letter-spacing: 0.1em;
}

.color-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.color-item .item-swatch {
  width: 28px;
  height: 28px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.item-info {
  flex: 1;
  min-width: 0;
}
.item-hex {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.item-rgb {
  font-size: 10px;
  color: var(--dim);
  margin-top: 1px;
}

.item-delete {
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 2px;
  transition: color 0.15s;
}
.item-delete:hover {
  color: var(--danger);
}

/* ── Toast ──────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--accent);
  color: #000;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 8px 18px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
