/* Зачем: оформление PWA TRANSLATE.
   Для кого: index.html.
   Что и когда писать: токены цвета/ритма при смене UI.
   Объём и вид: одна композиция, без карточного дашборда. */

:root {
  --bg0: #121820;
  --bg1: #1a2332;
  --ink: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3d9b8f;
  --accent-press: #2f7f75;
  --danger: #c45c5c;
  --line: rgba(232, 238, 246, 0.12);
  --font: "Segoe UI", "PT Root UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #243247 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1e3a36 0%, transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1));
}

.shell {
  max-width: 28rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
}

.account-strip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.12rem;
  max-width: min(16rem, 52vw);
  font-size: 0.85rem;
  line-height: 1.25;
  color: var(--muted);
  text-align: right;
}

.brand-account {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  max-width: min(18rem, 58vw);
}

.account-strip .strip-quota {
  color: var(--accent);
  font-weight: 600;
}

.account-strip .strip-quota.is-empty {
  color: #c97b6b;
}

.account-strip .strip-billing {
  color: var(--ink);
  opacity: 0.9;
}

button.brand-logout {
  flex-shrink: 0;
  width: auto;
  margin: 0;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

button.brand-logout.hidden {
  display: none;
}

button.brand-logout .logout-icon {
  display: none;
}

button.brand-logout:hover {
  color: var(--ink);
  border-color: rgba(232, 238, 246, 0.28);
}

@media (max-width: 480px) {
  .brand-account {
    order: 3;
    flex-basis: 100%;
    max-width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .account-strip {
    max-width: none;
    align-items: flex-start;
    text-align: left;
  }

  button.brand-logout {
    padding: 0.45rem;
    min-width: 2.4rem;
    min-height: 2.4rem;
    justify-content: center;
  }

  button.brand-logout .logout-label {
    display: none;
  }

  button.brand-logout .logout-icon {
    display: block;
  }
}

.brand h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 2.6rem);
  letter-spacing: 0.04em;
  font-weight: 700;
}

.brand .ver {
  font-size: 0.45em;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  vertical-align: middle;
}

button.brand-leave {
  flex-shrink: 0;
  width: auto;
  margin: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--ink);
}

button.leave-session {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
}

button.leave-session:hover {
  color: var(--ink);
  border-color: rgba(232, 238, 246, 0.28);
}

.invite-email {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.invite-email label {
  display: block;
}

.invite-email #btnSendInvite {
  width: 100%;
}

.live-status {
  min-height: 1.35rem;
  margin: 0.75rem 0 0.5rem;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

.live-status.is-peer {
  color: #c9a66b;
}

.live-status.is-idle {
  color: var(--muted);
  font-weight: 500;
}

.panel-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.auth-box {
  margin: 1.15rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.auth-box .ghost {
  margin-top: 0.5rem;
}

.auth-box .checkline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
}

.auth-box .checkline input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  flex: 0 0 auto;
}

.panel input,
.panel select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #0e141c;
  color: #f7fafc;
  font-size: 1rem;
}

.panel select option,
.session-lang select option {
  background-color: #f7fafc;
  color: #121820;
}

.row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.setup-join {
  margin-top: 0;
}

.join input { flex: 1; margin-top: 0; }

button {
  border: 0;
  border-radius: 0.55rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

button.primary { background: var(--accent); color: #041210; font-weight: 600; }
button.primary:active { background: var(--accent-press); }
button.ghost { background: transparent; border: 1px solid var(--line); width: 100%; margin-top: 1rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.talk {
  width: 100%;
  min-height: 5.5rem;
  margin: 1.25rem 0;
  background: var(--accent);
  color: #041210;
  font-weight: 700;
  font-size: 1.05rem;
  touch-action: none;
  user-select: none;
}

.talk.recording {
  background: var(--danger);
  color: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}

.session-lang {
  display: block;
  margin: 0.5rem 0 0.75rem;
  color: #d5deea;
  font-size: 0.85rem;
}
.session-lang select {
  margin-top: 0.35rem;
}

@keyframes pulse {
  50% { filter: brightness(1.1); }
}

.meta { color: var(--muted); margin: 0.25rem 0; }
.hint {
  margin: -0.35rem 0 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}
#createNeedLogin {
  margin: 0.45rem 0 0;
}
.setup-hint {
  margin: 0.65rem 0 1rem;
}
.peer-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.peer-lang {
  color: var(--muted, #9aa7b8);
  white-space: nowrap;
}
.peer-lang::before {
  content: "·";
  margin-right: 0.45rem;
  color: #5a6575;
}
.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #5a6575;
  flex-shrink: 0;
}
.dot.online {
  background: #3d9b8f;
  box-shadow: 0 0 0 3px rgba(61, 155, 143, 0.25);
}
.notice {
  margin: 0.5rem 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(61, 155, 143, 0.35);
  border-radius: 0.45rem;
  background: rgba(61, 155, 143, 0.12);
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.35;
}
.invite {
  display: block;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.invite .row { margin-top: 0.35rem; }
.invite input { font-size: 0.8rem; }

.video-stage {
  position: relative;
  margin-top: 0.85rem;
  aspect-ratio: 4 / 3;
  max-height: 42vh;
  border-radius: 0.65rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
}

.video-remote {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0e14;
  display: block;
}

.video-remote:not(.has-track) {
  opacity: 0;
  position: absolute;
  inset: 0;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.video-stage.has-remote .video-placeholder {
  display: none;
}

.video-local {
  position: absolute;
  right: 0.55rem;
  bottom: 0.55rem;
  width: 28%;
  max-width: 7.5rem;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 0.45rem;
  border: 1px solid var(--line);
  background: #0a0e14;
  transform: scaleX(-1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

button.camera {
  width: auto;
  margin: 0 0 0 auto;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
}

button.camera.on {
  background: rgba(61, 155, 143, 0.22);
  border-color: rgba(61, 155, 143, 0.45);
}

.log {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.55rem;
  min-height: 4rem;
  max-height: 16rem;
  overflow: auto;
  margin-top: 0.75rem;
  padding: 0.65rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 0.88rem;
}

.log:empty {
  display: none;
}

body.in-session .log:not(:empty) {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.talk {
  margin: 0.85rem 0 0;
}

#session:not(.hidden) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.talk-dock {
  flex: none;
  margin-top: auto;
  z-index: 2;
  padding-top: 0.45rem;
  background: linear-gradient(to top, #121820 78%, rgba(18, 24, 32, 0));
}

.talk-dock .talk {
  margin: 0;
}

.talk-dock .leave-session {
  margin-top: 0.45rem;
}
.log-row {
  display: flex;
  width: 100%;
  line-height: 1.35;
}
.log-row.mine {
  justify-content: flex-end;
}
.log-row.peer {
  justify-content: flex-start;
}
.log-row.system {
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
.bubble {
  max-width: 88%;
  padding: 0.55rem 0.7rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
}
.log-row.mine .bubble {
  background: rgba(61, 155, 143, 0.22);
  border-color: rgba(61, 155, 143, 0.4);
  border-bottom-right-radius: 0.25rem;
}
.log-row.peer .bubble {
  background: rgba(255, 255, 255, 0.07);
  border-bottom-left-radius: 0.25rem;
}
.bubble-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.78rem;
}
.bubble-source {
  color: var(--ink);
}
.bubble-translated {
  margin-top: 0.2rem;
  color: #c9d6e6;
}
.log-time { color: var(--muted); font-size: 0.72rem; font-weight: 500; }
.log-arrow { color: var(--accent); }

.status {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.status.is-error {
  color: #e8a090;
  font-weight: 600;
}

.hidden { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 12, 18, 0.72);
}

.modal.hidden { display: none; }

.modal-card {
  width: min(100%, 22rem);
  padding: 1.15rem 1.1rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: #15202c;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.modal-text {
  margin: 0 0 1rem;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.modal-actions button { width: 100%; }

.billing-banner {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(201, 166, 107, 0.35);
  background: rgba(201, 166, 107, 0.12);
  color: #e6d3a8;
  font-size: 0.82rem;
}

.owner-banner {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(201, 123, 107, 0.4);
  background: rgba(201, 123, 107, 0.14);
  color: #e8a090;
  font-size: 0.82rem;
}

.fb-fab {
  position: fixed;
  z-index: 35;
  display: flex;
  align-items: center;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  right: max(0px, env(safe-area-inset-right, 0px));
}
body.in-session {
  overflow: hidden;
}

body.in-session .shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
}

body.in-session #session {
  flex: 1;
  min-height: 0;
}

body.in-session .fb-fab {
  right: auto;
  left: max(0px, env(safe-area-inset-left, 0px));
  bottom: calc(12rem + env(safe-area-inset-bottom, 0px));
}
.fb-fab .fb-tab,
.fb-fab .fb-main {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.fb-tab {
  width: 1.7rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 999px 0 0 999px;
  border: 1px solid var(--line);
  background: #15202c;
  color: var(--accent);
  font-size: 1.1rem;
}
body.in-session .fb-tab {
  border-radius: 0 999px 999px 0;
}
.fb-main {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #041210;
  font-size: 1.15rem;
}
.fb-fab.is-collapsed .fb-main { display: none; }
body.fb-capturing .fb-fab,
body.fb-capturing .fb-sheet,
body.fb-capturing .fb-backdrop { visibility: hidden; }

.fb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(8, 12, 18, 0.45);
}
.fb-backdrop.hidden { display: none; }
.fb-sheet {
  position: fixed;
  z-index: 46;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(85vh, 36rem);
  overflow: auto;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  background: #15202c;
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
}
.fb-sheet.hidden { display: none; }
.fb-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.fb-sheet-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.fb-sheet button.ghost {
  width: auto;
  margin-top: 0;
  padding: 0.4rem 0.7rem;
}
.fb-sheet textarea {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #0e141c;
  color: var(--ink);
  font: inherit;
  padding: 0.65rem 0.75rem;
  resize: vertical;
}
.fb-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.fb-tools button { padding: 0.5rem 0.7rem; font-size: 0.9rem; }
.fb-previews {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.fb-previews figure {
  margin: 0;
  width: 5.5rem;
}
.fb-previews img {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  border-radius: 0.4rem;
  background: #0e141c;
}
.fb-previews button {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.3rem;
  font-size: 0.75rem;
}
.fb-sheet #fbSend { width: 100%; margin-top: 0.35rem; }
