/* ─────────────────────────────────────────────────────────────
   Komunalka — design tokens & shared styles
   ───────────────────────────────────────────────────────────── */

:root {
  /* Surface — Rovio-warm cream */
  --kx-bg: #F4ECDB;          /* deeper warm cream */
  --kx-bg-deeper: #E9DFC6;
  --kx-surface: #FFFFFF;     /* card */
  --kx-surface-2: #FAF5E8;   /* subtle card */
  --kx-divider: rgba(40, 33, 22, 0.06);
  --kx-soft-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 8px 24px rgba(60, 45, 20, 0.06);

  /* Ink */
  --kx-ink: #121212;
  --kx-ink-2: #4A4339;
  --kx-ink-3: #8C8273;
  --kx-ink-4: #B8AE9D;

  /* Accent (honey) */
  --kx-accent: #F4C95D;
  --kx-accent-2: #FFE399;
  --kx-accent-ink: #1F1605;

  /* Service tints — soft, distinct */
  --kx-elec-bg: #FFE9A6;     --kx-elec-ink: #6B4E00;  --kx-elec-mark: #F4B82A;
  --kx-water-bg: #D6E8F4;    --kx-water-ink: #1F4A75; --kx-water-mark: #4A8FCB;
  --kx-heat-bg: #F8D2BB;     --kx-heat-ink: #7A2E0E;  --kx-heat-mark: #E07A5F;
  --kx-rent-bg: #DDE9CC;     --kx-rent-ink: #2C4A1A;  --kx-rent-mark: #6FA84B;

  /* Semantic */
  --kx-ok: #5C9A4A;
  --kx-warn: #D78A1F;
  --kx-err: #D24A3C;
}

/* Dark mode (Tweaks-driven, attached to .kx-dark on root) */
.kx-dark {
  --kx-bg: #17150F;
  --kx-bg-deeper: #0E0C08;
  --kx-surface: #211D16;
  --kx-surface-2: #1A1710;
  --kx-divider: rgba(255, 240, 215, 0.07);

  --kx-ink: #F5EFE0;
  --kx-ink-2: #C8C0AE;
  --kx-ink-3: #8C8273;
  --kx-ink-4: #5C5547;

  --kx-elec-bg: #3D3014;     --kx-elec-ink: #FCE5A4;
  --kx-water-bg: #1E3148;    --kx-water-ink: #BBD6EF;
  --kx-heat-bg: #3F2114;     --kx-heat-ink: #F7CFB7;
  --kx-rent-bg: #2A3520;     --kx-rent-ink: #CADBB4;
}

/* Base */
.kx {
  font-family: 'Onest', 'Manrope', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--kx-ink);
  background: var(--kx-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01';
  letter-spacing: -0.01em;
}

.kx * { box-sizing: border-box; }
.kx button { font-family: inherit; }

/* Telegram chrome strip (acts as TG header under iOS status bar) */
.kx-tg-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--kx-ink-3);
  background: var(--kx-bg);
  border-bottom: 1px solid var(--kx-divider);
  min-height: 42px;
}
.kx-tg-strip .kx-tg-title {
  display: flex; align-items: center; gap: 6px;
  color: var(--kx-ink-2);
}
.kx-tg-strip .kx-tg-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--kx-ok);
}

/* Phone screen scaffolding */
.kx-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--kx-bg);
  overflow: hidden;
  position: relative;
}
.kx-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 24px;
}
.kx-content--flush { padding: 0; }

/* Headlines — Rovio-bold */
.kx-display {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
  color: var(--kx-ink);
}
.kx-h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--kx-ink);
}
.kx-h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.15;
  color: var(--kx-ink);
}
.kx-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kx-ink-3);
}
.kx-body {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--kx-ink-2);
}
.kx-caption {
  font-size: 13px;
  color: var(--kx-ink-3);
  line-height: 1.4;
}
.kx-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Card */
.kx-card {
  background: var(--kx-surface);
  border-radius: 32px;
  padding: 22px;
  border: 1px solid var(--kx-divider);
  box-shadow: var(--kx-soft-shadow);
}
.kx-card--flat {
  background: var(--kx-surface-2);
  border: 1px solid var(--kx-divider);
}
.kx-card--ghost {
  background: transparent;
  border: 1.5px dashed var(--kx-ink-4);
}

/* Buttons */
.kx-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 64px;
  border-radius: 9999px;
  border: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: transform .12s, opacity .12s;
}
.kx-btn:active { transform: scale(0.985); }
.kx-btn--primary {
  background: var(--kx-ink);
  color: #fff;
}
.kx-btn--accent {
  background: var(--kx-accent);
  color: var(--kx-accent-ink);
}
.kx-btn--ghost {
  background: transparent;
  color: var(--kx-ink-2);
  height: 48px;
  font-weight: 500;
}
.kx-btn--secondary {
  background: var(--kx-bg-deeper);
  color: var(--kx-ink);
}
.kx-btn[disabled] {
  background: var(--kx-bg-deeper);
  color: var(--kx-ink-4);
  cursor: not-allowed;
}

/* Pill / chip */
.kx-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--kx-bg-deeper);
  color: var(--kx-ink-2);
}

/* Service mark */
.kx-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.kx-mark--lg { width: 56px; height: 56px; border-radius: 18px; font-size: 24px; }
.kx-mark--sm { width: 36px; height: 36px; border-radius: 12px; font-size: 16px; }

/* Input — Rovio-style large pill with label on top-left inside */
.kx-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kx-field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--kx-ink-3);
  padding-left: 4px;
}
.kx-input {
  width: 100%;
  height: 64px;
  background: var(--kx-surface);
  border-radius: 22px;
  padding: 0 22px;
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  color: var(--kx-ink);
  border: 1px solid rgba(40, 33, 22, 0.08);
  outline: none;
  font-family: inherit;
  box-shadow: var(--kx-soft-shadow);
}
/* Wrapping field — pill with label baked in */
.kx-pillfield {
  width: 100%;
  background: var(--kx-surface);
  border-radius: 28px;
  padding: 12px 22px 14px;
  border: 1px solid rgba(40, 33, 22, 0.06);
  box-shadow: var(--kx-soft-shadow);
  position: relative;
}
.kx-pillfield .kx-pillfield-label {
  font-size: 13px;
  color: var(--kx-ink-3);
  font-weight: 500;
  margin-bottom: 2px;
}
.kx-pillfield input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--kx-ink);
  padding: 0;
}
.kx-input--focused {
  border-color: var(--kx-ink);
}
.kx-input--error {
  border-color: var(--kx-err);
}

/* Progress dots */
.kx-progress {
  display: flex;
  gap: 6px;
  align-items: center;
}
.kx-progress span {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: var(--kx-bg-deeper);
}
.kx-progress span.is-done { background: var(--kx-ink); }
.kx-progress span.is-current { background: var(--kx-accent); }

/* Status bullet */
.kx-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}
.kx-status .kx-dot { width: 6px; height: 6px; border-radius: 50%; }

/* Soft shape backgrounds (geometric placeholders replacing 3D characters) */
.kx-blob {
  width: 100%;
  aspect-ratio: 1.4 / 1;
  position: relative;
  border-radius: 28px;
  overflow: hidden;
}

/* Decorative grid for placeholder imagery */
.kx-placeholder-stripes {
  background-image: repeating-linear-gradient(
    135deg,
    rgba(0,0,0,0.04) 0 1px,
    transparent 1px 8px
  );
}

/* TG MainButton (bottom CTA) */
.kx-mainbtn {
  position: relative;
  padding: 14px 20px 28px;
  background: var(--kx-bg);
}
.kx-mainbtn--floating {
  background: transparent;
}

/* Bottom safe area */
.kx-bottom-pad { padding-bottom: 28px; }

/* Tweaks-driven tints */
.kx[data-accent="honey"]  { --kx-accent: #F2C14E; --kx-accent-ink:#2A2106; }
.kx[data-accent="leaf"]   { --kx-accent: #7FB069; --kx-accent-ink:#19310F; }
.kx[data-accent="sky"]    { --kx-accent: #6FA8DC; --kx-accent-ink:#0C2745; }
.kx[data-accent="clay"]   { --kx-accent: #E07A5F; --kx-accent-ink:#3B0F04; }
.kx[data-accent="ink"]    { --kx-accent: #1A1A1A; --kx-accent-ink:#FFFFFF; }
