@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --blue: #2aabee;
  --blue-strong: #168acd;
  --green: #28a745;
  --red: #df3c46;
  --fallback-page-bg: #f3f5f7;
  --fallback-section-bg: #ffffff;
  --fallback-text: #17181a;
  --fallback-hint: #6d7278;
  --fallback-separator: #e2e5e9;
  color: var(--tg-theme-text-color, var(--fallback-text));
  background: var(--tg-theme-secondary-bg-color, var(--fallback-page-bg));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; min-height: 100%; margin: 0; }
body { min-height: 100svh; overflow-x: hidden; background: var(--tg-theme-secondary-bg-color, var(--fallback-page-bg)); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-shell { display: flex; min-height: 100svh; flex-direction: column; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: calc(4rem + env(safe-area-inset-top));
  padding: calc(0.65rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.65rem max(1rem, env(safe-area-inset-left));
  align-items: center;
  border-bottom: 1px solid var(--tg-theme-section-separator-color, var(--fallback-separator));
  background: color-mix(in srgb, var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fallback-section-bg))) 94%, transparent);
  backdrop-filter: blur(0.8rem);
}

.brand {
  display: inline-flex;
  min-width: 0;
  padding: 0;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  color: inherit;
  background: transparent;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.25rem;
  font-weight: 720;
  letter-spacing: -0.06em;
  line-height: 1;
  cursor: pointer;
}
.brand img { display: block; width: 2.25rem; height: 2.25rem; flex: 0 0 2.25rem; object-fit: contain; }

.app-main { width: 100%; max-width: 42rem; margin: 0 auto; padding: 1.25rem max(1rem, env(safe-area-inset-right)) 2rem max(1rem, env(safe-area-inset-left)); flex: 1; }
.app-footer { display: flex; padding: 0.8rem 1rem calc(1rem + env(safe-area-inset-bottom)); justify-content: center; gap: 0.45rem; color: var(--tg-theme-hint-color, var(--fallback-hint)); font-size: 0.78rem; }
.app-footer button { padding: 0; border: 0; color: var(--tg-theme-link-color, var(--blue-strong)); background: none; cursor: pointer; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Bricolage Grotesque", sans-serif; letter-spacing: -0.035em; }
h1 { margin-bottom: 0.55rem; font-size: clamp(1.75rem, 7vw, 2.35rem); line-height: 1.03; }
h2 { margin-bottom: 0.35rem; font-size: 1.35rem; }
h3 { margin-bottom: 0.2rem; font-size: 1.03rem; }
.lead { max-width: 31rem; margin-bottom: 1.35rem; color: var(--tg-theme-hint-color, var(--fallback-hint)); line-height: 1.55; }
.eyebrow { margin-bottom: 0.45rem; color: var(--tg-theme-link-color, var(--blue-strong)); font-size: 0.73rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; }
.muted, .helper { color: var(--tg-theme-hint-color, var(--fallback-hint)); }
.helper { margin: 0.6rem 0 0; font-size: 0.8rem; line-height: 1.45; }

.panel, .loading-card, .notice {
  border: 1px solid var(--tg-theme-section-separator-color, var(--fallback-separator));
  border-radius: 1.15rem;
  background: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fallback-section-bg)));
  box-shadow: 0 0.4rem 1.4rem rgb(0 0 0 / 0.035);
}
.panel { padding: 1rem; }
.panel + .panel { margin-top: 0.8rem; }
.loading-card { display: flex; min-height: 10rem; align-items: center; justify-content: center; flex-direction: column; gap: 0.8rem; color: var(--tg-theme-hint-color, var(--fallback-hint)); }
.loading-card p { margin: 0; }
.spinner { width: 1.55rem; height: 1.55rem; border: 0.18rem solid color-mix(in srgb, var(--blue) 24%, transparent); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.choice-card { min-height: 8.5rem; padding: 1rem; border: 1px solid var(--tg-theme-section-separator-color, var(--fallback-separator)); border-radius: 1rem; color: inherit; background: var(--tg-theme-section-bg-color, var(--fallback-section-bg)); text-align: left; cursor: pointer; }
.choice-card:active { transform: scale(0.985); }
.choice-icon { display: grid; width: 2.5rem; height: 2.5rem; margin-bottom: 1rem; place-items: center; border-radius: 0.8rem; background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--tg-theme-link-color, var(--blue-strong)); font-size: 1.25rem; font-weight: 800; }
.choice-card strong { display: block; margin-bottom: 0.25rem; }
.choice-card span:last-child { color: var(--tg-theme-hint-color, var(--fallback-hint)); font-size: 0.78rem; line-height: 1.4; }

.field { display: grid; margin-bottom: 1rem; gap: 0.42rem; }
.field > span { font-size: 0.8rem; font-weight: 700; }
.field input { width: 100%; min-height: 3rem; padding: 0.75rem 0.85rem; border: 1px solid var(--tg-theme-section-separator-color, var(--fallback-separator)); border-radius: 0.8rem; outline: none; color: inherit; background: var(--tg-theme-secondary-bg-color, var(--fallback-page-bg)); }
.field input:focus { border-color: var(--tg-theme-button-color, var(--blue)); box-shadow: 0 0 0 0.18rem color-mix(in srgb, var(--blue) 14%, transparent); }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 1rem; gap: 0.7rem; }
.mode-option { position: relative; }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option span { display: block; min-height: 6.8rem; padding: 0.85rem; border: 1px solid var(--tg-theme-section-separator-color, var(--fallback-separator)); border-radius: 0.85rem; background: var(--tg-theme-secondary-bg-color, var(--fallback-page-bg)); }
.mode-option strong { display: block; margin-bottom: 0.28rem; }
.mode-option small { color: var(--tg-theme-hint-color, var(--fallback-hint)); line-height: 1.35; }
.mode-option input:checked + span { border-color: var(--tg-theme-button-color, var(--blue)); box-shadow: inset 0 0 0 1px var(--tg-theme-button-color, var(--blue)); background: color-mix(in srgb, var(--blue) 9%, var(--tg-theme-section-bg-color, white)); }
.consent { display: flex; margin: 0.25rem 0 1.1rem; align-items: flex-start; gap: 0.65rem; color: var(--tg-theme-hint-color, var(--fallback-hint)); font-size: 0.78rem; line-height: 1.45; }
.consent input { width: 1.1rem; height: 1.1rem; margin: 0.1rem 0 0; accent-color: var(--tg-theme-button-color, var(--blue)); }

.button-row { display: flex; margin-top: 1rem; gap: 0.65rem; }
.button { display: inline-flex; min-height: 2.9rem; padding: 0.72rem 1rem; align-items: center; justify-content: center; border: 0; border-radius: 0.82rem; background: var(--tg-theme-button-color, var(--blue)); color: var(--tg-theme-button-text-color, white); font-weight: 750; text-decoration: none; cursor: pointer; }
.button.secondary { border: 1px solid var(--tg-theme-section-separator-color, var(--fallback-separator)); background: var(--tg-theme-secondary-bg-color, var(--fallback-page-bg)); color: var(--tg-theme-text-color, var(--fallback-text)); }
.button.block { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button-row .button { flex: 1; }
.text-button { padding: 0; border: 0; color: var(--tg-theme-link-color, var(--blue-strong)); background: none; font-weight: 700; cursor: pointer; }

.workspace-head { display: flex; margin-bottom: 1rem; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.workspace-head h1 { margin-bottom: 0.2rem; }
.badge { display: inline-flex; padding: 0.35rem 0.6rem; align-items: center; border-radius: 999px; background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--tg-theme-link-color, var(--blue-strong)); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; }
.stepper { display: flex; margin-bottom: 1rem; align-items: center; gap: 0.45rem; }
.step-dot { height: 0.34rem; flex: 1; border-radius: 999px; background: var(--tg-theme-section-separator-color, var(--fallback-separator)); }
.step-dot.active { background: var(--tg-theme-button-color, var(--blue)); }

.checklist { margin: 0.85rem 0 0; padding: 0; list-style: none; }
.check { display: flex; min-height: 2.7rem; padding: 0.55rem 0; align-items: center; gap: 0.7rem; border-top: 1px solid var(--tg-theme-section-separator-color, var(--fallback-separator)); }
.check:first-child { border-top: 0; }
.check-mark { display: grid; width: 1.45rem; height: 1.45rem; flex: 0 0 1.45rem; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--red) 11%, transparent); color: var(--red); font-size: 0.78rem; font-weight: 900; }
.check.done .check-mark { background: color-mix(in srgb, var(--green) 13%, transparent); color: var(--green); }
.check span:last-child { font-size: 0.86rem; font-weight: 620; }
.locked-panel { opacity: 0.58; }
.success { padding: 1.15rem; border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); border-radius: 1rem; background: color-mix(in srgb, var(--green) 8%, var(--tg-theme-section-bg-color, white)); }
.success-icon { display: grid; width: 2.7rem; height: 2.7rem; margin-bottom: 0.8rem; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 1.25rem; font-weight: 900; }
.notice { padding: 0.85rem; color: var(--tg-theme-hint-color, var(--fallback-hint)); font-size: 0.8rem; line-height: 1.45; }
.error { margin-bottom: 0.85rem; padding: 0.75rem; border-radius: 0.75rem; background: color-mix(in srgb, var(--red) 10%, transparent); color: var(--red); font-size: 0.8rem; }
.code-box { display: flex; margin-top: 0.7rem; padding: 0.7rem; align-items: center; gap: 0.65rem; border: 1px dashed var(--tg-theme-section-separator-color, var(--fallback-separator)); border-radius: 0.75rem; background: var(--tg-theme-secondary-bg-color, var(--fallback-page-bg)); }
.code-box code { min-width: 0; flex: 1; overflow: hidden; font-size: 0.67rem; text-overflow: ellipsis; white-space: nowrap; }
.dialog-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; padding: 1rem; place-items: end center; background: rgb(0 0 0 / 0.42); }
.dialog { width: min(100%, 32rem); padding: 1.1rem; border-radius: 1.1rem; background: var(--tg-theme-section-bg-color, var(--fallback-section-bg)); box-shadow: 0 1rem 3rem rgb(0 0 0 / 0.25); }

@media (max-width: 380px) {
  .brand { font-size: 1.08rem; }
  .brand img { width: 2rem; height: 2rem; flex-basis: 2rem; }
  .choice-grid, .mode-options { grid-template-columns: 1fr; }
  .choice-card { min-height: 6.6rem; }
  .choice-icon { margin-bottom: 0.65rem; }
}

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