:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #30363d;
  --accent: #60a5fa;
  --accent-2: #3b82f6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow: 0 20px 60px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(96,165,250,.16), transparent 36%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(13,17,23,.82);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { color: #fff; font-weight: 800; letter-spacing: -.025em; font-size: 1.1rem; }
.nav { display: flex; align-items: center; gap: .9rem; }
.nav a, .nav-user { color: var(--muted); font-size: .95rem; }
.nav a:hover { color: #fff; }
.nav-toggle { display: none; background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: .6rem; padding: .35rem .55rem; }
.container { width: min(1120px, calc(100% - 2rem)); margin: 2rem auto; }
.footer { color: var(--muted); text-align: center; padding: 2rem; font-size: .85rem; }

.hero, .card, .chat-shell, .admin-grid > a, .notice {
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.02));
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}
.hero { padding: clamp(1.5rem, 5vw, 3rem); display: grid; gap: 1rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 4rem); margin: 0; letter-spacing: -.06em; line-height: .95; }
.hero p { color: var(--muted); max-width: 680px; font-size: 1.08rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.card { padding: 1.25rem; }
.card h2, .card h3 { margin-top: 0; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.button, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 0;
  border-radius: .75rem;
  padding: .75rem 1rem;
  background: var(--accent-2);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
}
.button:hover, button:hover, input[type="submit"]:hover { transform: translateY(-1px); text-decoration: none; opacity: .95; }
.button.secondary, button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.button.danger, button.danger { background: var(--danger); }
.button.small, button.small { padding: .45rem .7rem; border-radius: .55rem; font-size: .85rem; }

form { display: grid; gap: .9rem; }
label { display: grid; gap: .35rem; color: var(--muted); font-size: .95rem; }
input, textarea, select {
  width: 100%;
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: .75rem .85rem;
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(96,165,250,.35); border-color: var(--accent); }

.alert, .notice { padding: .95rem 1rem; margin-bottom: 1rem; border-radius: 1rem; border: 1px solid var(--line); }
.alert.success { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); }
.alert.error { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); }
.alert.warning, .notice.warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }

.chat-shell { display: grid; grid-template-rows: auto 1fr auto; height: min(720px, calc(100vh - 190px)); overflow: hidden; }
.chat-header { padding: 1rem; border-bottom: 1px solid var(--line); }
.chat-messages { padding: 1rem; overflow-y: auto; display: grid; align-content: start; gap: .75rem; background: rgba(0,0,0,.12); }
.message { display: grid; gap: .25rem; padding: .75rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(255,255,255,.035); }
.message-meta { display: flex; justify-content: space-between; gap: .75rem; color: var(--muted); font-size: .82rem; flex-wrap: wrap; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: .75rem; padding: 1rem; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 48px; max-height: 140px; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.admin-grid > a { padding: 1.25rem; color: var(--text); }
.admin-grid strong { display: block; font-size: 1.1rem; margin-bottom: .4rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .2rem .55rem; background: var(--panel-2); color: var(--muted); font-size: .8rem; }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; top: 64px; left: 1rem; right: 1rem; flex-direction: column; align-items: stretch; background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; }
  .nav.open { display: flex; }
  .chat-shell { height: calc(100vh - 170px); }
  .chat-form { grid-template-columns: 1fr; }
}

button:disabled, textarea:disabled, input:disabled {
  opacity: .55;
  cursor: not-allowed;
}
