/* Design tokens — Apple glass, spec §1. Own palette (NOT per-user Telegram colors); light/dark by
   Telegram colorScheme. One tint per surface = --phase-accent (set by js/phase.js). */

:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --surface-grouped: #f2f2f7;
  --separator: rgba(60, 60, 67, 0.18);
  --text: #1d1d1f;
  --text-secondary: rgba(60, 60, 67, 0.78);
  --text-tertiary: rgba(60, 60, 67, 0.55);
  --material-thin: rgba(255, 255, 255, 0.6);
  --material-regular: rgba(255, 255, 255, 0.78);
  --material-thick: rgba(255, 255, 255, 0.92);

  --system-blue: #007aff;
  --system-green: #34c759;
  --system-orange: #ff9500;
  --system-purple: #af52de;
  --system-red: #ff3b30;
  --graphite: #8e8e93;

  --phase-accent: var(--system-green);

  --page: #f2f3f7;

  /* spacing (8pt), radii */
  --r-card: 14px;
  --r-btn: 12px;
  --r-input: 10px;
  --r-sheet: 16px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root.dark {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --surface-grouped: #2c2c2e;
  --separator: rgba(84, 84, 88, 0.65);
  --text: #f5f5f7;
  --text-secondary: rgba(235, 235, 245, 0.78);
  --text-tertiary: rgba(235, 235, 245, 0.55);
  --material-thin: rgba(30, 30, 32, 0.6);
  --material-regular: rgba(30, 30, 32, 0.78);
  --material-thick: rgba(30, 30, 32, 0.92);
  --page: #000000;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, 'Onest', system-ui, sans-serif;
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* App shell: header / scrolling screen / dock */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.tg-header {
  flex: none;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  padding-top: var(--safe-top);
  box-sizing: content-box;
  background: var(--material-thin);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-bottom: 0.5px solid var(--separator);
}
.tg-header .h-title {
  flex: 1;
  text-align: center;
  font: 600 17px/1 -apple-system, 'Onest', system-ui;
}
.hbtn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--phase-accent);
  cursor: pointer;
  border-radius: 50%;
}
.hbtn[hidden],
.navatar[hidden],
.phase-chip[hidden] {
  display: none;
}
.navatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--phase-accent), #0a84ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.navatar i {
  width: 16px;
  height: 16px;
}
.phase-chip {
  font: 600 11px/1 -apple-system, 'Onest', system-ui;
  color: #fff;
  background: var(--phase-accent);
  padding: 5px 9px;
  border-radius: 999px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}
.phase-chip i {
  width: 12px;
  height: 12px;
}

.body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}

.tg-bottom {
  flex: none;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: var(--material-thin);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 0.5px solid var(--separator);
}
.tg-bottom:empty {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
