/* Telegram Mini App – dark, Durger King–style (clean, minimal) */
:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --text: #e0e0e6;
  --foreground: #fff;
  --muted: #2d2f3d;
  --muted-foreground: #9aa0b2;
  --hint: #7a7f8f;
  --primary: #3dd598;
  --primary-dark: #2eb87a;
  --primary-foreground: #0d1f18;
  --accent: #2d2f3d;
  --accentText: #e0e0e6;
  --danger: #ff6b6b;
  --border: rgba(255, 255, 255, 0.08);
  --input-background: #2d2f3d;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);

  --radius: 14px;
  --radiusSm: 10px;
  --pad: 14px;
  --gap: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  height: 100%;
  min-height: 100dvh;
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 12px);
  padding-left: calc(14px + env(safe-area-inset-left));
  padding-right: calc(14px + env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* With bottom bar: don’t scroll the whole screen; only the middle area scrolls */
.screen.screen--withBar {
  overflow: hidden;
}

.screen__scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.bottomBar {
  flex-shrink: 0;
  padding: 12px calc(var(--pad) + env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 12px) calc(var(--pad) + env(safe-area-inset-right));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.bottomBar .btn--primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: none;
  box-shadow: 0 2px 8px rgba(61, 213, 152, 0.35);
  font-weight: 700;
  color: var(--primary-foreground);
  transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.bottomBar .btn--primary:not(:disabled):hover {
  box-shadow: 0 3px 12px rgba(61, 213, 152, 0.45);
}
.bottomBar .btn--primary:disabled {
  background: var(--muted);
  box-shadow: none;
  color: var(--muted-foreground);
  opacity: 0.65;
  cursor: not-allowed;
}
.bottomBar .btn--ghost {
  background: var(--muted);
  border-color: var(--border);
  color: var(--foreground);
}

.progressRow {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progressTrack {
  height: 6px;
  border-radius: 999px;
  background: var(--muted);
  overflow: hidden;
}
.progressFill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
  transition: width 0.2s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  margin: 0 calc(-1 * var(--pad)) 0 calc(-1 * var(--pad));
  padding: 14px calc(20px + env(safe-area-inset-right)) 14px calc(20px + env(safe-area-inset-left));
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.brand { flex: 1; min-width: 0; }
.brand__title { font-weight: 700; font-size: 17px; letter-spacing: 0.01em; color: var(--foreground); }
.brand__subtitle { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }

.pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted-foreground);
  background: var(--muted);
  border: 1px solid var(--border);
}
.pill--ok { color: var(--primary); border-color: rgba(61, 213, 152, 0.5); background: rgba(61, 213, 152, 0.15); }
.pill--warn { color: #f0c14b; border-color: rgba(240, 193, 75, 0.5); background: rgba(240, 193, 75, 0.12); }
.pill--bad { color: var(--danger); border-color: rgba(255, 107, 107, 0.5); background: rgba(255, 107, 107, 0.12); }

.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: none;
  padding: var(--pad);
}

.muted { color: var(--muted-foreground); }
.hint { color: var(--hint); }

.h1 { font-size: 18px; font-weight: 720; margin: 0; color: var(--foreground); }
.h2 { font-size: 14px; font-weight: 650; margin: 0; color: var(--foreground); }

.pseudonym-display {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--foreground);
  letter-spacing: 0.02em;
}
.pseudonym-display .muted { font-weight: 500; }

.row { display: flex; gap: var(--gap); }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { height: 6px; }

label { font-size: 12px; color: var(--muted-foreground); }
input, textarea, select {
  width: 100%;
  padding: 12px 12px;
  border-radius: var(--radiusSm);
  border: 1px solid var(--border);
  background: var(--input-background);
  color: var(--text);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(61, 213, 152, 0.2);
}
textarea { resize: vertical; min-height: 96px; }
input::placeholder, textarea::placeholder { color: var(--muted-foreground); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radiusSm);
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--foreground);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
}
.btn:active { transform: translateY(1px); opacity: 0.95; }
.btn--primary {
  border: none;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--primary-foreground);
  font-weight: 700;
}
.btn--danger {
  border: none;
  background: var(--danger);
  color: #fff;
}
.btn--ghost {
  background: var(--muted);
  border-color: var(--border);
  color: var(--foreground);
}
/* Secondary action: greenish, softer than primary */
.btn--secondary {
  background: rgba(61, 213, 152, 0.15);
  border-color: rgba(61, 213, 152, 0.5);
  color: var(--primary);
}
.btn--secondary:not(:disabled):hover {
  background: rgba(61, 213, 152, 0.22);
  border-color: var(--primary);
}
.btn--block { width: 100%; }
.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.btn--primary:disabled,
.btn--primary[disabled] {
  background: var(--muted);
  color: var(--muted-foreground);
  box-shadow: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid--2col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 620px) {
  .grid:not(.grid--2col) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.tile {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}
.tile__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tile__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radiusSm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.tile__count {
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
  background: rgba(61, 213, 152, 0.2);
  border: 1px solid rgba(61, 213, 152, 0.5);
  padding: 3px 10px;
  border-radius: 999px;
  line-height: 1.4;
}
.tile__title { font-weight: 700; color: var(--foreground); }
.tile__desc { font-size: 12px; color: var(--muted-foreground); line-height: 1.35; }
.tile--span-2 { grid-column: span 2; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  touch-action: manipulation;
}
.chip {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input-background);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: inline-block;
  touch-action: manipulation;
}
.chip[aria-pressed="true"] {
  background: rgba(61, 213, 152, 0.18);
  border-color: var(--primary);
  color: var(--primary);
}

.footerActions {
  margin-top: var(--gap);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.footerActions--3col {
  grid-template-columns: 1fr 1fr 1fr;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
}
.modal {
  width: min(720px, 100%);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--surface);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
  padding: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modalTitle { font-weight: 700; font-size: 17px; color: var(--foreground); }
.modalText { color: var(--muted-foreground); font-size: 14px; line-height: 1.45; }
.modalActions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.listItem {
  border: 1px solid var(--border);
  border-radius: var(--radiusSm);
  padding: 12px;
  background: var(--input-background);
}
.listItem__title { font-weight: 600; color: var(--foreground); }
.listItem__meta { color: var(--muted-foreground); font-size: 12px; margin-top: 4px; }
.card__meta { font-size: 12px; margin-top: 4px; }

/* Read-only pitch detail (Submitted, Published, Closed) */
.card--readonly .card__field { margin-bottom: var(--gap); }
.card--readonly .card__field:last-of-type { margin-bottom: 0; }
.card__fieldLabel {
  display: block;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 4px;
}
.card__fieldValue {
  margin: 0;
  font-size: 15px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.card--readonly .card__fieldValue:empty::before { content: '—'; color: var(--muted-foreground); }