/* Meeting Room — shared styles. Colours come from theme.js as CSS variables. */

:root {
  --accent: #4c8dff;
  --accent-2: #ffb547;
  --accent-ink: #111723;
  --accent-2-ink: #111723;
  --accent-text: #6d9fff;
  --accent-2-text: #ffb547;
  --accent-soft: rgba(76, 141, 255, 0.18);
  --accent-2-soft: rgba(255, 181, 71, 0.18);
  --bg: #11151f;
  --bg-2: #171c29;
  --card: #1d2333;
  --card-2: #252b3b;
  --line: #3a4050;
  --text: #eef2fa;
  --muted: #8f96a6;
  --danger: #f87171;
  --ok: #4ade80;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(900px 500px at 0% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, var(--accent-2-soft), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

h1, h2 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 19px; }
a { color: var(--accent-text); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
kbd {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--card-2);
  color: var(--text);
  font: 600 12px/1.6 inherit;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); margin: 10px 0 0; font-size: 14px; }

/* ------------------------------------------------------------- controls */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 600; }

input[type="text"], input[type="password"], input[type="number"], input:not([type]) {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--danger); }
input::placeholder { color: var(--muted); opacity: 0.7; }

.code-input::placeholder { letter-spacing: 0.1em; text-transform: none; }
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  color: var(--text);
  background: var(--card-2);
  transition: filter 0.15s, background 0.15s, border-color 0.15s, transform 0.05s;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--card-2); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--card-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }

.link-btn {
  background: none;
  border: 0;
  padding: 4px 6px;
  color: var(--accent-text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.row-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  background: var(--card-2);
}

.code-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 800;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
}

.p-conn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.p-conn i { width: 8px; height: 8px; border-radius: 50%; background: #e0a100; }
.p-conn[data-state="live"] i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.p-conn[data-state="ended"] i { background: var(--danger); }
.p-conn[data-state="connecting"] i { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 8, 15, 0.6);
  backdrop-filter: blur(4px);
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.notice-card { width: 100%; max-width: 420px; }
.notice-card p { margin: 0 0 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 60;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: #fff; }

/* -------------------------------------------------------- join / login */

.join-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top)) 16px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.join-wrap > p { margin: 0 0 20px; }
.join-logo { font-size: 46px; margin-bottom: 8px; display: flex; justify-content: center; gap: 6px; }
.join-card { text-align: left; }
.hint-warn { color: var(--text) !important; font-weight: 600; }

/* --------------------------------------------------- participant room */

.participant #room-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.p-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
}
.p-bar-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.p-room-name { font-weight: 750; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.p-me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-me .avatar { width: 26px; height: 26px; font-size: 11px; }
.p-bar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.p-bar-right .link-btn { padding: 2px 0; }

.big-buttons {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

@media (min-width: 768px) {
  .big-buttons { flex-direction: row; gap: 24px; padding: 8px 24px 24px; }
}

.big-btn {
  flex: 1;
  min-height: 170px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow);
  transition: background 0.22s, color 0.22s, border-color 0.22s, box-shadow 0.3s, transform 0.08s;
}
.big-btn:active { transform: scale(0.985); }
@media (hover: hover) {
  #btn-hand:not(.on):hover { border-color: var(--accent); }
  #btn-comment:not(.on):hover { border-color: var(--accent-2); }
}
.big-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.big-icon { font-size: clamp(52px, 13vmin, 104px); line-height: 1; transition: transform 0.3s; }
.big-label { font-size: clamp(24px, 5.4vmin, 38px); font-weight: 800; letter-spacing: -0.01em; }
.big-state {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}
.big-hint { font-size: 13px; color: var(--muted); }

#btn-hand.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  animation: ring-1 2.4s ease-in-out infinite;
}
#btn-comment.on {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: var(--accent-2-ink);
  animation: ring-2 2.4s ease-in-out infinite;
}
.big-btn.on .big-state {
  background: rgba(255, 255, 255, 0.22);
  background: color-mix(in srgb, currentColor 14%, transparent);
  color: inherit;
}
.big-btn.on .big-hint { color: inherit; opacity: 0.78; }
#btn-hand.on .big-icon { transform: rotate(-10deg) scale(1.06); animation: wave 0.7s ease 1; }
#btn-comment.on .big-icon { transform: scale(1.06); animation: pop 0.45s ease 1; }

@keyframes ring-1 {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft), var(--shadow); }
  50% { box-shadow: 0 0 0 10px var(--accent-soft), var(--shadow); }
}
@keyframes ring-2 {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-2-soft), var(--shadow); }
  50% { box-shadow: 0 0 0 10px var(--accent-2-soft), var(--shadow); }
}
@keyframes wave {
  0% { transform: rotate(0); }
  30% { transform: rotate(-18deg) scale(1.1); }
  60% { transform: rotate(8deg) scale(1.08); }
  100% { transform: rotate(-10deg) scale(1.06); }
}
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1.06); }
}

/* Short phone in landscape: keep both buttons on screen. */
@media (max-height: 480px) and (orientation: landscape) {
  .big-buttons { flex-direction: row; }
  .big-btn { min-height: 0; gap: 4px; padding: 10px; }
  .big-icon { font-size: 40px; }
  .big-label { font-size: 22px; }
}

/* ---------------------------------------------------------------- admin */

.admin-wrap { max-width: 1280px; margin: 0 auto; padding: 16px 20px 40px; }

.admin-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.brand { font-weight: 800; font-size: 18px; }
.admin-head-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.create-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.create-grid .field { margin: 0; }
.create-grid .btn { height: 48px; }
@media (max-width: 760px) { .create-grid { grid-template-columns: 1fr 1fr; } .create-grid .field:first-child, .create-grid .btn { grid-column: 1 / -1; } }

.rooms-list {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.room-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.room-card:hover { border-color: var(--accent); }
.room-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.room-card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; font-size: 18px; }
.room-card-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card-queues { margin-top: 6px; font-size: 14px; white-space: pre; }
.empty-note { text-align: center; padding: 24px 0; margin: 0; }

/* room view */

.room-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}
.room-title h1 { margin: 0 0 4px; font-size: 26px; overflow-wrap: anywhere; }
.room-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; }

.invite {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.qr-thumb {
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #fff;
  cursor: zoom-in;
  flex-shrink: 0;
}
.qr-thumb svg, .qr-big-code svg { display: block; width: 100%; height: 100%; }
.invite-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.invite-text a { font-weight: 700; word-break: break-all; }
.invite-text .row-buttons { margin-top: 4px; gap: 6px; }

@media (max-width: 900px) {
  .room-head { grid-template-columns: 1fr; }
  .room-head #back-btn { justify-self: start; }
}

.room-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.sound-btn[aria-pressed="false"] { color: var(--muted); }

.queues { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .queues { grid-template-columns: 1fr; } }

.queue {
  min-height: 52vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.queue-comment { border-top-color: var(--accent-2); }
.queue-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.queue-head h2 { margin: 0; font-size: 21px; }
.queue-count {
  min-width: 34px;
  padding: 3px 10px;
  border-radius: 999px;
  text-align: center;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.queue-comment .queue-count { background: var(--accent-2-soft); color: var(--accent-2-text); }
.queue-list { display: flex; flex-direction: column; }
.queue-empty { margin: auto 0; padding: 30px 0; text-align: center; color: var(--muted); }

.q-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0 0 8px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.q-item:hover { border-color: var(--danger); }
.q-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.q-pos { width: 22px; text-align: center; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.q-who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.q-name { font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-wait { font-size: 12px; color: var(--muted); }
.q-x { color: var(--danger); font-weight: 800; opacity: 0; transition: opacity 0.15s; }
.q-item:hover .q-x { opacity: 1; }
.q-item.offline .avatar { opacity: 0.45; }
.q-item.offline .q-name { color: var(--muted); }

/* the next one up in each list */
.queue-hand .q-item.next { border-color: var(--accent); background: var(--accent-soft); }
.queue-comment .q-item.next { border-color: var(--accent-2); background: var(--accent-2-soft); }
.q-item.next:hover { border-color: var(--danger); }

.q-item.enter { animation: q-in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.q-item.leave { animation: q-out 0.26s ease-in forwards; pointer-events: none; }
.q-item.collapse {
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  transition: height 0.24s ease, margin 0.24s ease, padding 0.24s ease, border-width 0.24s ease;
}
@keyframes q-in {
  from { transform: translateX(-70px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes q-out {
  to { transform: translateX(90px); opacity: 0; }
}

.queue-help { margin: 16px 2px 0; font-size: 14px; }
.sound-hint {
  margin: 10px 2px 0;
  font-size: 14px;
  color: var(--accent-2-text);
}

/* participants */

.people-layout { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .people-layout { grid-template-columns: 1fr; } }
.people-card { padding: 8px; }
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
}
.person + .person { border-top: 1px solid var(--line); border-radius: 0; }
.person-who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.person-who strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-status { color: var(--ok); }
.person.offline .person-status { color: var(--muted); }
.person.offline .avatar { opacity: 0.45; }
.person-flags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.flag {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.flag-hand { background: var(--accent-soft); color: var(--accent-text); }
.flag-comment { background: var(--accent-2-soft); color: var(--accent-2-text); }
.flag:hover { border-color: currentColor; }
.room-settings h2 { margin-bottom: 14px; }

/* settings */

.settings-card { max-width: 720px; margin-bottom: 18px; }
.settings-card > p { margin-top: 0; }
.palette { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin: 16px 0; }
@media (max-width: 560px) { .palette-grid { grid-template-columns: 1fr; } }
.palette-item { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.palette-item span { display: flex; flex-direction: column; }
.palette-item small { font-weight: 400; color: var(--muted); font-size: 12px; }
.palette-item input[type="color"] {
  width: 46px;
  height: 46px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  cursor: pointer;
  flex-shrink: 0;
}
.palette-preview {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px dashed var(--line);
}
.preview-btn { padding: 12px 18px; border-radius: 14px; font-weight: 750; }
.preview-hand { background: var(--accent); color: var(--accent-ink); }
.preview-comment { background: var(--accent-2); color: var(--accent-2-ink); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); }

/* big QR */

.qr-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(92vw, 560px);
  text-align: center;
}
.qr-big-code {
  width: min(78vw, 70vh, 460px);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 16px;
  background: #fff;
}
.qr-big-text { display: flex; flex-direction: column; gap: 2px; }
.qr-big-text strong { font-size: 40px; letter-spacing: 0.25em; padding-left: 0.25em; }
.qr-big-text span:last-child { font-weight: 600; word-break: break-all; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .q-item.collapse { transition-duration: 0.01ms; }
}
