/* Owner pages: sign-in, recorder, video list, and the control window. */

/* ---------- Sign-in ---------- */

.signin-body { min-height: 100vh; display: flex; }
.signin { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.signin-card { width: 100%; max-width: 380px; padding: 32px 28px; display: flex; flex-direction: column; gap: 22px; }
.signin-title { font-size: 2.75rem; margin-top: 4px; }
.signin form { display: flex; flex-direction: column; gap: 10px; }
.code-input { font-size: 28px; letter-spacing: 0.5em; text-align: center; padding-left: 0.5em; font-weight: 700; min-height: 60px; }

/* ---------- Recorder: setup ---------- */

.rec-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
@media (max-width: 960px) { .rec-grid { grid-template-columns: 1fr; } .rec-side { order: -1; } }

.rec-settings { display: grid; gap: 12px; }
.cell {
  margin: 0; min-width: 0;
  background: var(--mc-white); border: 1px solid var(--mc-ivory-line); border-radius: var(--r-1);
  padding: 18px 20px; display: grid; gap: 12px;
}
fieldset.cell > legend { float: left; width: 100%; padding: 0; margin: 0 0 2px; }
fieldset.cell > legend + * { clear: both; }
.cell-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cell.is-off { opacity: 0.55; }

.source-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.source-opt { position: relative; cursor: pointer; }
.source-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.source-box {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 14px 6px 12px; border: 1px solid var(--border-2); border-radius: var(--r-1);
  background: var(--mc-ivory); color: var(--mc-charcoal);
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.source-box svg { width: 30px; height: 30px; }
.source-name { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; line-height: 1.25; }
.source-opt:hover .source-box { border-color: var(--mc-charcoal); }
.source-opt input:checked + .source-box { background: var(--mc-charcoal); border-color: var(--mc-charcoal); color: var(--mc-white); }
.source-opt input:focus-visible + .source-box { outline: 2px solid var(--mc-charcoal); outline-offset: 2px; }

.meter { height: 6px; background: var(--mc-ivory-deep); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--mc-charcoal); transform-origin: left center; transform: scaleX(0); transition: transform 80ms linear; }

.bubble-row { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.bubble-row .grow { flex: 1; min-width: 200px; }
.corner-grid { display: grid; grid-template-columns: repeat(2, 64px); grid-template-rows: repeat(2, 44px); gap: 4px; padding: 4px; border: 1px solid var(--border-2); border-radius: var(--r-1); background: var(--mc-ivory); width: max-content; }
.corner-opt { position: relative; cursor: pointer; display: block; }
.corner-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.corner-opt > span { display: block; width: 100%; height: 100%; border-radius: var(--r-1); border: 1px dashed var(--border-2); background: transparent; position: relative; }
.corner-opt > span::after { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--border-2); }
.corner-opt:nth-child(1) > span::after { top: 3px; left: 3px; }
.corner-opt:nth-child(2) > span::after { top: 3px; right: 3px; }
.corner-opt:nth-child(3) > span::after { bottom: 3px; left: 3px; }
.corner-opt:nth-child(4) > span::after { bottom: 3px; right: 3px; }
.corner-opt input:checked + span { background: var(--mc-white); border: 1px solid var(--mc-charcoal); }
.corner-opt input:checked + span::after { background: var(--mc-charcoal); }
.corner-opt input:focus-visible + span { outline: 2px solid var(--mc-charcoal); outline-offset: 2px; }
.corner-opt input:disabled + span { opacity: 0.5; }

.rec-side { display: grid; gap: 14px; position: sticky; top: 96px; }
@media (max-width: 960px) { .rec-side { position: static; } }
.preview { padding: 12px; }
.preview-screen {
  position: relative; aspect-ratio: 16 / 9; background: var(--mc-charcoal); border-radius: var(--r-1); overflow: hidden;
  --bubble: 24%;
}
.preview-screen[data-size="small"] { --bubble: 17%; }
.preview-screen[data-size="large"] { --bubble: 32%; }
.preview-mock { position: absolute; inset: 9% 8%; display: grid; grid-template-rows: 10% 1fr 1fr; gap: 6%; }
.preview-mock span { background: rgba(255, 255, 255, 0.07); border-radius: var(--r-1); }
.preview-mock span:first-child { width: 42%; }
.preview-bubble {
  position: absolute; height: var(--bubble); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  border: 2px solid rgba(245, 240, 232, 0.95); background: var(--mc-charcoal-soft);
  bottom: 3.5%; left: 2%;
  transition: height var(--dur-base) var(--ease-out);
}
.preview-screen[data-corner="top-left"] .preview-bubble { top: 6%; bottom: auto; left: 3.5%; right: auto; }
.preview-screen[data-corner="top-right"] .preview-bubble { top: 6%; bottom: auto; right: 3.5%; left: auto; }
.preview-screen[data-corner="bottom-left"] .preview-bubble { bottom: 6%; top: auto; left: 3.5%; right: auto; }
.preview-screen[data-corner="bottom-right"] .preview-bubble { bottom: 6%; top: auto; right: 3.5%; left: auto; }
.preview-screen[data-cam="off"] .preview-bubble { display: none; }
.preview-bubble video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.bubble-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--mc-slate-soft); }
.bubble-off svg { width: 34%; height: 34%; }

.center { text-align: center; }
.unsupported, .recovery, .perm { margin-bottom: 24px; }
.perm { margin-bottom: 0; align-items: center; }
.recovery .label { margin: 0 0 6px; color: var(--mc-charcoal); }
.recovery-text { font-family: var(--font-serif); font-size: 17px; margin: 0; overflow-wrap: anywhere; }
.recovery-text a { color: var(--mc-charcoal); display: inline-block; padding: 10px 0; }
.recovery-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.recovery > div:first-child { flex: 1; min-width: 240px; }

/* ---------- Recorder: live ---------- */

.live { max-width: 640px; margin: 24px auto 0; padding: 36px 28px 28px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.live-top { display: inline-flex; align-items: center; gap: 10px; }
.live-top .label { color: var(--mc-charcoal); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mc-charcoal); display: inline-block; flex: none; }
[data-phase="recording"] .rec-dot, .pip[data-state="recording"] .rec-dot { animation: recfade 1.6s ease-in-out infinite; }
[data-phase="paused"] .rec-dot, .pip[data-state="paused"] .rec-dot { background: var(--mc-slate-soft); }
@keyframes recfade { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.live-timer, .countdown { font-family: var(--font-display); font-weight: 900; font-size: clamp(4.5rem, 14vw, 7.5rem); line-height: 1; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.live-limit { font-size: 13px; margin: -4px 0 6px; }
.live-controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.live-controls .btn { min-width: 150px; }
.live-secondary { display: flex; gap: 22px; justify-content: center; }
.confirm { width: 100%; border: 2px solid var(--mc-charcoal); border-radius: var(--r-1); padding: 14px; display: grid; gap: 10px; }
.confirm p { margin: 0; font-weight: 600; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.live-upload { margin: 4px 0 0; font-size: 14px; color: var(--mc-slate-ink); min-height: 1.5em; }
.live .hint { max-width: 460px; }

/* ---------- Recorder: finished ---------- */

.finish { max-width: 720px; margin: 24px auto 0; padding: 32px 28px; display: grid; gap: 14px; }
.finish h2 { font-size: clamp(2rem, 5vw, 2.75rem); }
.link-row { display: flex; gap: 8px; }
.link-input { font-weight: 600; font-size: 16px; }
@media (max-width: 560px) { .link-row { flex-direction: column; } }
.progress { height: 6px; background: var(--mc-ivory-deep); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--mc-charcoal); transform-origin: left center; transform: scaleX(0); transition: transform var(--dur-base) var(--ease-out); }
.finish-detail { margin: 0; font-size: 15px; color: var(--mc-slate-ink); min-height: 1.5em; }
.finish-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Control window (Picture-in-Picture) ---------- */

.pip-body { background: var(--mc-charcoal); color: var(--mc-white); margin: 0; height: 100vh; overflow: hidden; }
.pip { height: 100%; display: flex; flex-direction: column; }
.pip-cam { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 14px 14px 0; }
.pip-cam-video { height: 100%; max-height: 200px; aspect-ratio: 1; border-radius: 50%; object-fit: cover; transform: scaleX(-1); border: 2px solid rgba(245, 240, 232, 0.95); background: var(--mc-charcoal-soft); }
.pip-bar { padding: 12px 14px 12px; display: grid; gap: 8px; }
.pip-status { display: flex; align-items: center; gap: 10px; }
.pip .rec-dot { background: var(--mc-white); }
.pip-timer { font-family: var(--font-display); font-weight: 900; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.pip-msg { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mc-slate-soft); }
.pip-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pip-btn {
  -webkit-appearance: none; appearance: none; min-height: 40px; border-radius: var(--r-1);
  font-family: var(--font-sans); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; border: 2px solid rgba(255, 255, 255, 0.85); background: transparent; color: var(--mc-white);
}
.pip-btn:hover { background: var(--mc-charcoal-soft); }
.pip-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pip-stop { background: var(--mc-auburn); border-color: var(--mc-auburn); }
.pip-stop:hover { background: var(--mc-auburn-deep); border-color: var(--mc-auburn-deep); }
.pip-more { display: flex; justify-content: space-between; }
.pip-link { -webkit-appearance: none; appearance: none; background: none; border: 0; padding: 4px 0; color: var(--mc-slate-soft); font-family: var(--font-sans); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.pip-link:hover { color: var(--mc-white); }
.pip-confirm { display: grid; gap: 8px; }
.pip-confirm-text { margin: 0; font-size: 13px; font-weight: 700; }
.pip-yes { border-color: var(--mc-white); background: var(--mc-white); color: var(--mc-charcoal); }
.pip-yes:hover { background: var(--mc-ivory); }
.pip[data-state="waiting"] .pip-buttons, .pip[data-state="waiting"] .pip-more { display: none; }
.pip[data-state="waiting"] .pip-timer { display: none; }
.pip[data-state="stopped"] .pip-buttons, .pip[data-state="stopped"] .pip-more { display: none; }
/* The control window opens before Chrome's picker says what's shared. If it
   opened in the short size (whole screen picked on the page) but a tab or a
   window was picked, there's no room for the camera preview, so it stays
   hidden instead of being squeezed into a dot. */
@media (max-height: 300px) {
  .pip-cam { display: none; }
}

/* ---------- Video list ---------- */

.lib-tools { display: grid; gap: 16px; margin-bottom: 28px; }
.defaults { background: var(--mc-white); border: 1px solid var(--mc-ivory-line); border-radius: var(--r-1); }
.defaults > summary {
  list-style: none; cursor: pointer; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.defaults > summary::-webkit-details-marker { display: none; }
.defaults > summary::after { content: ""; width: 10px; height: 10px; border-right: 2px solid var(--mc-charcoal); border-bottom: 2px solid var(--mc-charcoal); transform: rotate(45deg); transition: transform var(--dur-base) var(--ease-out); margin-right: 4px; }
.defaults[open] > summary::after { transform: rotate(-135deg); }
.defaults .summary-text { display: grid; gap: 2px; }
.defaults .summary-text .label { color: var(--mc-charcoal); }
.defaults .summary-now { font-size: 14px; color: var(--mc-slate-ink); }
.defaults-body { padding: 0 20px 20px; display: grid; gap: 14px; }
.two-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; }
@media (max-width: 640px) { .two-fields { grid-template-columns: 1fr; } }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--mc-ivory-line); }
.saved-list:empty { display: none; }
.saved-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 4px 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--mc-ivory-line); }
.saved-words { font-weight: 700; }
.saved-url { font-size: 14px; color: var(--mc-slate-ink); overflow-wrap: anywhere; }
@media (max-width: 640px) { .saved-item { grid-template-columns: minmax(0, 1fr) auto; } .saved-url { grid-column: 1; grid-row: 2; } .saved-item .link-btn { grid-row: 1 / span 2; grid-column: 2; } }
.finish-button { display: grid; gap: 6px; margin-top: 14px; max-width: 420px; }

.video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .video-grid { grid-template-columns: 1fr; } }

.vcard { display: flex; flex-direction: column; transition: box-shadow var(--dur-base) var(--ease-out); }
.vcard:hover { box-shadow: var(--shadow-2); }
.vthumb { position: relative; aspect-ratio: 16 / 9; background: var(--mc-charcoal); border-radius: var(--r-1) var(--r-1) 0 0; overflow: hidden; display: block; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; }
.vthumb .no-pic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--mc-slate-soft); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.vdur { position: absolute; right: 8px; bottom: 8px; background: rgba(43, 43, 43, 0.9); color: var(--mc-white); font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: var(--r-1); font-variant-numeric: tabular-nums; }
.vflag { position: absolute; left: 8px; top: 8px; background: var(--mc-white); color: var(--mc-charcoal); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding: 4px 7px; border-radius: var(--r-1); }
.vbody { padding: 16px 16px 14px; display: grid; gap: 8px; flex: 1; align-content: start; }
.vtitle { font-size: 1.25rem; line-height: 1.1; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vmeta { font-size: 13px; color: var(--mc-slate-ink); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.vmeta strong { color: var(--mc-charcoal); font-weight: 700; }
.vstatus { font-size: 13px; color: var(--mc-slate-ink); margin: 0; }
.vactions { padding: 0 16px 16px; display: grid; gap: 10px; }
.vlinks { display: flex; flex-wrap: wrap; gap: 0 16px; }

.empty { text-align: center; padding: 64px 16px; border: 1px dashed var(--border-2); border-radius: var(--r-1); }
.empty h2 { font-size: 2rem; margin-bottom: 10px; }
.empty p { margin: 0 0 20px; font-family: var(--font-serif); font-size: 18px; color: var(--mc-slate-ink); }

/* ---------- Editor dialog ---------- */

.editor {
  width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--mc-ivory-line); border-radius: var(--r-2);
  background: var(--mc-ivory); color: var(--mc-charcoal); box-shadow: var(--shadow-3);
}
.editor::backdrop { background: rgba(43, 43, 43, 0.55); }
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.editor-head h2 { font-size: 1.6rem; overflow-wrap: anywhere; }
.editor-close { -webkit-appearance: none; appearance: none; background: none; border: 0; width: 44px; height: 44px; flex: none; cursor: pointer; color: var(--mc-charcoal); display: flex; align-items: center; justify-content: center; border-radius: var(--r-1); }
.editor-close:hover { background: var(--mc-ivory-deep); }
.editor-close svg { width: 20px; height: 20px; }
.tabs { display: flex; gap: 4px; padding: 14px 22px 0; border-bottom: 1px solid var(--mc-ivory-line); overflow-x: auto; }
.tab {
  -webkit-appearance: none; appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  min-height: 44px; padding: 10px 12px; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
  font-family: var(--font-sans); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mc-slate-ink);
}
.tab[aria-selected="true"] { color: var(--mc-charcoal); border-bottom-color: var(--mc-charcoal); }
.tab:hover { color: var(--mc-charcoal); }
.panel { padding: 20px 22px 22px; display: grid; gap: 14px; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.trim-player { position: relative; background: var(--mc-charcoal); border-radius: var(--r-1); overflow: hidden; aspect-ratio: 16 / 9; width: min(100%, calc(42vh * 16 / 9)); margin: 0 auto; }
.trim-player video { width: 100%; height: 100%; object-fit: contain; background: var(--mc-charcoal); }
.trim-bar { position: relative; height: 44px; }
.trim-track { position: absolute; left: 0; right: 0; top: 18px; height: 8px; background: var(--mc-ivory-deep); border-radius: 999px; }
.trim-keep { position: absolute; top: 18px; height: 8px; background: var(--mc-charcoal); border-radius: 999px; }
.trim-head { position: absolute; top: 8px; width: 2px; height: 28px; background: var(--mc-slate); pointer-events: none; }
/* The start and end handles are 44px tall so they're easy to grab on a phone. */
.trim-bar input[type="range"] {
  -webkit-appearance: none; appearance: none; position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 44px; margin: 0;
  background: none; pointer-events: none;
}
.trim-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto; width: 22px; height: 44px; border-radius: var(--r-1);
  background: var(--mc-white); border: 2px solid var(--mc-charcoal); cursor: ew-resize; box-shadow: var(--shadow-1);
}
.trim-bar input[type="range"]::-moz-range-thumb {
  pointer-events: auto; width: 18px; height: 40px; border-radius: var(--r-1);
  background: var(--mc-white); border: 2px solid var(--mc-charcoal); cursor: ew-resize;
}
.trim-bar input[type="range"]::-webkit-slider-runnable-track { background: none; height: 44px; }
.trim-bar input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--mc-charcoal); outline-offset: 2px; }
.trim-times { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.trim-times strong { font-variant-numeric: tabular-nums; }

.radio-list { display: grid; gap: 8px; }
.radio-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border-2); border-radius: var(--r-1); background: var(--mc-white); cursor: pointer; }
.radio-item input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--mc-charcoal); flex: none; }
.radio-item .ri-title { font-weight: 700; font-size: 14px; }
.radio-item .ri-sub { font-size: 13px; color: var(--mc-slate-ink); overflow-wrap: anywhere; }

.cue-list { display: grid; gap: 6px; max-height: 46vh; overflow: auto; padding-right: 4px; }
.cue { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; align-items: center; }
.cue-time { -webkit-appearance: none; appearance: none; background: none; border: 0; padding: 6px 0; text-align: left; font-family: var(--font-sans); font-size: 13px; font-weight: 700; color: var(--mc-slate-ink); font-variant-numeric: tabular-nums; cursor: pointer; text-decoration: underline; text-decoration-color: var(--border-2); text-underline-offset: 3px; }
.cue-time:hover { color: var(--mc-charcoal); }
.cue .input { min-height: 44px; padding: 8px 12px; font-size: 14px; }

.confirm-dialog { width: min(460px, calc(100vw - 32px)); padding: 24px; border: 2px solid var(--mc-charcoal); border-radius: var(--r-2); background: var(--mc-ivory); }
.confirm-dialog::backdrop { background: rgba(43, 43, 43, 0.55); }
.confirm-dialog h2 { font-size: 1.6rem; margin-bottom: 10px; }
.confirm-dialog p { margin: 0 0 18px; font-family: var(--font-serif); font-size: 17px; }

@media (max-width: 640px) {
  .editor { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; margin: 0; }
  .editor-head, .panel { padding-left: 16px; padding-right: 16px; }
  .tabs { padding-left: 12px; padding-right: 12px; }
}

.stack { display: grid; gap: 14px; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
