:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --border: #e4e6eb;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.brand-logo {
  width: 28px;
  height: 28px;
  flex: none;
  transition: transform .2s ease;
}
.brand:hover .brand-logo { transform: rotate(-6deg); }
.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 15px;
}
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); }
.nav a.btn { color: #fff; }
.nav a.btn:hover { color: #fff; }
.nav a.btn-ghost { color: var(--text); }
.nav a.btn-ghost:hover { color: var(--text); }
.nav-user { color: var(--text); font-weight: 600; }

/* layout */
.main {
  flex: 1;
  padding: 40px 20px 64px;
}
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: var(--muted);
  font-size: 14px;
}

.hero { margin-bottom: 24px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -.02em;
}
.lead { margin: 0; color: var(--muted); }

/* cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.form-card {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.form-card .field { flex: 1 1 320px; margin: 0; }

.topic-card { margin-bottom: 18px; }
.topic-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.topic-title { margin: 0 0 10px; font-size: 20px; line-height: 1.35; }
.topic-description { margin: 0 0 18px; color: #374151; }
.topic-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.topic-actions form { margin: 0; }

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.grid .topic-card { margin-bottom: 0; display: flex; flex-direction: column; }
.grid .topic-actions { margin-top: auto; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 24px;
}
.empty p { margin: 0 0 16px; }

/* badges & buttons */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.badge-accent { background: #e8f7ee; color: #067647; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: #4338ca; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid #c7d2fe; outline-offset: 2px; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: #f3f4f6; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-block { width: 100%; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 14px; font-weight: 600; }
.field-help { font-size: 13px; color: var(--muted); }
.field-help ul { margin: 6px 0 0; padding-left: 18px; }
.field-error { font-size: 13px; color: var(--danger); }

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

/* auth */
.auth-wrap { max-width: 430px; margin: 0 auto; }
.auth-title { margin: 0 0 6px; font-size: 24px; }
.auth-form { margin-top: 22px; }
.auth-switch { margin: 18px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.auth-switch a { color: var(--accent); }

/* alerts */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  background: var(--accent-soft);
  color: var(--accent);
}
.alert-error { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 560px) {
  .nav { gap: 12px; font-size: 14px; }
  .nav-user { display: none; }
  .brand-logo { width: 24px; height: 24px; }
  .main { padding-top: 24px; }
  .form-card { padding: 18px; }
}
