:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #262b35;
  --text: #e8eaf0;
  --muted: #8a8f9c;
  --accent: #4f8cff;
  --warn: #ffb454;
  --good: #4fd48a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.muted { color: var(--muted); font-size: 0.9em; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar h1 { margin: 0; font-size: 1.4em; }

.countdown {
  text-align: center;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.countdown span#days-to-race {
  display: block;
  font-size: 1.8em;
  font-weight: 700;
  color: var(--accent);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95em;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: default; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { margin-top: 0; font-size: 1.05em; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.grid.two-col { grid-template-columns: 1fr 1fr; }

@media (max-width: 800px) {
  .grid, .grid.two-col { grid-template-columns: 1fr; }
}

.hidden { display: none; }

.pending { border-color: var(--warn); }

.rec-item {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.rec-item:first-child { border-top: none; }
.rec-actions { margin-top: 8px; display: flex; gap: 8px; }
.rec-actions button.reject { background: #3a3f4b; }

.plan-item, .note-item {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.plan-item:first-child, .note-item:first-child { border-top: none; }

.tag {
  display: inline-block;
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #23283330;
  border: 1px solid var(--border);
  margin-right: 6px;
  color: var(--muted);
}

.status-completed { color: var(--good); }
.status-modified { color: var(--warn); }

/* --- Auth (login/register) --- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
}
.auth-tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; color: var(--muted); }
.auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.95em;
}
.auth-form hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.auth-hint { font-size: 0.85em; color: var(--muted); margin: 0; }
.auth-error { color: #ff6b6b; font-size: 0.85em; min-height: 1.2em; margin: 0; }

/* --- Telegram-link panel --- */
.telegram-link code {
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  margin: 6px 0;
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user button.secondary { background: #3a3f4b; }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.9em; }
.back-link:hover { color: var(--text); }

/* --- Planning chat --- */
.chat-card { display: flex; flex-direction: column; height: 70vh; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.chat-hint { text-align: center; margin-top: 20px; }
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  white-space: pre-wrap;
  line-height: 1.4;
}
.chat-user { align-self: flex-end; background: var(--accent); color: white; }
.chat-assistant { align-self: flex-start; background: #23283a; }
.chat-assistant.thinking { color: var(--muted); font-style: italic; }
.chat-proposal { align-self: stretch; max-width: 100%; background: #23283a; border: 1px solid var(--warn); }
.chat-proposal .proposal-items { margin-top: 8px; max-height: 240px; overflow-y: auto; }
.chat-proposal summary { cursor: pointer; color: var(--accent); margin-top: 6px; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form textarea {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-family: inherit;
}
