:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--tg-theme-text-color, #152238);
  background: var(--tg-theme-bg-color, #f4f7fb);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% -10%, rgba(116, 97, 255, 0.14), transparent 38%),
    var(--tg-theme-bg-color, #f4f7fb);
}

button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }

.screen-message {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 32px;
  text-align: center;
  color: var(--tg-theme-hint-color, #718096);
}

.screen-message h1 { color: var(--tg-theme-text-color, #152238); font-size: 22px; }
.spinner { width: 36px; height: 36px; border: 3px solid rgba(108, 92, 231, .18); border-top-color: #6c5ce7; border-radius: 50%; animation: spin .8s linear infinite; }
.fatal-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 18px; color: #fff; background: #e74c3c; font-weight: 800; font-size: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

.app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.topbar h1 { margin: 2px 0 4px; font-size: 25px; letter-spacing: -.5px; }
.eyebrow { margin: 0; color: #6c5ce7; font-weight: 800; font-size: 11px; letter-spacing: 1.4px; }
.muted { margin: 0; color: var(--tg-theme-hint-color, #718096); }
.small { font-size: 12px; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border-radius: 17px; color: white; background: linear-gradient(135deg, #6c5ce7, #4f8cff); font-weight: 800; font-size: 18px; box-shadow: 0 8px 24px rgba(82, 76, 196, .25); }

.status-card { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border: 1px solid var(--tg-theme-section-separator-color, rgba(30, 45, 70, .08)); border-radius: 18px; background: var(--tg-theme-section-bg-color, #fff); box-shadow: 0 8px 30px rgba(21, 34, 56, .06); }
.status-date { margin: 3px 0 0; font-weight: 750; }
.status-pill { padding: 7px 11px; border-radius: 999px; font-weight: 750; font-size: 12px; }
.status-pill.pending { color: #9a6700; background: #fff4cf; }
.status-pill.done { color: #157347; background: #dcf8e9; }

.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin: 18px 0; padding: 4px; border-radius: 14px; background: var(--tg-theme-secondary-bg-color, #e9eef6); }
.tab { border: 0; border-radius: 11px; padding: 10px 8px; color: var(--tg-theme-hint-color, #667085); background: transparent; font-size: 13px; font-weight: 750; cursor: pointer; }
.tab.active { color: var(--tg-theme-button-text-color, #fff); background: var(--tg-theme-button-color, #6c5ce7); box-shadow: 0 4px 12px rgba(82, 76, 196, .2); }

.page { display: none; animation: appear .18s ease-out; }
.page.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }
.section-heading { display: flex; justify-content: space-between; margin: 20px 2px 12px; }
.section-heading h2, .team-summary h2, .preview h2 { margin: 0 0 4px; font-size: 19px; }
.section-heading p { margin: 0; color: var(--tg-theme-hint-color, #718096); font-size: 13px; line-height: 1.45; }

textarea { width: 100%; min-height: 165px; resize: vertical; border: 1px solid var(--tg-theme-section-separator-color, #dfe5ee); outline: none; padding: 16px; border-radius: 18px; color: var(--tg-theme-text-color, #152238); background: var(--tg-theme-section-bg-color, #fff); line-height: 1.5; box-shadow: 0 8px 30px rgba(21, 34, 56, .05); transition: border-color .2s, box-shadow .2s; }
textarea:focus { border-color: #6c5ce7; box-shadow: 0 0 0 3px rgba(108, 92, 231, .12); }
.textarea-meta { margin: 6px 7px 12px; text-align: right; color: var(--tg-theme-hint-color, #8a94a6); font-size: 11px; }

.primary-button { width: 100%; border: 0; border-radius: 15px; padding: 14px 18px; color: var(--tg-theme-button-text-color, #fff); background: var(--tg-theme-button-color, #6c5ce7); font-weight: 800; cursor: pointer; box-shadow: 0 8px 22px rgba(82, 76, 196, .22); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.spinner-inline { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.success-button { margin-top: 12px; background: #159a64; box-shadow: 0 8px 22px rgba(21, 154, 100, .2); }

.preview { margin-top: 18px; padding: 17px; border: 1px solid var(--tg-theme-section-separator-color, rgba(30, 45, 70, .08)); border-radius: 20px; background: var(--tg-theme-section-bg-color, #fff); box-shadow: 0 10px 32px rgba(21, 34, 56, .06); }
.preview-title { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.ai-badge { padding: 5px 8px; border-radius: 8px; color: #6c5ce7; background: rgba(108, 92, 231, .12); font-size: 11px; font-weight: 900; }
.structured-block { padding: 12px 0; border-top: 1px solid var(--tg-theme-section-separator-color, #edf0f5); }
.structured-block h3 { margin: 0 0 7px; font-size: 13px; }
.structured-block ul { margin: 0; padding-left: 20px; color: var(--tg-theme-text-color, #334155); font-size: 13px; line-height: 1.55; }
.empty { margin: 0; color: var(--tg-theme-hint-color, #8a94a6); font-size: 13px; }
.warning { color: #a15c00; background: #fff4cf; margin: 8px 0 0; padding: 10px 12px; border-radius: 11px; font-size: 12px; line-height: 1.45; }

.team-summary { display: flex; align-items: center; gap: 15px; margin: 20px 0 14px; padding: 16px; border-radius: 20px; background: var(--tg-theme-section-bg-color, #fff); box-shadow: 0 8px 30px rgba(21, 34, 56, .06); }
.progress-ring { display: grid; place-items: center; width: 64px; height: 64px; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(#28b779 var(--progress, 0%), #e7ebf2 0); position: relative; }
.progress-ring::after { content: ""; position: absolute; width: 48px; height: 48px; border-radius: 50%; background: var(--tg-theme-section-bg-color, #fff); }
.progress-ring span { z-index: 1; font-size: 12px; font-weight: 850; }
.filters { display: flex; gap: 7px; margin-bottom: 12px; overflow-x: auto; }
.filter { white-space: nowrap; border: 1px solid var(--tg-theme-section-separator-color, #dfe5ee); border-radius: 999px; padding: 7px 11px; color: var(--tg-theme-hint-color, #667085); background: var(--tg-theme-section-bg-color, #fff); font-size: 12px; font-weight: 750; }
.filter.active { color: #6c5ce7; border-color: rgba(108, 92, 231, .35); background: rgba(108, 92, 231, .08); }
.team-list { display: grid; gap: 8px; }
.person-card { display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 16px; background: var(--tg-theme-section-bg-color, #fff); }
.person-avatar { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #536dfe, #7c4dff); font-size: 13px; font-weight: 850; }
.person-info { min-width: 0; flex: 1; }
.person-name { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 750; }
.person-role { margin: 3px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tg-theme-hint-color, #7b8495); font-size: 11px; }
.person-status { width: 10px; height: 10px; border-radius: 50%; background: #d4dae4; }
.person-status.done { background: #28b779; box-shadow: 0 0 0 4px rgba(40, 183, 121, .12); }

.summary-content { display: grid; gap: 10px; margin-top: 14px; }
.summary-card { padding: 15px; border-radius: 17px; background: var(--tg-theme-section-bg-color, #fff); box-shadow: 0 8px 26px rgba(21, 34, 56, .05); }
.summary-card h3 { margin: 0 0 8px; font-size: 14px; }
.summary-card p, .summary-card li { font-size: 13px; line-height: 1.5; }
.summary-card ul { margin: 0; padding-left: 20px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 32px), 500px); padding: 12px 15px; border-radius: 13px; color: #fff; background: rgba(22, 31, 48, .94); text-align: center; font-size: 13px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); z-index: 10; }

@media (min-width: 560px) {
  .app { padding-left: 24px; padding-right: 24px; }
  .team-list { grid-template-columns: 1fr 1fr; }
}
