/* Page chrome only — component styles live in shadow DOM */

* {
  box-sizing: border-box;
}

:root {
  --bg: #161616;
  --bg-soft: #222222;
  --text: #d4d4d4;
  --muted: #8a8a8a;
  --border: #333;
  --link: #ff6600;
  --link-dim: #ff8533;
  --title: #ececec;
  --danger: #e07070;
  --ok: #7cba6f;
  --radius: 14px;
  --radius-sm: 10px;
}

html {
  height: 100%;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Verdana, Geneva, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
}

a:visited {
  color: var(--link-dim);
}

#wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 16px 0;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
}

header {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin: 0 0 20px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 48px;
}

header a.site-title {
  font-weight: bold;
  color: var(--title);
  text-decoration: none;
  margin-right: 4px;
}

header nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

header nav a {
  text-decoration: none;
  color: var(--text);
}

header nav a:hover {
  color: var(--link);
}

.nav-form {
  display: inline;
  margin: 0;
}

.nav-form button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}

.nav-form button:hover {
  color: var(--link);
}

h1 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--title);
  margin: 0 0 10px;
}

h2 {
  font-size: 12px;
  font-weight: 700;
  margin: 24px 0 12px;
  padding: 0;
  border: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

p {
  margin: 0 0 10px;
}

.muted,
.intro {
  color: var(--muted);
  line-height: 1.6;
}

.home-intro {
  margin-bottom: 22px;
}

.home-intro .intro {
  max-width: 42em;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.list-head h1 {
  margin: 0;
}

.sort-switch {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
}

.sort-btn {
  display: inline-block;
  padding: 5px 12px;
  font-size: 12px;
  text-decoration: none;
  color: var(--muted);
}

.sort-btn:visited {
  color: var(--muted);
}

.sort-btn:hover {
  color: var(--link);
}

.sort-btn.is-active {
  color: var(--title);
  background: #2c2c2c;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pager {
  margin-top: 16px;
  padding-top: 12px;
  color: var(--muted);
}

.pager a {
  margin-right: 12px;
}

.flashes {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}

.flash {
  margin: 0 0 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.flash-error,
.flash-danger {
  color: var(--danger);
}

.flash-ok {
  color: var(--ok);
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--title);
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
}

.btn:visited {
  color: var(--title);
}

.btn:hover {
  border-color: var(--link);
  color: var(--link);
}

.btn-primary {
  border-color: var(--link);
  color: var(--link);
}

.crumb {
  font-size: 13px;
  margin-bottom: 12px;
}

.edit-link {
  margin-top: 14px;
}

.answers {
  margin-top: 22px;
}

.answers ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.answers li {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.answers .q {
  color: var(--title);
  line-height: 1.5;
}

.answers .a {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
}

.after-result {
  margin-top: 16px;
  color: var(--muted);
}

auth-form h1 {
  margin-bottom: 14px;
}

auth-form form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

auth-form label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

auth-form label span em {
  font-style: normal;
  color: #6e6e6e;
}

auth-form input[type="text"],
auth-form input[type="email"],
auth-form input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #1c1c1c;
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}

auth-form input:focus {
  outline: none;
  border-color: var(--link);
}

auth-form .btn {
  margin-top: 4px;
  align-self: flex-start;
}

.form-error {
  color: var(--danger);
  margin: 0 0 12px;
}

.auth-alt {
  margin-top: 16px;
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 16px 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

quiz-card:not(:defined) {
  display: block;
  min-height: 220px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

quiz-section:not(:defined),
quiz-stats:not(:defined),
quiz-hero:not(:defined),
quiz-wizard:not(:defined),
result-view:not(:defined),
auth-form:not(:defined),
quiz-builder:not(:defined),
attempt-row:not(:defined),
share-box:not(:defined),
progress-bar:not(:defined) {
  display: block;
  min-height: 48px;
}

@media (max-width: 560px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    flex-wrap: wrap;
  }

  header nav {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .list-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}
