:root {
  --paper: #f1efe9;
  --paper-2: #e7e4db;
  --card: #fbfaf7;
  --ink: #141518;
  --ink-2: #2a2c31;
  --muted: #5f6168;
  --line: rgba(20, 21, 24, 0.14);
  --red: #d81e28;
  --red-soft: #fbe3e4;
  --ok: #1d7a47;
  --ok-soft: #e1f2e8;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --radius: 10px;
  font-family: 'Archivo', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); line-height: 1.45; font-size: 16px; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.1; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
p { margin: 0 0 0.8em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Header */
.topbar {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 14px 24px; border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; font-size: 20px; text-decoration: none; }
/* Mechanica shield: the same geometry as getmechanica.com's icon.svg. */
.brand .shield {
  width: 26px; height: 28px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='11 9 42 46'%3E%3Cpath d='M11 9h42v29L32 55 11 38V9Z' fill='%23D81E28'/%3E%3Cpath d='M18 42V21h6.2l7.8 11.6L39.8 21H46v21h-6V31.2L32 43.4 24 31.2V42h-6Z' fill='%23F1EFE9'/%3E%3C/svg%3E") no-repeat center / contain;
}
.brand small { font-weight: 500; letter-spacing: 0; color: var(--muted); font-size: 14px; margin-left: 4px; }

/* Layout */
.wrap { max-width: 720px; margin: 0 auto; padding: 32px 20px 64px; }
.wrap.wide { max-width: 1040px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* Controls */
button, .btn {
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; border-radius: 8px;
  border: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  padding: 11px 18px; display: inline-flex; align-items: center; gap: 8px; justify-content: center; text-decoration: none;
}
button:hover:not(:disabled), .btn:hover { background: var(--ink-2); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary, .btn.secondary { background: transparent; color: var(--ink); }
button.secondary:hover:not(:disabled) { background: var(--paper-2); }
button.danger { background: var(--red); border-color: var(--red); color: #fff; }
button.danger:hover:not(:disabled) { background: #b8161f; }
button.big { font-size: 18px; padding: 15px 26px; }
button.small { font-size: 13px; padding: 6px 12px; border-width: 1.5px; }
input[type=text], input[type=password], select {
  font: inherit; font-size: 16px; width: 100%; padding: 11px 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(216, 30, 40, 0.35); outline-offset: 1px; }
label.field { display: block; font-weight: 600; font-size: 14px; }
label.field > span { display: block; margin-bottom: 6px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
label.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--red); }

/* Notices */
.notice { border-radius: var(--radius); padding: 14px 16px; border: 1.5px solid var(--line); background: var(--card); }
.notice.red { border-color: var(--red); background: var(--red-soft); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice strong { display: block; margin-bottom: 2px; }
.error { color: var(--red); font-weight: 600; }

/* Video */
.video { position: relative; background: var(--ink); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video video.mirror { transform: scaleX(-1); }
.video .label {
  position: absolute; left: 10px; bottom: 10px; background: rgba(20, 21, 24, 0.75); color: var(--paper);
  font-size: 13px; font-weight: 600; padding: 4px 9px; border-radius: 6px;
}
.video .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; color: rgba(241, 239, 233, 0.7);
  font-weight: 600; text-align: center; padding: 20px;
}

/* Mic meter */
.meter { height: 12px; border-radius: 6px; background: var(--paper-2); overflow: hidden; border: 1px solid var(--line); }
.meter > div { height: 100%; width: 100%; background: linear-gradient(90deg, var(--ok) 0 70%, #d9a400 70% 88%, var(--red) 88%); transform-origin: left; transform: scaleX(0); }

/* Check list */
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.checks .tick {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 13px; font-weight: 800; margin-top: 1px;
}
.checks li.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.checks li.done .tick::after { content: '✓'; }

/* REC badge */
.rec-badge {
  display: inline-flex; align-items: center; gap: 8px; background: var(--red); color: #fff; font-weight: 800;
  letter-spacing: 0.08em; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-variant-numeric: tabular-nums;
}
.rec-badge::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
.idle-badge { display: inline-flex; align-items: center; gap: 8px; background: var(--paper-2); color: var(--muted); font-weight: 700; padding: 6px 12px; border-radius: 999px; font-size: 14px; }
@keyframes blink { 50% { opacity: 0.25; } }

/* Upload progress */
.progress { height: 10px; border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--ink); width: 0; transition: width 0.3s; }

/* Status pills */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--paper-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.red { background: var(--red-soft); color: var(--red); }

/* Studio (host) */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; padding: 20px 24px 40px; }
.stage { display: grid; gap: 14px; align-content: start; }
.stage > .video:not(.self) { max-width: calc((100vh - 130px) * 16 / 9); }
.stage .self { width: 38%; min-width: 220px; }
.side { display: grid; gap: 16px; align-content: start; }
.side .card { padding: 16px; }
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-size: 13px; padding: 8px 10px; }
.status-row { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.status-row:first-of-type { border-top: 0; padding-top: 0; }
.status-row .who { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.status-row .detail { font-size: 13px; color: var(--muted); }
.takes { display: grid; gap: 12px; }
.take h4 { margin: 0 0 6px; font-size: 14px; }
.track { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; padding: 6px 0; border-top: 1px dashed var(--line); }
.track .name { font-weight: 600; }

/* Guest call: full-screen and minimal, like a plain video call. */
body.in-call { background: #0e0f11; overflow: hidden; }
body.in-call .topbar, body.in-call #upload-banner { display: none !important; }
.call { position: fixed; inset: 0; }
.call-stage { position: absolute; inset: 0; }
.call-stage .video.remote { position: absolute; inset: 0; border-radius: 0; aspect-ratio: auto; background: #0e0f11; }
.call-stage .video.remote video { object-fit: contain; }
.call-stage .video.remote .placeholder { background: rgba(14, 15, 17, 0.55); color: #f1efe9; font-size: 18px; }
.call-stage .self {
  position: absolute; right: 16px; bottom: 16px; width: 18%; min-width: 150px; max-width: 280px;
  aspect-ratio: 16 / 9; border: 2px solid rgba(241, 239, 233, 0.6); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.rec-dot {
  position: absolute; top: 16px; left: 16px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(14, 15, 17, 0.6); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  padding: 5px 10px; border-radius: 999px;
}
.rec-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: blink 1.6s infinite; }
.leave {
  position: absolute; top: 14px; right: 16px; font-size: 13px; padding: 7px 14px; border-width: 1.5px;
  background: rgba(14, 15, 17, 0.6); border-color: rgba(241, 239, 233, 0.35); color: #fff;
}
.leave:hover:not(:disabled) { background: var(--red); border-color: var(--red); }
.call-pill {
  position: absolute; left: 16px; bottom: 16px; background: rgba(14, 15, 17, 0.7); color: #f1efe9;
  font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
}
.call-notice { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); }
.banner { border-radius: var(--radius); padding: 14px 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.banner .grow { min-width: 200px; }
.banner.uploading { background: var(--ink); color: var(--paper); }
.banner.uploading .progress { background: rgba(241, 239, 233, 0.2); }
.banner.uploading .progress > div { background: var(--red); }
.banner.done { background: var(--ok-soft); border: 1.5px solid var(--ok); }
.banner.trouble { background: var(--warn-soft); border: 1.5px solid var(--warn); }

/* Episodes */
.episodes { display: grid; gap: 10px; }
.episode { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 16px; }
.episode .title { font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: 0.2s;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-weight: 600; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; padding: 16px; }
}
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .wrap { padding: 24px 16px 48px; }
}
