:root {
  --bg: var(--tg-theme-bg-color, #1a1a1e);
  --text: var(--tg-theme-text-color, #f2f2f2);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --secondary: var(--tg-theme-secondary-bg-color, #2c2c2e);
  --destructive: var(--tg-theme-destructive-text-color, #ff453a);
  --radius: 12px;
  --pad: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100%;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0));
  min-height: 100vh;
}

.screen { display: none; }
.screen.screen-active { display: block; }

#screen-wizard.screen-active { padding-bottom: 88px; }

/* —— Стартовый экран (BotFather-style) —— */
.home-hero {
  text-align: center;
  padding: 8px 0 20px;
}

.home-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: contain;
  margin-bottom: 12px;
}

.home-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.home-desc {
  margin: 0 auto 10px;
  max-width: 320px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--hint);
}

.home-greeting {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.home-section-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
}

.list-card {
  background: var(--secondary);
  border-radius: 14px;
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.list-row:last-child { border-bottom: none; }

.list-row-create { background: transparent; }

.list-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1e;
}

.list-avatar-add {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

.list-avatar-profile {
  background: var(--secondary);
  font-size: 22px;
  line-height: 1;
}

.profile-hint {
  margin: 8px 0 16px;
}

#screen-profile .input {
  margin-bottom: 10px;
}

#screen-profile .btn.block {
  margin-top: 8px;
}

.list-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-title-accent { color: var(--accent); }

.list-sub {
  font-size: 13px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-status {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}

.list-status-active { color: #34c759; }
.list-status-hidden { color: #ff453a; }

.detail-status-active { color: #34c759; font-size: 13px; font-weight: 600; }
.detail-status-hidden { color: #ff453a; font-size: 13px; font-weight: 600; }

.list-chevron {
  flex-shrink: 0;
  font-size: 22px;
  color: var(--hint);
  line-height: 1;
}

.list-empty, .list-error {
  padding: 14px;
  margin: 0;
  font-size: 14px;
  color: var(--hint);
  text-align: center;
}

.list-error { color: var(--destructive); }

.home-footer {
  margin: 24px 0 8px;
  text-align: center;
  font-size: 13px;
  color: var(--hint);
}

.detail-card {
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.detail-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.detail-row { margin: 6px 0; font-size: 15px; }
.detail-row.muted { color: var(--hint); font-size: 14px; }

.wizard-header { margin-bottom: 12px; }

.header h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--hint);
  font-size: 14px;
}

.step { display: none; }
.step.active { display: block; }

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--hint);
}

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--hint);
  line-height: 1.35;
  word-break: break-all;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--secondary);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
}

.btn-row, .btn-col {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-col { flex-direction: column; }

.chip {
  flex: 1;
  min-width: 120px;
  padding: 12px 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--secondary);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.chip.block { width: 100%; flex: none; }

.chip.selected {
  background: var(--accent);
  color: var(--accent-text);
}

.btn {
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn:disabled,
.btn.btn-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.ghost {
  background: var(--secondary);
  color: var(--text);
}

.btn.block {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  margin-top: 10px;
}

.card {
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  white-space: pre-wrap;
}

.card.success { border-left: 4px solid #30d158; }
.card.error { border-left: 4px solid var(--destructive); }

.card .row { margin: 6px 0; }
.card .title { font-weight: 700; font-size: 17px; margin-bottom: 10px; }

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px var(--pad);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(transparent, var(--bg) 24%);
  max-width: 480px;
  margin: 0 auto;
}

.footer .btn { flex: 1; }

.hidden { display: none !important; }

.loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading.hidden { display: none; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

#loading-text { color: var(--text); margin-top: 12px; }
