:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f1f5fb);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #14213d);
  --muted: var(--tg-theme-hint-color, #72809a);
  --accent: var(--tg-theme-button-color, #1677ff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: color-mix(in srgb, var(--muted) 22%, transparent);
  --danger: #d9363e;
  --shadow: 0 16px 48px rgba(29, 63, 120, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

.shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 2px 24px;
}

.mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 17px;
  background: linear-gradient(145deg, var(--accent), #35a7ff);
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.05em;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 30%, transparent);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 24px; line-height: 1.05; letter-spacing: -0.03em; }
h2 { margin-bottom: 8px; font-size: 23px; letter-spacing: -0.025em; }
.eyebrow, .step { margin-bottom: 5px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }
.subtitle, .muted { margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }

.panel {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-panel { display: grid; place-items: center; min-height: 180px; color: var(--muted); }
.status-panel p { margin: 14px 0 0; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

form { display: grid; gap: 9px; margin-top: 22px; }
label { font-size: 13px; font-weight: 700; }
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  padding: 13px 14px;
  transition: border-color .16s, box-shadow .16s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }

.primary-button, .select-button {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 750;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.primary-button { width: 100%; margin-top: 8px; padding: 14px 18px; }
.select-button { flex: 0 0 auto; padding: 10px 14px; }
button:active { transform: scale(.98); }
button:disabled { cursor: wait; opacity: .55; }

.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }
.error-label { color: var(--danger); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 0 3px; }
.section-heading h2, .section-heading .step { margin-bottom: 0; }
.count-pill { border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); padding: 6px 10px; font-size: 12px; font-weight: 800; }

.search-field { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; padding: 0 13px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow); }
.search-field input { border: 0; box-shadow: none; background: transparent; padding-left: 0; }

.project-list { display: grid; gap: 9px; }
.project-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 66px; padding: 12px 12px 12px 16px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); box-shadow: 0 6px 24px rgba(29, 63, 120, .05); }
.project-title { margin: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 680; line-height: 1.35; }
.empty { color: var(--muted); text-align: center; box-shadow: none; }
.hidden { display: none !important; }

@media (min-width: 560px) {
  .shell { padding-left: 24px; padding-right: 24px; }
  .project-card { padding-left: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
