/* Question Runner — one small stylesheet for both pages. */

:root {
  --bg: #f5f5f4;
  --card: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #e7e5e4;
  --error: #b91c1c;
  --saved: #15803d;
  font-size: 18px;
}

* {
  box-sizing: border-box;
}

/* class-based display rules must not override the hidden attribute */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

/* ---------- cards & layout ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body > .card {
  max-width: 34rem;
  margin: 8vh auto 2rem;
  padding: 2rem;
}

.narrow {
  max-width: 22rem !important;
}

/* ---------- form controls ---------- */

button {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  width: 100%;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.link {
  background: none;
  color: var(--accent);
  width: auto;
  padding: 0.4rem 0.6rem;
}

button.link:hover {
  background: none;
  text-decoration: underline;
}

input,
textarea,
select {
  font: inherit;
  width: 100%;
  padding: 0.8rem;
  margin: 0.4rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

label {
  font-weight: 600;
}

/* ---------- visitor page ---------- */

#prompt {
  margin-bottom: 1.25rem;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.option {
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
  text-align: left;
}

.option:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--border);
}

.option.selected {
  border-color: var(--accent);
  background: #eff6ff;
}

.error {
  color: var(--error);
  margin: 0 0 0.75rem;
}

.saved {
  color: var(--saved);
  margin: 0 0 0.75rem;
}

.muted {
  color: var(--muted);
  margin: 0;
}

/* ---------- admin panel ---------- */

.admin {
  max-width: 40rem;
  margin: 0 auto 3rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h1 {
  margin: 0;
}

.visitors ul,
.answers ul,
#answer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.visitor-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  text-align: left;
}

.visitor-item:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--border);
}

.visitor-item.selected {
  border-color: var(--accent);
  background: #eff6ff;
}

.visitor-item .muted {
  margin-left: auto;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d6d3d1;
  flex-shrink: 0;
}

.dot.online {
  background: #22c55e;
}

.current-question {
  margin-bottom: 1rem;
}

.label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.question-text {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.nav {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 1.25rem;
}

.nav button {
  width: auto;
  flex-shrink: 0;
}

.nav select {
  margin: 0;
  min-width: 0;
  flex: 1;
}

#answer-list li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  background: #fff;
}

#answer-list p {
  margin: 0.2rem 0;
}

.answer-question {
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  body > .card {
    margin: 3vh auto 1rem;
    padding: 1.25rem;
  }

  .nav {
    flex-wrap: wrap;
  }

  .nav select {
    order: -1;
    flex-basis: 100%;
  }
}

/* ---------- HTML page mode (visitor) ---------- */

/* Full-page templates render into this container. */
#page-html {
  width: 100%;
  min-height: 40vh;
}

/* The panel-wide control rules above (button/input widths) must not stretch
   template controls — restore natural widths inside the injected page so
   templates look the same as they do standalone. */
#page-html button {
  width: auto;
}
#page-html input,
#page-html textarea,
#page-html select {
  width: auto;
}

/* While a custom page is shown, the built-in card gets out of the way:
   transparent, no border/shadow, so it only carries status messages. */
body.page-mode > .card {
  background: transparent;
  border: none;
  box-shadow: none;
  margin-top: 1rem;
  max-width: 34rem;
}

body.page-mode {
  background: var(--bg);
}

/* Question UI injected into a [data-panel-answer] marker */
[data-panel-answer] .input-area {
  margin: 0.5rem 0 0.75rem;
}

[data-panel-answer] h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}
