:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3efe7;
  color: #17201a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(42, 115, 75, .22), transparent 32rem),
    linear-gradient(180deg, #fff8ee 0%, #f2eadf 45%, #ebe3da 100%);
}

body.signed-in {
  background:
    radial-gradient(circle at top left, rgba(31, 92, 62, .1), transparent 24rem),
    linear-gradient(180deg, #f7f3ec 0%, #efe8de 100%);
}

button, input, select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  background: #173f2a;
  color: #fffaf3;
  font-weight: 800;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(23, 63, 42, .18);
}

button:active {
  transform: translateY(1px);
}

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #ded4c5;
  border-radius: 16px;
  background: #fffaf4;
  color: #17201a;
  padding: 12px 14px;
  outline: none;
}

input:focus, select:focus {
  border-color: #277149;
  box-shadow: 0 0 0 4px rgba(39, 113, 73, .12);
}

h1, h2, p {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.4rem, 13vw, 4.4rem);
  line-height: .88;
  letter-spacing: -.07em;
}

h2 {
  font-size: 1.15rem;
  letter-spacing: -.03em;
}

p {
  color: #6d655b;
  line-height: 1.45;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 104px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 12px;
  padding: 18px 4px 18px;
}

.hero p {
  max-width: 30rem;
  font-size: 1rem;
}

.hero-copy {
  display: grid;
  gap: 14px;
}

main {
  display: grid;
  gap: 14px;
}

.landing-card,
.account-card,
.onboarding-card,
.dashboard-card {
  display: grid;
  gap: 14px;
}

.landing-intro {
  max-width: 32rem;
  font-size: 1rem;
}

.landing-actions {
  gap: 10px;
}

.feature-grid {
  display: grid;
  gap: 10px;
}

.feature-card {
  display: grid;
  gap: 4px;
  border: 1px solid #e7ddcf;
  border-radius: 20px;
  background: #fffdf8;
  padding: 14px;
  box-shadow: none;
}

.feature-card strong {
  font-size: .98rem;
}

.feature-card span {
  color: #756c61;
  line-height: 1.35;
}

.dashboard-card {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-tile {
  display: grid;
  gap: 4px;
  border: 1px solid #e7ddcf;
  border-radius: 20px;
  background: linear-gradient(180deg, #fffdf8, #f7f0e6);
  padding: 14px;
}

.dashboard-tile strong {
  font-size: .98rem;
}

.dashboard-tile strong {
  min-height: 2.4em;
}

.dashboard-tile span {
  color: #756c61;
  line-height: 1.35;
}

body.signed-in .app-shell {
  width: min(100%, 480px);
  padding-top: 14px;
  padding-bottom: 104px;
}

body.signed-in .feature-grid {
  grid-template-columns: 1fr;
}

body:not(.signed-in) .dashboard-card {
  display: none !important;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-actions button {
  padding-inline: 12px;
}

.hero-topline, .section-heading, .provider-title, .rule-card-header, .action-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.app-mark {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: #17201a;
  color: #fffaf3;
  font-weight: 900;
  letter-spacing: -.03em;
}

.brand-lockup {
  display: grid;
  gap: 6px;
}

.brand-note {
  max-width: 22ch;
  margin: 0;
  font-size: .8rem;
  line-height: 1.35;
  color: #6d655b;
}

.hero-copy.app-only h1 {
  max-width: 9ch;
  font-size: clamp(1.95rem, 11vw, 3rem);
}

body.signed-in .hero-copy.app-only {
  gap: 8px;
}

body.signed-in .hero-copy.app-only h1 {
  max-width: 14ch;
  font-size: clamp(1.45rem, 7vw, 2.15rem);
  line-height: 1.02;
  letter-spacing: -.05em;
}

body.signed-in .hero-copy.app-only p {
  max-width: 24rem;
  font-size: .92rem;
}

body.signed-in .hero {
  gap: 10px;
  padding-bottom: 6px;
}

body.signed-in .hero-copy.landing-only {
  display: none;
}

body.signed-in .hero-copy.app-only {
  display: grid;
}

body.signed-in .hero-copy.app-only p {
  max-width: 24rem;
}

.screen {
  display: none;
  gap: 14px;
}

.screen.active {
  display: grid;
}

.card {
  border: 1px solid rgba(51, 42, 32, .08);
  border-radius: 28px;
  background: rgba(255, 250, 244, .86);
  padding: 18px;
  box-shadow: 0 20px 48px rgba(64, 49, 31, .12);
  backdrop-filter: blur(18px);
}

.onboarding-card {
  border-color: rgba(39, 113, 73, .2);
  background: linear-gradient(180deg, rgba(255, 250, 244, .96), rgba(239, 248, 241, .96));
}

.primary-card {
  min-height: 190px;
  display: grid;
  align-content: end;
  gap: 10px;
  background:
    linear-gradient(135deg, rgba(23, 63, 42, .94), rgba(39, 113, 73, .82)),
    #173f2a;
  color: #fffaf3;
}

.primary-card p, .primary-card .eyebrow {
  color: rgba(255, 250, 243, .78);
}

.eyebrow, .optional, .helper-text, .mini-status {
  font-size: .78rem;
  color: #8b8174;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-weight: 900;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading.standalone {
  margin-bottom: 10px;
}

.section-heading > div, .provider-title > div {
  min-width: 0;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: #f0d35d;
  color: #2b261c;
  font-weight: 900;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.stack-form label {
  display: grid;
  gap: 7px;
  color: #40382e;
  font-weight: 760;
}

.provider-section {
  display: grid;
  gap: 14px;
}

.provider-card {
  display: grid;
  gap: 16px;
}

.provider-title strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.capture-card {
  background: linear-gradient(180deg, rgba(255, 250, 244, .9), rgba(255, 244, 216, .9));
}

.connected {
  border-color: rgba(39, 113, 73, .34);
}

.status-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.ready {
  background: #dff3e6;
  color: #1e6941;
}

.status-pill.warning, .notice {
  background: #fff0c2;
  color: #835b00;
}

.status-pill.muted {
  background: rgba(23, 32, 26, .08);
  color: #6d655b;
}

.notice {
  border-radius: 18px;
  padding: 12px 14px;
  font-weight: 760;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

.studio-picker, .class-picker, .manual-fields {
  display: grid;
  gap: 10px;
}

.manual-fields, .time-grid, .preference-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.secondary-button {
  background: #ebe3da;
  color: #173f2a;
  box-shadow: none;
}

.telegram-card {
  display: grid;
  gap: 12px;
  border: 1px solid #e7ddcf;
  border-radius: 20px;
  background: #fffdf8;
  padding: 14px;
}

.telegram-card strong {
  display: block;
  margin-bottom: 4px;
}

.telegram-actions {
  display: grid;
  gap: 8px;
}

.telegram-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 999px;
  background: #2f7f55;
  color: #fffaf3;
  font-weight: 800;
  text-decoration: none;
}

.result-list {
  display: grid;
  gap: 8px;
}

.result-card, .selected-card, .rule-card, .empty-state, .skeleton-card {
  width: 100%;
  min-height: unset;
  border-radius: 20px;
  background: #fffdf8;
  color: #17201a;
  box-shadow: none;
  border: 1px solid #e7ddcf;
  padding: 13px 14px;
  text-align: left;
}

.result-card strong, .selected-card strong {
  display: block;
  margin-bottom: 4px;
}

.result-card span, .selected-card span {
  display: block;
  color: #756c61;
  font-size: .88rem;
  line-height: 1.35;
}

.selected-card {
  border-color: rgba(39, 113, 73, .36);
  background: #eef8f1;
}

.chip-fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

.chip-fieldset legend {
  width: 100%;
  margin-bottom: 2px;
  color: #40382e;
  font-weight: 760;
}

.chip-fieldset label, .toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid #e1d8ca;
  border-radius: 999px;
  background: #fffdf8;
  padding: 0 12px;
  color: #40382e;
  font-weight: 760;
}

.chip-fieldset input, .toggle-row input {
  width: auto;
  min-height: auto;
  accent-color: #277149;
}

.toggle-row {
  justify-content: flex-start;
  border-radius: 18px;
  padding: 12px 14px;
}

.rule-list {
  display: grid;
  gap: 10px;
}

.rule-card {
  display: grid;
  gap: 10px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-row span {
  border-radius: 999px;
  background: #f0eadf;
  color: #51483d;
  padding: 6px 9px;
  font-size: .78rem;
  font-weight: 760;
}

.rule-error {
  border-radius: 14px;
  background: #fff0c2;
  color: #835b00;
  padding: 9px 11px;
  font-size: .9rem;
}

.action-card {
  align-items: stretch;
}

.action-card button {
  align-self: center;
  padding: 0 18px;
}

.empty-state, .skeleton-card {
  color: #756c61;
  font-weight: 700;
}

.log-card {
  display: grid;
  gap: 10px;
}

pre {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  border-radius: 18px;
  background: #17201a;
  color: #eaf5ee;
  padding: 14px;
  white-space: pre-wrap;
  font-size: .82rem;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(calc(100% - 24px), 520px);
  padding: 7px;
  border: 1px solid rgba(51, 42, 32, .1);
  border-radius: 999px;
  background: rgba(255, 250, 244, .92);
  box-shadow: 0 18px 42px rgba(64, 49, 31, .2);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

body.signed-in .bottom-nav {
  width: min(calc(100% - 24px), 480px);
}

.bottom-nav button {
  min-height: 42px;
  background: transparent;
  color: #756c61;
  box-shadow: none;
  font-size: .78rem;
  padding-inline: 8px;
}

.bottom-nav button.active {
  background: #173f2a;
  color: #fffaf3;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 28px;
  }

  .card {
    padding: 22px;
  }

  .manual-fields, .time-grid, .preference-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .telegram-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
