:root {
  color-scheme: dark;
  font-size: 18px;
  --bg-root: #00110e;
  --bg-panel: #002d2a;
  --bg-panel-strong: #021c17;
  --bg-soft: rgba(8, 28, 24, 0.85);
  --overlay: rgba(0, 7, 6, 0.85);
  --text-strong: #EAF2F1;
  --text-muted: #B8C7C3;
  --icon-accent: #F0F7F6;
  --icon-settings: #EAF2F1;
  --accent-primary: #0E6251;
  --accent-secondary: #0FAF8F;
  --accent-soft: rgba(14, 98, 81, 0.25);
  --border-soft: rgba(255, 255, 255, 0.08);
  --danger: #D95C4A;
  --danger-strong: #B04536;
  --surface-elevated: rgba(255, 255, 255, 0.04);
  --control-radius: 1.5rem;
  --shadow-soft: 0 1.5rem 3rem rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at 20% -10%, rgba(15, 175, 143, 0.25), transparent 45%),
    var(--bg-root);
  color: var(--text-strong);
}

.app-shell {
  min-height: 100vh;
  width: 100%;
  background: linear-gradient(200deg, #002d2a 0%, #0d5546 50%, #0e6251 100%);
}

.main-area {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.screen-wrapper {
  flex: 1;
  width: 100%;
}

.screen-card {
  width: 100%;
  min-height: 100vh;
  padding: clamp(1.25rem, 4vw, 3.5rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 2.5rem);
  background: linear-gradient(180deg, rgba(0, 45, 42, 0.95) 0%, rgba(14, 98, 81, 0.75) 60%, rgba(14, 98, 81, 0.9) 100%);
  color: var(--text-strong);
  border: 1px solid var(--border-soft);
}

@media (min-width: 960px) {
  .screen-card {
    max-width: 960px;
    margin: 0 auto;
    border-radius: 2.5rem;
    box-shadow: var(--shadow-soft);
  }
}

.screen-zone {
  width: 100%;
}

.screen-zone--header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.screen-zone--action {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.screen-zone--hint {
  margin-top: auto;
}

.screen-home {
  gap: clamp(1.5rem, 5vw, 3rem);
}

.home-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-direction: row;
  gap: 0;
}

.home-brand {
  margin: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.home-settings {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--icon-settings);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.home-settings:focus-visible,
.home-settings:hover {
  border-color: var(--accent-primary);
  background: rgba(15, 175, 143, 0.25);
}

.home-settings-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.home-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-action-button {
  width: min(480px, 100%);
  background: linear-gradient(145deg, #0E6251 0%, #0FAF8F 50%, #0E6251 100%);
  color: var(--text-strong);
  box-shadow: 0 1.75rem 3rem rgba(2, 22, 18, 0.7);
}

.home-action-button.ui-large:hover,
.home-action-button.ui-large:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 2rem 3.5rem rgba(0, 0, 0, 0.65);
}

.home-action-symbol {
  background: rgba(255, 255, 255, 0.08);
  color: var(--icon-accent);
}

.home-action-symbol svg {
  width: 1.9rem;
  height: 1.9rem;
  stroke-width: 2.2;
}

.home-action-text {
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.home-hint-zone {
  display: flex;
  justify-content: center;
}

.home-hint {
  text-align: center;
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 320px;
}

.screen-settings {
  gap: clamp(1.35rem, 4vw, 2.75rem);
}

.settings-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  min-height: 3rem;
}

.settings-header h1 {
  margin: 0 auto;
  font-size: clamp(2.1rem, 5vw, 2.9rem);
  font-weight: 700;
  text-align: center;
}

.settings-close,
.invite-close {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--icon-settings);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  position: absolute;
  top: 0.15rem;
  right: 0;
}

.settings-close:focus-visible,
.settings-close:hover,
.invite-close:focus-visible,
.invite-close:hover {
  border-color: var(--accent-primary);
  background: rgba(15, 175, 143, 0.25);
}

.invite-close {
  top: 0;
}

.settings-close-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
}

.settings-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3vw, 1.75rem);
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 0 0.5rem 1.5rem;
}

.settings-reinstall-button,
.settings-remote-logging-button {
  width: min(520px, 100%);
  text-align: center;
  letter-spacing: 0.05em;
}

.settings-reinstall-symbol,
.settings-remote-logging-symbol {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 1.5rem;
}

.settings-reinstall-symbol svg,
.settings-remote-logging-symbol svg,
.settings-reinstall-symbol img,
.settings-remote-logging-symbol img {
  width: 2.4rem;
  height: 2.4rem;
}

.settings-remote-logging-button {
  border: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.settings-remote-logging-state {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.15);
  transition: background-color 0.2s ease;
}

.settings-remote-logging-state[data-state='enabled'] {
  color: var(--accent-secondary);
  background-color: rgba(56, 201, 119, 0.2);
}

.screen-kicker {
  letter-spacing: 0.4em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.screen-zone h1,
.screen-zone h2 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 3rem);
  font-weight: 700;
}

.screen-subtext {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1.5;
}

.screen-subtext--strong {
  color: var(--accent-primary);
}

.screen-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.screen-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-strong);
}

.home-actions-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.home-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.home-label {
  width: 100%;
}

.label-title {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.ui-large {
  width: 100%;
  min-height: auto;
  border-radius: var(--control-radius);
  border: none;
  padding: 1rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ui-large span {
  align-self: center;
}

input.ui-large {
  background: var(--bg-panel-strong);
  color: var(--text-strong);
  border: 2px solid var(--border-soft);
  font-family: inherit;
  font-size: 1.3rem;
  padding: 1.1rem 1.25rem;
}

input.ui-large:focus {
  border-color: var(--accent-primary);
  outline: 2px solid rgba(15, 175, 143, 0.4);
  outline-offset: 2px;
}

button.ui-large {
  cursor: pointer;
}

.primary {
  background: linear-gradient(145deg, #0FAF8F 0%, #0E6251 100%);
  color: var(--text-strong);
  box-shadow: 0 1.25rem 2.5rem rgba(4, 23, 18, 0.65);
}

.ghost {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border-soft);
  color: var(--text-strong);
}

.danger {
  background: linear-gradient(145deg, #B04536 0%, #D95C4A 100%);
  color: #fff;
  box-shadow: 0 1.25rem 2.5rem rgba(217, 92, 74, 0.35);
}

.ui-large:focus-visible,
.ui-large:hover {
  transform: translateY(-2px);
}

.ui-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-align: left;
}

.ui-glyph {
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--icon-accent);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 0.35rem 0.85rem rgba(0, 0, 0, 0.4);
}

.ui-glyph--ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-strong);
}

.ui-glyph--outline {
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-strong);
}

.ui-glyph svg {
  width: 2rem;
  height: 2rem;
  stroke: currentColor;
  fill: none;
}

.saved-name-banner {
  background: var(--bg-panel-strong);
  border-radius: 1.75rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.saved-name-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.saved-name-text {
  margin: 0;
  font-size: 1.2rem;
}

.saved-name-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 600px) {
  .saved-name-actions {
    flex-direction: row;
  }
}

.home-call {
  width: 100%;
}

.screen-invite {
  gap: clamp(1.5rem, 3vw, 2.25rem);
}

.invite-header {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 3.5rem;
}

.invite-link-zone {
  display: flex;
  justify-content: center;
}

.invite-link-card {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
  border-radius: 2rem;
  border: 1px solid var(--border-soft);
  background: var(--bg-panel-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
}

.invite-link-text {
  margin: 0;
  width: 100%;
  text-align: center;
  word-break: break-all;
  font-size: clamp(1.25rem, 3vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-strong);
}

.invite-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: stretch;
}

.invite-actions > .invite-action-button {
  max-width: 520px;
  margin: 0 auto;
}

.invite-action-button {
  justify-content: center;
}

.invite-action-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.invite-action-icon svg {
  width: 1.8rem;
  height: 1.8rem;
  stroke: currentColor;
  fill: none;
}

.invite-action-text {
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.invite-action-secondary.invite-action-button {
  background: linear-gradient(145deg, rgba(15, 175, 143, 0.15) 0%, rgba(14, 98, 81, 0.65) 100%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--text-strong);
}

.invite-action-secondary .invite-action-icon {
  border-color: rgba(255, 255, 255, 0.2);
}

.screen-call {
  padding: 0;
  gap: 0;
  min-height: 100vh;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

@media (min-width: 960px) {
  .screen-call {
    max-width: 100%;
    margin: 0;
  }
}

body.state-call {
  min-height: 100vh;
  overflow: hidden;
}

.screen-call .call-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #010d0a 0%, #021c17 60%, rgba(1, 29, 22, 0.95) 100%);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

.call-stage video#remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 1;
  pointer-events: none;
}

.call-local {
  position: absolute;
  bottom: max(
    env(safe-area-inset-bottom, 1.25rem) + calc(var(--call-close-height, 3.5rem) * 2),
    clamp(3rem, 5vw, 4.5rem)
  );
  right: clamp(1.25rem, 3vw, 1.75rem);
  width: clamp(130px, 20vw, 180px);
  height: clamp(160px, 28vw, 220px);
  border-radius: 1.5rem;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.call-local video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.call-settings {
  position: absolute;
  top: clamp(1rem, 3vw, 1.5rem);
  right: clamp(1rem, 3vw, 1.5rem);
  z-index: 3;
  pointer-events: auto;
}

.call-close {
  position: absolute;
  left: 50%;
  bottom: max(
    env(safe-area-inset-bottom, 1.75rem),
    clamp(2rem, 4vw, 3rem)
  );
  --call-close-height: clamp(3rem, 7vw, 4rem);
  min-height: var(--call-close-height);
  transform: translateX(-50%);
  width: min(320px, 85%);
  border-radius: 999px;
  justify-content: center;
  z-index: 3;
  transition: none;
}

.call-close:focus-visible,
.call-close:hover {
  transform: translateX(-50%);
}

.call-close .ui-glyph {
  width: 1.8rem;
  height: 1.8rem;
}

.screen-end .screen-zone--action {
  align-items: center;
}

#toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}

.toast {
  min-width: 220px;
  max-width: 340px;
  padding: 0.9rem 1.2rem;
  border-radius: 1rem;
  color: var(--text-strong);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1rem 1.75rem rgba(0, 0, 0, 0.6);
}

.toast-info {
  background: #6ECFC0;
  color: #04120e;
  box-shadow: 0 0.75rem 1.5rem rgba(110, 207, 192, 0.35);
}

.toast-success {
  background: linear-gradient(140deg, #0FAF8F 0%, #0E6251 100%);
  color: var(--text-strong);
}

.toast-warn {
  background: #E9A944;
  color: #201205;
  box-shadow: 0 0.75rem 1.5rem rgba(233, 169, 68, 0.35);
}

.toast-error {
  background: #D95C4A;
  color: #fff;
  box-shadow: 0 0.75rem 1.5rem rgba(217, 92, 74, 0.45);
}

@media (max-width: 520px) {
  .ui-large {
    flex-direction: row;
    align-items: stretch;
  }
  .ui-glyph {
    width: 2.75rem;
    height: 2.75rem;
  }
  .local-miniature {
    width: 120px;
    height: 150px;
  }
}
