:root {
  --bg: #fff8f2;
  --bg-soft: #fff1e4;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --surface-alt: #fff4e9;
  --surface-muted: #fff7f0;
  --text: #1d2433;
  --muted: #667085;
  --line: rgba(235, 122, 32, 0.14);
  --accent: #f26a1b;
  --accent-deep: #ca4f00;
  --accent-soft: #fff0e1;
  --success: #1f9a63;
  --danger: #ca3d15;
  --shadow: 0 10px 24px rgba(180, 83, 9, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --container: 1180px;
}

html[data-theme="dark"] {
  --bg: #0f141c;
  --bg-soft: #141c27;
  --surface: rgba(21, 28, 38, 0.96);
  --surface-strong: #1a2330;
  --surface-alt: #202b3a;
  --surface-muted: #151d27;
  --text: #edf3fb;
  --muted: #98a8bc;
  --line: rgba(255, 148, 76, 0.18);
  --accent: #ff8a3d;
  --accent-deep: #ffc391;
  --accent-soft: rgba(255, 138, 61, 0.12);
  --success: #56d293;
  --danger: #ff8c72;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

html[data-theme="dark"] {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 14%, transparent), transparent 34%),
    radial-gradient(circle at top right, color-mix(in srgb, #4f7cff 10%, transparent), transparent 28%);
}

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

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.site-shell {
  min-height: 100vh;
}

.container {
  width: min(calc(100% - 28px), var(--container));
  margin: 0 auto;
}

.section {
  padding: 34px 0 52px;
}

.section--accent {
  background: var(--bg-soft);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.nav {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand__mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-family: "Unbounded", sans-serif;
  font-size: 0.88rem;
  box-shadow: none;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand__text strong {
  font-family: "Unbounded", sans-serif;
  font-size: 0.98rem;
  line-height: 1.15;
}

.brand__text span {
  color: var(--muted);
  font-size: 0.88rem;
}

.nav-links,
.nav-actions,
.button-stack,
.footer__links,
.detail-toolbar,
.meta-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-links a {
  color: var(--muted);
}

.nav-links a:hover {
  color: var(--accent);
}

html[data-theme="dark"] .nav-links a,
html[data-theme="dark"] .mobile-nav a {
  color: var(--muted);
}

html[data-theme="dark"] .nav-links a:hover,
html[data-theme="dark"] .mobile-nav a:hover {
  color: var(--text);
}

.nav-toggle {
  display: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 999px;
}

.mobile-nav {
  display: none;
  padding: 0 16px 18px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.mobile-nav.is-open {
  display: grid;
  gap: 12px;
}

.preview-banner {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
}

.preview-banner__inner,
.preview-banner__actions,
.preview-card {
  display: grid;
  gap: 12px;
}

.preview-banner__inner {
  padding: 14px 0;
}

.preview-banner__actions form {
  margin: 0;
}

.card,
.search-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}

.card {
  padding: 22px;
}

.card--soft {
  background: var(--surface-alt);
}

.button,
.user-chip {
  border-radius: 14px;
  padding: 12px 18px;
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.button:hover {
  transform: none;
}

.button--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.button--secondary {
  background: var(--surface-strong);
  color: var(--accent-deep);
  border-color: rgba(242, 106, 27, 0.28);
}

.button--ghost {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--text);
}

.button--open {
  background: var(--surface-muted);
  color: var(--accent-deep);
  border-color: rgba(242, 106, 27, 0.22);
}

.button--danger {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface-strong));
  color: var(--danger);
  border-color: rgba(202, 61, 21, 0.24);
}

.theme-toggle {
  min-width: 132px;
}

.theme-toggle--mobile {
  justify-self: stretch;
}

.button--primary:hover,
.button--secondary:hover,
.button--ghost:hover,
.button--open:hover {
  background-image: none;
  filter: brightness(0.98);
}

html[data-theme="dark"] .button--secondary,
html[data-theme="dark"] .button--ghost,
html[data-theme="dark"] .button--open {
  color: var(--text);
}

.button--wide {
  width: 100%;
}

.button-stack {
  flex-wrap: wrap;
}

.button-stack--horizontal {
  justify-content: flex-start;
}

.button-stack form {
  margin: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--accent-deep);
  border: 1px solid rgba(255, 107, 0, 0.14);
  font-weight: 700;
  font-size: 0.88rem;
}

.pill--soft {
  background: var(--accent-soft);
}

.user-chip {
  background: var(--surface-alt);
  color: var(--accent-deep);
  font-weight: 700;
}

.eyebrow {
  color: var(--accent-deep);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  line-height: 1.12;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.7rem);
}

h2 {
  font-size: clamp(1.4rem, 3vw, 2.3rem);
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0;
  line-height: 1.7;
}

.lead,
.section-copy {
  color: var(--muted);
}

.hero__grid,
.detail-layout,
.admin-layout {
  display: grid;
  gap: 24px;
}

.intro-shell,
.stats-strip,
.detail-simple {
  display: grid;
  gap: 16px;
}

.stats-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.intro-card,
.detail-header {
  display: grid;
  gap: 16px;
}

.search-bar--home {
  margin-bottom: 0;
}

.hero-points,
.sidebar-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  display: grid;
  gap: 10px;
}

.hero-card__stats,
.stats-grid {
  display: grid;
  gap: 16px;
}

.hero-card__stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 18px 0;
}

.stat,
.stat-card {
  padding: 18px;
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.stat-card--simple {
  box-shadow: none;
}

.stat strong,
.stat-card strong {
  display: block;
  font-size: 1.4rem;
  color: var(--accent-deep);
}

.stat span,
.stat-card span {
  color: var(--muted);
}

.section-head {
  margin-bottom: 24px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.section-head--small {
  margin-top: 30px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.cards-grid--subjects {
  align-items: stretch;
}

.subject-list,
.answers-list {
  display: grid;
  gap: 14px;
}

.subject-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.subject-row__main,
.subject-row__side {
  display: grid;
  gap: 10px;
}

.subject-row__title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.subject-row__side {
  justify-items: end;
  min-width: 190px;
}

.subject-row__buttons {
  justify-content: flex-end;
}

.subject-card__meta--right {
  justify-content: flex-end;
}

.subject-card,
.answer-card {
  display: grid;
  gap: 14px;
}

.subject-kind-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--accent-deep);
}

.subject-kind-badge--practice {
  background: var(--accent-soft);
}

.filter-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.answer-card[hidden] {
  display: none;
}

.qa-block,
.qa-section {
  display: grid;
  gap: 10px;
}

.qa-group {
  display: grid;
  gap: 18px;
}

.qa-group__item {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.qa-group__item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.answer-group__title,
.answer-divider-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  font-weight: 800;
  color: var(--accent-deep);
}

.qa-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.qa-question {
  font-size: 1.02rem;
  line-height: 1.75;
  font-weight: 700;
}

.qa-answer-box {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.qa-answer-text {
  line-height: 1.75;
  word-break: break-word;
}

.qa-answer-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  line-height: 1.7;
}

.attachment-preview {
  margin: 0;
  display: grid;
  gap: 10px;
}

.attachment-preview__image {
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.attachment-preview__image--admin {
  max-width: 420px;
}

.attachment-preview__caption {
  color: var(--muted);
  font-size: 0.92rem;
}

.attachment-gallery {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}

.attachment-gallery__item {
  flex: 0 0 min(340px, 82vw);
  display: grid;
  gap: 8px;
  scroll-snap-align: start;
}

.attachment-gallery__image {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.attachment-box--files {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.subject-card__meta,
.answer-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.subject-card p,
.answer-author,
.compact-item span,
.footer__copy,
.setting-note {
  color: var(--muted);
}

.compact-list {
  display: grid;
  gap: 14px;
}

.compact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.compact-item--actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.compact-item__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

.compact-item strong {
  display: block;
  margin-bottom: 4px;
}

.compact-item__arrow {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
}

.search-bar {
  padding: 14px;
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-bar input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid transparent;
  background: var(--surface-strong);
  color: var(--text);
  border-radius: 12px;
  padding: 15px 18px;
}

.search-bar__meta {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 700;
}

.field,
.checkbox-line,
.form-grid {
  display: grid;
  gap: 8px;
}

.field {
  margin-bottom: 16px;
}

.field--compact {
  margin-bottom: 0;
}

.field--required span {
  color: var(--accent-deep);
}

.field span,
.checkbox-line span {
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  padding: 14px 16px;
  color: var(--text);
}

.field textarea {
  resize: vertical;
}

.checkbox-line {
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-bottom: 14px;
}

.checkbox-line--important span {
  color: var(--accent-deep);
}

.checkbox-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.checkbox-tile--legal a {
  color: var(--accent-deep);
  font-weight: 700;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.form-card {
  max-width: 860px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.flash-stack {
  padding-top: 18px;
}

.flash {
  margin-bottom: 10px;
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.flash--success {
  border-color: rgba(31, 154, 99, 0.18);
}

.flash--error {
  border-color: rgba(202, 61, 21, 0.18);
}

.detail-main,
.detail-sidebar,
.admin-main {
  display: grid;
  gap: 20px;
}

.back-link {
  color: var(--accent-deep);
  font-weight: 700;
}

.answer-content {
  line-height: 1.8;
  white-space: normal;
  word-break: break-word;
}

.attachment-box {
  padding-top: 8px;
}

.attachment-strip {
  padding-top: 8px;
}

.attachment-strip__track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 4px 10px;
  scroll-snap-type: x proximity;
}

.attachment-strip__item {
  flex: 0 0 240px;
  margin: 0;
  display: grid;
  gap: 8px;
  scroll-snap-align: start;
}

.attachment-strip__image {
  width: 240px;
  height: 240px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.sidebar-card {
  position: sticky;
  top: 100px;
}

.auth-wrap {
  display: flex;
  justify-content: center;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 24px;
  align-items: start;
}

.auth-card {
  width: min(100%, 480px);
  display: grid;
  gap: 14px;
}

.auth-card--wide {
  width: 100%;
}

.auth-sidecard,
.auth-callout {
  display: grid;
  gap: 14px;
}

.auth-note {
  color: var(--muted);
}

.auth-note a {
  color: var(--accent-deep);
  font-weight: 700;
}

.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination__state {
  color: var(--muted);
}

.empty-card {
  text-align: center;
}

.admin-layout {
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 100px;
  display: grid;
  gap: 8px;
}

.preview-card {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.admin-nav__item {
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--muted);
}

.admin-nav__item.is-active,
.admin-nav__item:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.admin-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.table-wrap {
  overflow-x: auto;
}

.admin-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-thumb {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: var(--accent-deep);
}

.link-button--danger {
  color: var(--danger);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-alt) 68%, transparent);
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.9rem;
}

.logs-list {
  display: grid;
  gap: 12px;
}

.log-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-strong) 84%, transparent);
  border: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.log-item strong {
  color: var(--accent-deep);
}

.log-item span,
.log-item em {
  color: var(--muted);
  font-style: normal;
}

.log-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.log-meta time {
  color: var(--accent-deep);
  font-size: 0.92rem;
}

.footer {
  padding: 32px 0 48px;
  border-top: 1px solid var(--line);
}

html[data-theme="dark"] .footer__legal a:hover,
html[data-theme="dark"] .footer__links a:hover {
  color: var(--text);
}

.footer__grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: start;
}

.footer__links {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.footer__bottom {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.footer__legal {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer__legal a,
.footer__copyright {
  color: var(--muted);
  font-size: 0.92rem;
}

.legal-layout {
  display: flex;
  justify-content: center;
}

.legal-card,
.legal-sections {
  display: grid;
  gap: 18px;
}

.legal-card {
  width: min(100%, 920px);
}

.legal-section {
  display: grid;
  gap: 12px;
}

.legal-updated {
  color: var(--muted);
  font-size: 0.92rem;
}

.legal-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
  line-height: 1.7;
}

.legal-note {
  margin-top: 8px;
}

@media (max-width: 1100px) {
  .hero__grid,
  .detail-layout,
  .admin-layout,
  .admin-panels,
  .footer__grid,
  .stats-strip,
  .subject-row,
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-card,
  .admin-sidebar {
    position: static;
  }

  .subject-row__side {
    justify-items: start;
    min-width: 0;
  }
}

@media (max-width: 860px) {
  .nav-links,
  .nav-actions .button--primary,
  .nav-actions .user-chip {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head,
  .search-bar,
  .form-grid,
  .button-stack--horizontal,
  .detail-toolbar,
  .meta-inline,
  .preview-banner__actions,
  .compact-item--actions,
  .permissions-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .compact-item__main,
  .subject-row__buttons,
  .admin-row-actions {
    width: 100%;
  }

  .footer__bottom {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(calc(100% - 20px), var(--container));
  }

  .section {
    padding: 26px 0 40px;
  }

  .card {
    padding: 18px;
  }

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

  .hero-card__stats,
  .stats-grid,
  .stats-strip {
    grid-template-columns: 1fr;
  }

  .compact-item,
  .compact-item__main {
    flex-direction: column;
    align-items: flex-start;
  }

  .subject-row__buttons,
  .admin-row-actions,
  .button-stack {
    justify-content: flex-start;
  }

  .button,
  .subject-row__buttons .button,
  .compact-item--actions .button {
    width: 100%;
  }

  .nav {
    min-height: 72px;
  }

  .brand__mark {
    width: 42px;
    height: 42px;
  }

  .attachment-strip__item {
    flex-basis: 210px;
  }

  .attachment-strip__image {
    width: 210px;
    height: 210px;
  }
}
