:root {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --card: #1c2029;
  --card-hover: #222733;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #6c5ce7;
  --accent-2: #a29bfe;
  --accent-soft: rgba(108, 92, 231, 0.15);
  --green: #20bf6b;
  --red: #eb3b5a;
  --amber: #f7b731;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
          "Hiragino Sans", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 760px; margin: 0 auto; padding: 24px 18px 80px; }
.wrap-wide { max-width: 1100px; }

/* ---- Header ---- */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 0; margin-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px var(--accent);
}
.appbar .meta { color: var(--muted); font-size: 13px; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.hero {
  text-align: center;
  padding: 40px 24px;
  background: radial-gradient(120% 140% at 50% 0%, rgba(108,92,231,0.18), transparent 60%), var(--card);
}
.hero h1 { font-size: 26px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0 0 24px; }

/* ---- Forms ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
input[type=text], input[type=password], textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 90px; }

.code-input {
  text-align: center;
  letter-spacing: .35em;
  font-size: 26px;
  font-weight: 700;
  text-transform: uppercase;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 12px 18px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: transform .08s, background .15s, opacity .15s;
}
.btn:hover { background: #5a4bd6; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--card-hover); }
.btn-danger { background: transparent; border: 1px solid var(--red); color: #ff8aa0; }
.btn-danger:hover { background: rgba(235,59,90,.12); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }

/* ---- Tabs ---- */
.tabs { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.tabs button {
  background: transparent; border: none; color: var(--muted);
  padding: 7px 16px; border-radius: 7px; cursor: pointer; font-size: 14px; font-family: inherit; font-weight: 600;
}
.tabs button.active { background: var(--accent); color: #fff; }

/* ---- Question list ---- */
.qlist { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.qitem {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: border-color .15s, transform .15s;
  animation: fadein .25s ease;
}
.qitem:hover { border-color: #36405a; }
.qitem.answered { opacity: .62; }
.qbody { flex: 1; min-width: 0; }
.qbody .text { font-size: 16px; word-break: break-word; white-space: pre-wrap; }
.qmeta { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.vote {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 56px; padding: 8px 6px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; user-select: none;
  transition: all .12s; font-family: inherit; color: var(--text);
}
.vote:hover { border-color: var(--accent); }
.vote.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.vote .up { font-size: 16px; line-height: 1; }
.vote .count { font-size: 17px; font-weight: 700; margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.badge.answered { background: rgba(32,191,107,.15); color: #5fe2a0; }
.badge.hidden   { background: rgba(235,59,90,.15); color: #ff8aa0; }
.badge.closed   { background: rgba(247,183,49,.15); color: var(--amber); }

/* ---- Admin event cards ---- */
.evgrid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
.evcard { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.evcard .code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .12em; color: var(--accent-2); font-size: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Presentation (projector) view ---- */
.present { padding: 40px 56px; max-width: 1400px; margin: 0 auto; }
.present .phead { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 28px; }
.present .phead h1 { font-size: 40px; margin: 0; }
.present .joincode { font-size: 22px; color: var(--muted); }
.present .joincode b { color: var(--accent-2); font-family: ui-monospace, monospace; letter-spacing: .1em; }
.pqlist { display: flex; flex-direction: column; gap: 20px; }
.pqitem { display: flex; gap: 24px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 28px 32px; }
.pqitem.answered { opacity: .5; }
.pqvotes { display: flex; flex-direction: column; align-items: center; min-width: 90px; }
.pqvotes .n { font-size: 44px; font-weight: 800; color: var(--accent-2); line-height: 1; }
.pqvotes .l { font-size: 14px; color: var(--muted); }
.pqtext { font-size: 30px; line-height: 1.4; }
.pqauthor { font-size: 18px; color: var(--muted); margin-top: 8px; }

@media (max-width: 640px) {
  .hero h1 { font-size: 22px; }
  .qbody .text { font-size: 15px; }
}
