/* ---------- theme variables ---------- */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --card-2: #eef1f6;
  --border: #dde2ec;
  --text: #1a2233;
  --muted: #6b7488;
  --accent: #3b82f6;
  --accent-text: #ffffff;
}

body.dark {
  --bg: #0f1117;
  --card: #181c26;
  --card-2: #222736;
  --border: #2c3345;
  --text: #e8ebf2;
  --muted: #8a92a6;
  --accent: #4f8ef7;
  --accent-text: #ffffff;
}

/* ---------- base ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px;
}

.container {
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- top bar ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.theme-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
}

/* ---------- headings ---------- */
h1 {
  font-size: 1.6rem;
}

.tagline {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 24px 0 10px;
}

/* ---------- forms ---------- */
input[type="text"] {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  margin-bottom: 10px;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:active {
  opacity: 0.8;
}

.autocomplete-wrap {
  position: relative;
}

.school-menu {
  position: absolute;
  top: calc(100% - 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  max-height: 260px;
  overflow-y: auto;
}

.school-menu[hidden] {
  display: none;
}

.school-menu button {
  background: none;
  border: none;
  color: var(--text);
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.school-menu button:hover {
  background: var(--card-2);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.attest-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 14px;
  cursor: pointer;
}

.attest-row input {
  margin-top: 2px;
  width: auto;
  flex-shrink: 0;
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

input[type="password"] {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  margin-bottom: 10px;
}

input[type="password"]:focus {
  border-color: var(--accent);
}

.password-wrap {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 10px;
  min-width: 0;
}

.password-wrap input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.reveal-btn {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- school page ---------- */
.room-tabs {
  display: flex;
  gap: 4px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin: 20px 0 14px;
  width: fit-content;
}

.room-list {
  list-style: none;
}

.room-list.scrollable {
  max-height: 230px;
  overflow-y: auto;
  padding-right: 4px;
}

.room-list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-name {
  font-weight: 600;
}

.room-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 5px;
  vertical-align: middle;
}

.room-list button {
  padding: 9px 16px;
  font-size: 0.85rem;
}

.archived-room {
  opacity: 0.75;
}

.view-link {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.mono-code {
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
}

.revoke-btn {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: #ef4444;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.leave-link {
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.leave-link a {
  color: var(--muted);
  text-decoration: none;
}

/* ---------- room page ---------- */
.room-code {
  color: var(--accent);
}

.ask-form {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.ask-form input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.similar-box {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 20px;
}

.similar-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.similar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.88rem;
}

.similar-row button {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  font-family: -apple-system, sans-serif;
}

.q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 10px;
}

.q-header h2 {
  margin: 0;
}

.sort-toggle,
.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.status-filter {
  width: fit-content;
  margin-bottom: 14px;
}

.sort-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 7px;
  font-family: -apple-system, sans-serif;
}

.sort-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#questions {
  list-style: none;
}

#questions > li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.q-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.q-text {
  font-size: 1rem;
  line-height: 1.4;
}

.q-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 6px 8px;
  cursor: pointer;
  opacity: 0.5;
}

.delete-btn:hover {
  opacity: 1;
}

.vote-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.vote-btn {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.img-menu-wrap {
  position: relative;
  display: flex;
}

.img-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 1.1rem;
  cursor: pointer;
  height: 100%;
}

.img-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.img-menu[hidden] {
  display: none;
}

.img-menu button {
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.img-menu button:hover {
  background: var(--card-2);
}

.q-img {
  max-width: 100%;
  border-radius: 10px;
  margin-top: 12px;
  display: block;
}

/* ---------- answers ---------- */
.answers {
  list-style: none;
  margin-top: 12px;
}

.answers li {
  background: var(--card-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.reply-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.reply-row input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  padding: 9px 12px;
  font-size: 0.9rem;
}

.reply-row button {
  padding: 9px 14px;
  font-size: 0.85rem;
  background: var(--card-2);
  color: var(--accent);
  border: 1px solid var(--border);
}
