:root {
  --bg: #1b1b1f;
  --card: #26262c;
  --text: #f2f2f5;
  --muted: #a4a4b0;
  --accent: #0e72ed;
  --accent-hover: #2d8cff;
  --border: #35353d;
  --ok: #2fbf71;
  --warn: #f5a524;
  --err: #e5484d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* The camera webview is composited over the video: the page itself must be transparent. */
body[data-context="inCamera"] { background: transparent; overflow: hidden; }
body[data-context="preview-camera"] {
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #4a5568 0%, #2d3748 60%, #1a202c 100%);
}

/* ---------- Overlay (drawn onto the video) ---------- */

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

.clock-badge {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15em;
  padding: 0.45em 0.7em;
  border-radius: 0.5em;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  --size: 5vh;
  font-size: var(--size);
  margin: 3vh 3vh;
}
.clock-badge[data-size="s"] { --size: 3.6vh; }
.clock-badge[data-size="m"] { --size: 5vh; }
.clock-badge[data-size="l"] { --size: 7vh; }

.clock-badge[data-position="top-right"]    { top: 0; right: 0; align-items: flex-end; }
.clock-badge[data-position="top-left"]     { top: 0; left: 0;  align-items: flex-start; }
.clock-badge[data-position="bottom-right"] { bottom: 0; right: 0; align-items: flex-end; }
.clock-badge[data-position="bottom-left"]  { bottom: 0; left: 0;  align-items: flex-start; }

.clock-time { font-weight: 600; letter-spacing: 0.02em; }
.clock-label { font-size: 0.45em; font-weight: 500; opacity: 0.9; letter-spacing: 0.03em; }
.clock-label:empty { display: none; }

/* ---------- Sidebar panel ---------- */

.panel {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-header h1 { font-size: 20px; margin: 0 0 4px; }
.panel-header p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.tz { font-size: 16px; font-weight: 600; margin-top: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.card h2 { font-size: 13px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.preview-clock { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #2f2f37;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #393942; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: default; }

.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; font-size: 14px; }
.field select {
  background: #1f1f24;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  max-width: 55%;
}
.field.checkbox { justify-content: flex-start; }
.field.checkbox input { width: 16px; height: 16px; }

.status { display: none; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.status[data-kind] { display: block; }
.status[data-kind="ok"]   { background: rgba(47, 191, 113, 0.15); border: 1px solid var(--ok); }
.status[data-kind="warn"] { background: rgba(245, 165, 36, 0.15); border: 1px solid var(--warn); }
.status[data-kind="err"]  { background: rgba(229, 72, 77, 0.15); border: 1px solid var(--err); }

/* Preview: a 16:9 frame; the badge uses the frame's height via container units. */
.preview-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #4a5568 0%, #2d3748 60%, #1a202c 100%);
  container-type: size;
}
.preview-person {
  position: absolute;
  left: 50%; bottom: -10%;
  width: 46%; height: 70%;
  transform: translateX(-50%);
  background: #6b7a90;
  border-radius: 45% 45% 10% 10% / 60% 60% 10% 10%;
}
.preview-person::before {
  content: "";
  position: absolute;
  left: 50%; top: -40%;
  width: 55%; aspect-ratio: 1;
  transform: translateX(-50%);
  background: #8a99ad;
  border-radius: 50%;
}
.preview-frame .clock-badge { margin: 3cqh; }
.preview-frame .clock-badge[data-size="s"] { --size: 3.6cqh; }
.preview-frame .clock-badge[data-size="m"] { --size: 5cqh; }
.preview-frame .clock-badge[data-size="l"] { --size: 7cqh; }
