*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--plait-bg);
  color: var(--plait-text);
  -webkit-font-smoothing: antialiased;
}

.wizard {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

.wizard-card {
  width: 100%;
  max-width: 420px;
  background: var(--plait-card);
  border: 1px solid var(--plait-border);
  border-radius: var(--plait-card-radius);
  padding: 1.5rem 1.5rem 1.75rem;
  box-shadow: var(--plait-card-shadow);
}

.wizard-logo {
  display: block;
  width: auto;
  max-width: 169px;
  height: 4.5rem;
  margin: 0 auto 1rem;
  object-fit: contain;
}

.lang-bar {
  display: flex;
  width: 100%;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  padding: 0.2rem;
  background: var(--plait-surface);
  border: 1px solid var(--plait-border);
  border-radius: 10px;
}

.lang-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--plait-text-muted);
  cursor: pointer;
  text-align: center;
}

.lang-btn.active {
  background: var(--plait-surface-elevated);
  color: var(--plait-accent-hover);
}

.lang-btn:active {
  background: var(--plait-surface-elevated);
}

.ios-guide-detailed,
.android-guide-detailed {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--plait-surface);
  border: 1px solid var(--plait-border);
  border-radius: 12px;
  text-align: left;
}

.ios-guide-title,
.android-guide-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--plait-accent-hover);
  margin-bottom: 0.75rem;
}

.ios-guide-detailed .wizard-steps-list,
.android-guide-detailed .wizard-steps-list {
  font-size: 0.88rem;
  line-height: 1.5;
}

.wizard-step {
  width: 100%;
}

.wizard-step[hidden] {
  display: none !important;
}

.step-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--plait-accent-hover);
  background: var(--plait-surface);
  border: 1px solid var(--plait-border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  margin-bottom: 1.25rem;
}

.wizard-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 1.25rem;
  font-size: 2rem;
  line-height: 1;
  background: var(--plait-surface);
  border: 1px solid var(--plait-border);
  border-radius: 50%;
}

.wizard-emoji.pulse {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

.wizard-step h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  min-height: calc(1.5rem * 1.2 * 2);
  text-align: center;
  color: var(--plait-text);
}

.wizard-sub {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--plait-text-muted);
  text-align: center;
}

.install-guide {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--plait-surface);
  border: 1px solid var(--plait-border);
  border-radius: 12px;
}

.install-wait {
  font-size: 0.9rem;
  color: var(--plait-text-muted);
  padding: 0.5rem 0;
}

.wizard-lead {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--plait-text-muted);
  margin-bottom: 1.5rem;
  min-height: calc(1em * 1.55 * 2);
  text-align: center;
}

.wizard-lead strong {
  color: var(--plait-text);
  font-weight: 600;
}

.wizard-steps-list {
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--plait-text-muted);
  margin: 0;
  padding-left: 1.2rem;
}

.wizard-steps-list li {
  margin-bottom: 0.6rem;
}

.wizard-steps-list li:last-child {
  margin-bottom: 0;
}

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

#name {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  border: 1px solid var(--plait-input-border);
  border-radius: 0.9rem;
  background: var(--plait-input-bg);
  color: var(--plait-text);
  margin-bottom: 1rem;
  text-align: center;
  min-height: var(--plait-auth-control-height);
}

#name:focus {
  outline: none;
  border-color: var(--plait-input-focus);
  box-shadow: 0 0 0 2px var(--plait-input-focus-ring);
}

#name::placeholder {
  color: #7c858e;
}

.btn-primary {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.9rem;
  background: linear-gradient(to right, var(--plait-btn-from), var(--plait-btn-to));
  color: #fff;
  cursor: pointer;
  min-height: var(--plait-auth-control-height);
  box-shadow: 0 8px 24px var(--plait-btn-shadow);
  transition: filter 0.15s, box-shadow 0.15s, transform 0.15s;
}

.btn-primary:active {
  transform: scale(0.98);
  filter: brightness(0.95);
  box-shadow: 0 4px 16px var(--plait-btn-shadow);
}

.btn-secondary {
  width: 100%;
  padding: 0.9rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid var(--plait-border);
  border-radius: 0.9rem;
  background: var(--plait-surface-elevated);
  color: var(--plait-text);
  cursor: pointer;
  min-height: var(--plait-auth-control-height);
  transition: background 0.15s, color 0.15s;
}

.btn-secondary:active {
  background: #1a1a1a;
  color: var(--plait-text);
}

.btn-large {
  font-size: 1.05rem;
  padding: 1.05rem 1.25rem;
}

.btn-link {
  margin-top: 1rem;
  background: none;
  border: none;
  color: var(--plait-text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}

.btn-link:active {
  color: var(--plait-accent-hover);
}

.btn-link-block {
  display: block;
  text-align: center;
  text-decoration: none;
  line-height: 1.3;
}

.wizard[hidden] {
  display: none !important;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app[hidden] {
  display: none !important;
}

.map-header {
  --header-control-h: 2.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--plait-surface);
  border-bottom: 1px solid var(--plait-border);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.user-select-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.user-select {
  width: 100%;
  flex: none;
  min-width: 0;
  height: var(--header-control-h);
  box-sizing: border-box;
  padding: 0 0.75rem;
  font-size: 0.9rem;
  line-height: calc(var(--header-control-h) - 2px);
  font-family: inherit;
  border: 1px solid var(--plait-border);
  border-radius: 0.75rem;
  background: var(--plait-input-bg, var(--plait-surface-elevated));
  color: transparent;
  cursor: pointer;
}

.user-select-face {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  font-size: 0.9rem;
  color: var(--plait-text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-select-offline-tag {
  margin-left: 0.35rem;
  color: var(--plait-danger);
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.btn-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--header-control-h);
  height: var(--header-control-h);
  box-sizing: border-box;
  padding: 0;
  font-family: inherit;
  border: 1px solid var(--plait-border);
  border-radius: 0.75rem;
  background: var(--plait-surface-elevated);
  color: var(--plait-text);
  cursor: pointer;
}

.btn-icon.active {
  background: var(--plait-accent-hover);
  color: var(--plait-bg, #060606);
  border-color: var(--plait-accent-hover);
}

.btn-icon svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.btn-icon:active {
  filter: brightness(0.9);
}

.btn-icon:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.app-tabs {
  display: flex;
  width: 100%;
  flex-shrink: 0;
  border-bottom: 1px solid var(--plait-border);
  background: var(--plait-surface);
}

.app-tabs[hidden] {
  display: none !important;
}

.app-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.75rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--plait-text-muted);
  cursor: pointer;
  text-align: center;
}

.app-tab.active {
  color: var(--plait-accent-hover);
  border-bottom-color: var(--plait-accent-hover);
}

.app-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.app-panel {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.app-panel.active {
  display: block;
}

.user-info {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.25rem 1rem;
  margin: 0;
}

.user-info dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--plait-text-muted);
  margin-top: 1rem;
}

.user-info dt:first-child {
  margin-top: 0;
}

.user-info dd {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--plait-text);
  word-break: break-word;
}

.user-info dd.mono {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  font-size: 0.9rem;
  font-weight: 400;
}

.user-info-note {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--plait-text-muted);
  margin-top: 0.25rem;
}

.user-info-empty {
  padding: 1.25rem 1rem;
  color: var(--plait-text-muted);
  font-size: 0.95rem;
}

.settings-panel {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.25rem 1rem 1.5rem;
}

.settings-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.settings-name-block {
  margin-bottom: 1.25rem;
}

.settings-name-block .settings-label {
  margin-top: 0;
}

.settings-name-block .btn-primary {
  margin-bottom: 0;
}

.settings-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--plait-text-muted);
  margin: 1rem 0 0.5rem;
}

.settings-label:first-of-type {
  margin-top: 0;
}

.settings-hint {
  font-size: 0.85rem;
  color: var(--plait-text-muted);
  margin-bottom: 0.5rem;
}

.settings-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--plait-border);
  border-radius: 0.75rem;
  background: var(--plait-input-bg, var(--plait-surface-elevated));
  color: var(--plait-text);
  margin-bottom: 0.75rem;
}

.settings-input:disabled {
  opacity: 0.55;
}

.settings-select {
  appearance: auto;
  cursor: pointer;
}

.settings-select:disabled {
  cursor: not-allowed;
}

.settings-owntracks-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--plait-border);
}

.settings-owntracks-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.settings-owntracks-actions .btn-primary,
.settings-owntracks-actions .btn-secondary {
  flex: 1;
  min-width: 7rem;
}

.settings-panel .lang-bar {
  margin-bottom: 0;
}

.settings-panel .btn-primary {
  width: 100%;
  margin-top: 0.25rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--plait-surface);
  border-bottom: 1px solid var(--plait-border);
  backdrop-filter: blur(8px);
}

.header-status {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.status {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.status-sharing {
  color: var(--plait-ok);
}

.status-error {
  color: var(--plait-warn, #e8a838);
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-retry-geo {
  padding: 0;
  border: none;
  background: none;
  color: var(--plait-accent-hover);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-retry-geo:active {
  opacity: 0.8;
}

.btn-stop {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 0.9rem;
  background: var(--plait-danger);
  color: #fff;
  cursor: pointer;
  min-height: 42px;
}

.btn-stop:active {
  filter: brightness(0.9);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.map-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.map-viewport #map,
.map-viewport #map-3d,
.map-viewport #map-movements {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#map-movements {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.movements-empty {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--plait-text-muted);
  background: color-mix(in srgb, var(--plait-surface) 85%, transparent);
  pointer-events: none;
}

.movements-empty[hidden] {
  display: none !important;
}

.map-viewport #map-3d[hidden] {
  display: none !important;
}

.map-viewport #map[hidden] {
  display: none !important;
}

.map-overlay-controls {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 8.5rem;
}

.map-type-select {
  width: 100%;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--plait-border);
  border-radius: 0.75rem;
  background: var(--plait-surface-elevated);
  color: var(--plait-text);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  appearance: auto;
}

.map-type-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.map-type-select[hidden] {
  display: none !important;
}

.map-mode-toggle {
  width: 100%;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--plait-border);
  border-radius: 0.75rem;
  background: var(--plait-surface-elevated);
  color: var(--plait-text);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.map-mode-toggle:active {
  filter: brightness(0.9);
}

.map-mode-toggle[hidden] {
  display: none !important;
}

.leaflet-tooltip.map-marker-label {
  background: var(--plait-card);
  border: 1px solid var(--plait-border);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--plait-text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.leaflet-tooltip.map-marker-label::before {
  border-top-color: var(--plait-border);
}

.leaflet-tooltip.map-marker-label-offline {
  background: var(--plait-danger);
  border-color: #c93a3c;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  white-space: normal;
  text-align: center;
}

.leaflet-tooltip.map-marker-label-offline::before {
  border-top-color: #c93a3c;
}

.marker-tooltip-name {
  font-weight: 600;
  line-height: 1.2;
}

.marker-tooltip-since {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  opacity: 0.95;
}

.marker-pin-offline-wrap {
  background: transparent;
  border: none;
}

.leaflet-popup-content {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #1a1a1a;
}

.leaflet-popup-content strong {
  font-size: 1rem;
}
