/* ── Layout: app shell, app bar, view container ────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;         /* dynamic viewport — avoids Safari chrome overlap */
  height: 100vh;          /* fallback */
  overflow: hidden;
}

/* ── App bar ──────────────────────────────────────────────────────────────── */

.app-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: calc(var(--space-3) + var(--safe-top)) var(--space-4) var(--space-3);
  padding-left:  calc(var(--space-4) + var(--safe-left));
  padding-right: calc(var(--space-4) + var(--safe-right));
  background: var(--c-primary);
  color: #fff;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-bar__back {
  color: #fff;
  opacity: .85;
  font-size: var(--text-lg);
  padding: 0 var(--space-2);
  margin-left: calc(-1 * var(--space-2));
}

.app-bar__title {
  flex: 1;
  font-size: var(--text-lg);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

/* Sync / offline indicator */
.sync-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: rgba(255,255,255,.7);
  font-size: 18px;
  transition: color .2s;
}
.sync-icon[data-offline="true"]  { color: #fbbf24; }
.sync-icon[data-syncing="true"]  { animation: spin 1s linear infinite; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── View container ───────────────────────────────────────────────────────── */

#views {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: var(--space-4);
  padding-left:  calc(var(--space-4) + var(--safe-left));
  padding-right: calc(var(--space-4) + var(--safe-right));
  padding-bottom: calc(var(--space-8) + var(--safe-bottom));
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: calc(var(--space-6) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--c-text);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  animation: toast-in .15s ease;
}
.toast--error   { background: var(--c-danger); }
.toast--success { background: var(--c-success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
