:root {
  --bg: #0f1625;
  --card: #131b2c;
  --border: #1f2940;
  --text: #e8ecf5;
  --muted: #8da2c0;
  --accent: #46aef7;
  --accent-strong: #5be3ff;
  --warn: #f6c344;
  --error: #ff7b7b;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(70, 174, 247, 0.15), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(91, 227, 255, 0.12), transparent 30%),
    linear-gradient(160deg, #0f1625 0%, #0d1220 60%, #0b101c 100%);
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
}

.app {
  max-width: 960px;
  margin: 0 auto 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 20, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.form-modal .modal-content {
  max-width: 880px;
  width: 94vw;
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  align-items: flex-start;
  gap: 16px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  grid-column: 1;
}

.small-text {
  font-size: 12px;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 260px;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}

.modal-title {
  margin: 0;
  font-weight: 700;
}

.modal-desc {
  margin: 4px 0 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(91, 227, 255, 0.25);
  border-top-color: var(--accent-strong);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.small {
  padding: 8px 12px;
  font-size: 13px;
}

header.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1, h2 {
  margin: 4px 0 8px;
}

h2 {
  font-size: 18px;
}

p {
  margin: 4px 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--accent-strong);
  margin: 0 0 6px;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

@media (min-width: 420px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 12px 0;
}

#tg-user {
  display: none;
}

.hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#open-post-modal {
  background: var(--accent);
  color: #0c111c;
  border: 1px solid var(--accent);
}

#open-post-modal:hover {
  box-shadow: 0 6px 18px rgba(70, 174, 247, 0.3);
  transform: translateY(-1px);
}

#ton-connect-btn {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.tc-modal__overlay {
  background: transparent !important;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  grid-column: 2;
}

input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.form-modal textarea {
  min-height: 140px;
}

.form-modal h3 {
  margin: 4px 0 8px;
}

.form-modal .modal-head button {
  align-self: flex-start;
}

@media (max-width: 640px) {
  .form-modal .modal-content {
    grid-template-columns: 1fr;
  }
  .form-modal .form-col {
    grid-column: 1;
  }
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91, 227, 255, 0.15);
  background: #0d1526;
}

button {
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #0c111c;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(70, 174, 247, 0.3);
}

button:active {
  transform: translateY(0);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.ghost.small {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgba(91, 227, 255, 0.08);
}

button.ghost.small:hover {
  box-shadow: 0 6px 18px rgba(91, 227, 255, 0.24);
  transform: translateY(-1px);
}

.pre,
pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.mono {
  font-family: 'SFMono-Regular', Consolas, Monaco, monospace;
  font-size: 13px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-col .btn-row {
  justify-content: center;
}

.post-card {
  padding-bottom: 12px;
}

.post-card pre {
  margin: 0;
  padding: 0;
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.pill.success { background: rgba(91, 227, 255, 0.14); color: var(--accent-strong); }
.pill.warning { background: rgba(246, 195, 68, 0.15); color: var(--warn); }
.pill.error { background: rgba(255, 123, 123, 0.12); color: var(--error); }

.list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.list .item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #0e1626;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-clamp: 2;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(70, 174, 247, 0.14);
  color: var(--accent-strong);
  font-size: 12px;
  margin-right: 8px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #111a2b;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  body {
    padding: 20px;
  }
  header.card {
    flex-direction: column;
    align-items: flex-start;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
