/* -------------------------
   Modern Recorder Styles
   ------------------------- */

/* Base / Theme */
:root {
    --bg: #f2f5fb;
    /* soft background to avoid “column” banding */
    --card: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --ring: #2563eb;
    --danger: #ef4444;
    --info: #0ea5e9;
    --radius: 16px;
    --shadow: 0 12px 32px rgba(2, 6, 23, .08);
    --border: 1px solid rgba(2, 6, 23, .06);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);

    /* simple base; all the color comes from ::before */
    background: #f6f9ff;

    display: grid;
    place-items: center;
    padding: 32px;

    position: relative;
    isolation: isolate;
    overflow-x: hidden;
    /* avoids any 1px artifacts on some GPUs */
}


/* Recorder Card */
.recorder-card {
    width: min(980px, 92vw);
    background: var(--card);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow);
    border: var(--border);
    overflow: hidden;
}

/* Header */
.card-header {
    padding: 18px 22px;
    border-bottom: var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);

    position: relative;
    /* so the icon can be absolutely placed inside */

}

.card-header .title h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.card-header .title p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

/* Preview area */
.preview-wrap {
    position: relative;
    padding: 18px;
}

.preview-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    /* warm center + cool bottom glow */
    background:
        radial-gradient(520px 320px at 50% 22%, rgba(255, 236, 170, .55), transparent 60%),
        radial-gradient(720px 420px at 50% 95%, rgba(172, 209, 255, .30), transparent 70%);
    filter: blur(22px) saturate(120%);
}


#preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    /* stronger, GPT-style blobs */
    background:
        radial-gradient(820px 520px at 20% 8%, rgba(255, 146, 164, .85), transparent 62%),
        radial-gradient(900px 560px at 78% 12%, rgba(255, 210, 150, .85), transparent 64%),
        radial-gradient(980px 620px at 50% 115%, rgba(155, 185, 255, .85), transparent 66%),
        radial-gradient(900px 560px at -6% 96%, rgba(150, 240, 255, .75), transparent 66%),
        linear-gradient(180deg, #f4f8ff 0%, #eef4ff 100%);
    border-radius: calc(var(--radius) - 2px);
    display: block;
    object-fit: cover;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .14),
        inset 0 40px 160px rgba(255, 255, 255, .22);
}



#webcamOverlay {
    position: absolute;
    inset: 18px;
    width: calc(100% - 36px);
    height: calc((100% - 36px) * 9 / 16);
    /* follows preview aspect */
    pointer-events: none;
}

/* Controls layout */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 14px 18px 20px;
    border-top: var(--border);
}

@media (max-width: 720px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }
}

/* Webcam-only UI mode: hide controls and center the Record button */
.controls-grid.webcam-mode {
    grid-template-columns: 1fr;
    /* single column */
}

.controls-grid.webcam-mode .toggles {
    display: none;
    /* hide Include system audio + mic select */
}

.controls-grid.webcam-mode .actions {
    justify-content: center;
    /* center the Record button */
}


/* Recording mode: hide options + center the Stop button */
.recorder-card.recording .controls-grid {
  grid-template-columns: 1fr;              /* collapse to one column */
}

/* Hide ONLY the options while recording */
.recorder-card.recording .controls-grid .toggles,
.recorder-card.recording .controls-grid .select-wrap,
.recorder-card.recording .controls-grid #micSelect {
  display: none !important;
}

/* Keep the buttons row visible and centered */
.recorder-card.recording .controls-grid .actions {
  display: flex !important;
  justify-content: center;
  gap: 12px;
}

/* Show only Stop while recording */
.recorder-card.recording #stopBtn { display: inline-flex !important; }
.recorder-card.recording #startBtn,
.recorder-card.recording #againBtn { display: none !important; }




/* Toggles + select */
.toggles {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
}

@media (min-width: 721px){
  .toggles { flex-wrap: nowrap; }          /* keep all controls on one line */
  .controls-grid .upload-btn{ align-self: center; }
}


/* Keep the Upload button aligned with the toggles row */
.controls-grid .upload-btn{
  align-self: center;
  margin-right: 2px;
}


/* Beautiful switches */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--muted);
    user-select: none;
}

.toggle input {
    appearance: none;
    width: 40px;
    height: 22px;
    background: #e5e7eb;
    border-radius: 999px;
    position: relative;
    outline: none;
    cursor: pointer;
    transition: background .2s ease;
}

.toggle input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    transition: transform .2s ease;
}

.toggle input:checked {
    background: var(--ring);
}

.toggle input:checked::after {
    transform: translateX(18px);
}

/* Select */
.select-wrap select,
#micSelect {
    appearance: none;
    border: 1px solid #d0d7de;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    min-width: 240px;
    max-width: 100%;
    color: #0f172a;
}

.select-wrap {
    position: relative;
}

.select-wrap::after {
    content: "▾";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 12px;
    color: #64748b;
}

/* Buttons */
.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.actions button {
    border: 0;
    padding: 10px 16px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    transition: transform .06s ease, box-shadow .2s ease, opacity .15s ease;
    box-shadow: 0 6px 16px rgba(2, 6, 23, .12);
}

.actions button:active {
    transform: translateY(1px);
}

#startBtn {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

#stopBtn {
    background: linear-gradient(180deg, #f87171 0%, var(--danger) 100%);
}

#againBtn {
    background: linear-gradient(180deg, #38bdf8 0%, var(--info) 100%);
}

/* Accessibility helpers */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}



/* ----- Videos Today list ----- */
.list-card {
    margin: 18px auto 0;
    background: var(--card);
    border: var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.videos-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 18px 18px;

    /* show 8 rows max; scroll for more */
    max-height: 422px;
    /* 8 rows @ 40px + 7 gaps @ 10px + top/bottom padding (14+18) */
    overflow-y: auto;
}


.video-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    /* name | copy | time */
    gap: 8px 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid rgba(2, 6, 23, 06);
    border-radius: 12px;

    /* keep rows consistent so 8 fit cleanly */
    min-height: 40px;
}

.video-item:hover {
    background: #f8fafc;
    /* gentle hover */
    border-color: rgba(2, 6, 23, .10);
    box-shadow: 0 2px 6px rgba(2, 6, 23, .06);
}

.video-item a {
    min-width: 0;
    /* enables ellipsis in CSS grid */
    display: block;
    text-decoration: none;
    font-weight: 500;
    /* lighter weight */
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    /* single line */
    overflow: hidden;
    text-overflow: ellipsis;
    /* … for long names */
}

.video-meta {
    color: var(--muted);
    font-size: 13px;
    justify-self: end;
}


.empty-state {
    padding: 18px;
    color: var(--muted);
}

/* copy button */
.copy-btn {
    border: 0;
    background: transparent;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0;
    /* hidden by default */
    transform: translateY(2px);
    transition: opacity .15s ease, transform .15s ease, background .15s ease;
}

/* Mobile: always show the copy icon (no hover on touch) */
@media (max-width: 720px) {
    .copy-btn {
        opacity: 1;
        /* make it visible */
        transform: translateY(0);
        /* keep it in place */
    }
}


.video-item:hover .copy-btn {
    /* reveal on hover */
    opacity: 1;
    transform: translateY(0);
}

.copy-btn:hover {
    background: rgba(2, 6, 23, .05);
}

.copy-btn:focus {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(10px);
    background: #111827;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 99999;
    font-size: 14px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%) translateY(8px);
    background: #111827;
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 99999;
    font-size: 13px;
    line-height: 1.2;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ---- Smooth button transitions ---- */
#startBtn,
#stopBtn,
#againBtn {
    transition: opacity .18s ease, transform .18s ease;
    will-change: opacity, transform;
}

.btn-enter {
    opacity: 0;
    transform: translateY(4px) scale(.98);
}

.btn-show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.btn-hide {
    opacity: 0;
    transform: translateY(4px) scale(.98);
    pointer-events: none;
}

/* ---- Loading state for the Record button ---- */
#startBtn.loading {
    position: relative;
    color: transparent;
    /* hide original text while loading label shows */
}

#startBtn.loading::after {
    content: " ";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: inherit;
}

#startBtn.loading::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, .6);
    border-top-color: #fff;
    border-radius: 50%;
    /* use a dedicated animation that preserves the translate */
    animation: spin-centered .8s linear infinite;
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes spin-centered {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}


/* --- Center overlay while recorder initializes --- */
.loading-overlay {
    position: absolute;
    inset: 18px;
    /* matches .preview-wrap padding */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    border-radius: calc(var(--radius) - 2px);
    background: rgba(11, 18, 32, .45);
    backdrop-filter: blur(2px);
    z-index: 10;
    pointer-events: none;
    /* do not block UI */
}

.loading-text {
    color: #fff;
    font-weight: 600;
    letter-spacing: .2px;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}


/* --- Center overlay while recorder initializes --- */
.loading-overlay {
    position: absolute;
    inset: 18px;
    /* sits exactly over the preview area */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    border-radius: calc(var(--radius) - 2px);
    background: rgba(11, 18, 32, .45);
    backdrop-filter: blur(2px);
    z-index: 20;
    pointer-events: none;
    /* do not block clicks */
}

.loading-text {
    color: #fff;
    font-weight: 600;
    letter-spacing: .2px;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}


/* Ensure anything with the HTML [hidden] attribute is truly hidden */
[hidden] {
    display: none !important;
}

.loading-overlay[hidden] {
    display: none !important;
}


/* Idle state overlay (visible before recording) */
.idle-overlay {
    position: absolute;
    inset: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: calc(var(--radius) - 2px);
    color: #68778f;
    z-index: 5;
    pointer-events: none;
    background: none;
    /* no tint – let the bright preview show through */
}


.idle-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 22px;
    border-radius: 14px;

    /* darker glass so it stands out on the bright gradient */
    background: rgba(15, 23, 42, .70);
    border: 1px solid rgba(255, 255, 255, .28);
    /* solid, not dashed */
    box-shadow: 0 10px 30px rgba(2, 6, 23, .25), inset 0 1px 0 rgba(255, 255, 255, .10);
    backdrop-filter: blur(4px) saturate(120%);
}


.idle-overlay h3 {
    margin: 4px 0 0;
    font-size: 17px;
    color: #ffffff;
    letter-spacing: .2px;
}

.idle-overlay p {
    margin: 0;
    font-size: 13px;
    color: #e2e8f0;
    opacity: .95;
}

.idle-card svg {
    color: #e2e8f0;
    opacity: .98;
    filter: drop-shadow(0 2px 6px rgba(2, 6, 23, .25));
}



/* pastel background blobs like ChatGPT */
/* Seamless full-viewport background layer (no lines) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    /* fill viewport exactly */
    pointer-events: none;
    z-index: -1;
    background:
        /* colorful blobs */
        radial-gradient(900px 560px at 20% 6%, rgba(255, 170, 188, .60), transparent 60%),
        radial-gradient(1000px 640px at 82% 8%, rgba(255, 205, 150, .62), transparent 62%),
        radial-gradient(1100px 700px at 50% 110%, rgba(160, 185, 255, .70), transparent 66%),
        radial-gradient(1000px 620px at -6% 96%, rgba(160, 250, 255, .60), transparent 66%),
        /* gentle base wash so there’s no edge between layers */
        linear-gradient(180deg, #fdfcff 0%, #f5f9ff 100%);
    background-repeat: no-repeat;
    filter: blur(54px) saturate(130%);
    transform: translateZ(0);
    /* avoids hairline seams on some GPUs */
}


/* Webcam-only toggle, pinned to top-right of the preview area */
.webcam-only-toggle{
  position:absolute; top:18px; right:18px; z-index:5;

  /* tighter size + premium glass look */
  padding:6px 10px;
  border-radius:9999px;
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,252,255,.90));
  border:1px solid rgba(2,6,23,.08);
  backdrop-filter: blur(8px) saturate(115%);
  box-shadow:
    0 8px 22px rgba(2,6,23,.10),
    inset 0 1px 0 rgba(255,255,255,.75);

  /* subtle lift on hover */
  transition: box-shadow .18s ease, transform .12s ease;
}
.webcam-only-toggle:hover{ box-shadow:0 12px 28px rgba(2,6,23,.14); transform:translateY(-1px); }


.webcam-only-toggle .toggle{
  gap:8px;
  font-size:13px;
  font-weight:600;
  color:#334155;
}


/* Compact switch ONLY inside the webcam pill */
.webcam-only-toggle .toggle input{
  width:34px; height:18px;
  background:#e7ebf2;
}
.webcam-only-toggle .toggle input::after{
  top:2px; left:2px;
  width:14px; height:14px;
  box-shadow:0 1px 2px rgba(0,0,0,.18);
}
.webcam-only-toggle .toggle input:checked{
  background:#2563eb;
}
.webcam-only-toggle .toggle input:checked::after{
  transform:translateX(16px);
}


/* Small logout icon in the header (top-left) */
.logout-icon {
    position: absolute;
    right: 12px;
    /* moved from left to right */
    top: 12px;
    left: auto;
    /* ensure left is unset */
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 1px solid rgba(2, 6, 23, .08);
    background: #fff;
    color: #64748b;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(2, 6, 23, .06);
}

.logout-icon:hover {
    background: #f8fafc;
}

.logout-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}


/* --- Layout: center everything and make cards fill the container --- */
.container {
    max-width: 980px;
    width: 100%;
    margin-inline: auto;
    /* centers the whole app */
}

/* Let the cards use the container’s width */
.recorder-card,
.list-card {
    width: 100%;
    margin-inline: auto;
}

/* Media should never overflow on small screens */
video,
canvas {
    max-width: 100%;
    height: auto;
}

/* --- Mobile tweaks --- */
@media (max-width: 720px) {
    body {
        padding: 16px;
    }

    /* a bit less side padding */
    .actions {
        justify-content: center;
    }

    /* center the Record button row */
    .toggles {
        justify-content: center;
    }

    /* center the switches + mic select */
}



/* Mobile: compact idle preview (just a centered camera icon) */
@media (max-width: 720px) {
    .idle-overlay {
        inset: 12px;
    }

    /* a bit tighter */
    .idle-card {
        width: 88px;
        height: 88px;
        padding: 0;
        border-radius: 9999px;
        /* round badge */
        gap: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .idle-overlay h3,
    .idle-overlay p {
        display: none;
    }

    /* hide the text */
    .idle-card svg {
        width: 36px;
        height: 36px;
    }

    /* tidy icon size */
}

/* Mobile: hide options & show just a centered Record button */
@media (max-width: 720px) {
    #webcamOnlyWrap {
        display: none;
    }

    /* hide “Chỉ ghi webcam” */
    .toggles {
        display: none;
    }

    /* hide system audio + mic options */
    .actions {
        justify-content: center;
    }

    /* center the Record button */
}


/* Desktop vs Mobile title swap */
.title-mobile {
    display: none;
}

@media (max-width: 720px) {
    .title-desktop {
        display: none;
    }

    .title-mobile {
        display: inline;
    }
}


/* Title swap: Desktop vs Mobile, and when Webcam-only mode is ON */
.title-mobile {
    display: none;
}

@media (max-width: 720px) {
    .title-desktop {
        display: none;
    }

    .title-mobile {
        display: inline;
    }
}

/* On desktop, if webcam-only is ON, show "Video recorder" */
.recorder-card.webcam-mode .title-desktop {
    display: none;
}

.recorder-card.webcam-mode .title-mobile {

    
    display: inline;
}


/* Flip control (mobile) — very compact pill */
.flip-wrap{
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 12;
  display: none;                 /* shown only on mobile below */
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}


/* No-pill chip with crisp outline */
.flip-chip{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;                  /* tiny but gives the border room */
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,.95);   /* bright inner outline */
  background: transparent;                   /* still no fill */
  /* subtle dark halo so the white outline is visible on any bg */
  box-shadow: 0 0 0 1px rgba(2,6,23,.18);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  letter-spacing: .1px;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0,0,0,.18);
}
.flip-chip:active{ transform: none; }
.flip-chip:disabled{ opacity:.55; pointer-events:none; }




.flip-chip:active {
    transform: scale(.98);
}

.flip-chip:disabled {
    opacity: .5;
    pointer-events: none;
}

.flip-chip:active {
    transform: scale(.98);
}

.flip-chip:disabled {
    opacity: .5;
    pointer-events: none;
}

.flip-chip svg{
  width: 14px;
  height: 14px;
  display: block;
}
.flip-chip[data-facing="environment"] svg{ transform: rotateY(180deg); }



.flip-chip-text {
    white-space: nowrap;
    font-size: 11px;
    /* match chip font-size */
    line-height: 1;
    letter-spacing: .1px;
    /* a touch tighter than .2px */
}


/* Only on mobile */
@media (max-width: 720px) {
    .flip-wrap {
        display: block;
    }
}

/* Hide on desktop */
@media (min-width: 721px) {
    .flip-wrap {
        display: none !important;
    }
}



/* --- Recording timer (bottom-left of preview) --- */
.rec-timer{
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 9999px;
  color: #fff;
  font: 600 13px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: rgba(15,23,42,.72);
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 6px 18px rgba(2,6,23,.25), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(2px);
}

/* Top-left variant of the timer pill */
.rec-clock{
  top: 18px;
  left: 18px;
  bottom: auto; /* override .rec-timer bottom placement */
}

.rec-timer .dot{
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(239,68,68,.18);
  animation: recpulse 1.2s infinite;
}
@keyframes recpulse{
  0%,100%{ transform: scale(1); opacity: 1; }
  50%{ transform: scale(1.25); opacity: .75; }
}



/* Keep capture <video> elements rendering even in background tabs */
.stream-src{
  position: fixed;
  left: 0; top: 0;
  width: 1px; height: 1px;
  opacity: 0.0001;
  pointer-events: none;
  z-index: -1;
}



/* Upload button (left of toggles) */
.upload-btn{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:9999px;
  border:1px solid rgba(2,6,23,.08);
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,252,255,.90));
  color:#0f172a; font-weight:600; font-size:14px; cursor:pointer;
  box-shadow:0 6px 16px rgba(2,6,23,.08), inset 0 1px 0 rgba(255,255,255,.75);
  transition: box-shadow .18s ease, transform .06s ease, background .18s ease;
}
.upload-btn:hover{ box-shadow:0 8px 20px rgba(2,6,23,.12); transform: translateY(1px); }
.upload-btn:active{ transform: translateY(2px); }
.upload-btn svg{ width:16px; height:16px; display:block; }

.upload-btn svg,
.upload-btn span { pointer-events: none; }



/* Fix mic dropdown width so actions stay on one line */
:root { --mic-select-w: 280px; } /* tweak to taste: 260–320px */

.select-wrap{
  flex: 0 0 var(--mic-select-w);
  max-width: var(--mic-select-w);
}

#micSelect{
  width: 100%;
  min-width: 0;               /* override earlier min-width */
  overflow: hidden;
  text-overflow: ellipsis;    /* trim very long device names */
  white-space: nowrap;
}

/* (Optional) no change needed on mobile; toggles are hidden there */


.perm-modal{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.6);z-index:9999}
.perm-modal.hidden{display:none}
.perm-card{background:#fff;color:#111;max-width:420px;width:calc(100% - 2rem);padding:1.25rem;border-radius:16px;box-shadow:0 10px 30px rgba(0,0,0,.2);font-family:Inter,system-ui,sans-serif}
.perm-card h2{margin:0 0 .5rem;font-size:1.125rem}
.perm-actions{display:flex;gap:.5rem;margin-top:.75rem}
.perm-card button{padding:.65rem 1rem;border:none;border-radius:.75rem;font-weight:600;cursor:pointer}
.perm-card button.secondary{background:#e6e6e6}
.perm-card button:not(.secondary){background:#007bff;color:#fff}
.perm-msg{min-height:1.1em;margin-top:.5rem;font-size:.9rem;color:#d52731}
