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

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Themed root background prevents white bars / overscroll flashes inside the
     iOS safe areas and behind the translucent status bar in both themes. */
  background: var(--bg-primary);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.4;
  direction: ltr;
  transition: background 0.3s ease, color 0.3s ease;
  touch-action: manipulation;
  overscroll-behavior: none;
}

a {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

input,
textarea {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

@media (max-width: 768px) {
  input,
  textarea,
  select {
    font-size: 16px;
  }

  * {
    -webkit-tap-highlight-color: transparent;
  }
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.toast {
  position: fixed;
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--accent);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  z-index: 2000;
  transition: transform 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px 16px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-primary);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
  transform: scale(0.9);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.update-modal {
  z-index: 2100;
  align-items: center;
  padding: 16px;
}

.update-modal-dialog {
  max-width: 400px;
  padding: 0;
  border: 1px solid var(--border-color);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.update-modal-content {
  padding: 28px 24px 24px;
  text-align: center;
}

.update-modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: update-pulse 2s ease-in-out infinite;
}

.update-modal-icon svg {
  width: 28px;
  height: 28px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes update-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb, 29, 155, 240), 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(var(--accent-rgb, 29, 155, 240), 0); }
}

.update-modal-content h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.update-modal-content p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.update-modal-actions {
  display: flex;
  gap: 10px;
}

.update-modal-later,
.update-modal-refresh {
  flex: 1;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.update-modal-later {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.update-modal-later:hover {
  background: var(--border-color);
}

.update-modal-refresh {
  background: var(--accent);
  color: #fff;
}

.update-modal-refresh:hover {
  background: var(--accent-hover);
}

.update-modal-refresh:disabled {
  opacity: 0.7;
  cursor: wait;
}
