:root {
  --bg: hsl(229 31% 16%);
  --bg-soft: hsl(229 28% 21%);
  --panel: hsla(231, 28%, 24%, 0.82);
  --panel-strong: hsla(231, 30%, 22%, 0.94);
  --border: hsla(220, 40%, 100%, 0.14);
  --text: hsl(220 38% 97%);
  --muted: hsl(223 24% 86%);
  --accent: hsl(271 92% 74%);
  --accent-2: hsl(191 96% 68%);
  --accent-3: hsl(332 88% 72%);
  --success: hsl(151 72% 60%);
  --shadow: 0 24px 80px rgba(5, 8, 20, 0.24);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

:root[data-theme='light'] {
  --bg: hsl(226 100% 98%);
  --bg-soft: hsl(220 40% 96%);
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --border: rgba(71, 85, 105, 0.14);
  --text: hsl(229 33% 17%);
  --muted: hsl(220 14% 42%);
  --accent: hsl(265 84% 62%);
  --accent-2: hsl(193 88% 48%);
  --accent-3: hsl(335 82% 62%);
  --success: hsl(151 60% 42%);
  --shadow: 0 24px 80px rgba(78, 91, 124, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 14%, rgba(132, 103, 255, 0.34), transparent 28%),
    radial-gradient(circle at 78% 10%, rgba(60, 201, 255, 0.24), transparent 24%),
    radial-gradient(circle at 86% 76%, rgba(255, 96, 160, 0.22), transparent 22%),
    linear-gradient(160deg, #161a31 0%, #1b2038 46%, #15192d 100%);
  transition: background 220ms ease, color 220ms ease;
}

html[data-theme='light'],
html[data-theme='light'] body {
  background:
    radial-gradient(circle at 10% 12%, rgba(129, 92, 255, 0.12), transparent 26%),
    radial-gradient(circle at 82% 14%, rgba(33, 178, 255, 0.14), transparent 24%),
    radial-gradient(circle at 86% 78%, rgba(255, 96, 149, 0.12), transparent 20%),
    linear-gradient(160deg, #f6f9ff 0%, #eef3ff 48%, #fdfdff 100%);
}

body {
  padding: 24px;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 36px;
  padding: 42px;
  background:
    linear-gradient(135deg, rgba(44, 52, 82, 0.96), rgba(31, 37, 62, 0.93)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
  box-shadow: 0 28px 80px rgba(11, 16, 32, 0.24);
  isolation: isolate;
}

:root[data-theme='light'] .hero {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(242, 247, 255, 0.92));
}

.hero__topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 760px;
}

.theme-toggle {
  position: relative;
  z-index: 2;
  min-width: 118px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.2);
}

.theme-toggle__label {
  font-weight: 700;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(52, 60, 92, 0.76), rgba(32, 38, 60, 0.82));
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-2);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.04;
}

.hero__description {
  max-width: 600px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}

.hero__glow {
  position: absolute;
  inset: auto;
  border-radius: 999px;
  filter: blur(16px);
  opacity: 0.9;
}

.hero__glow--one {
  top: -24px;
  right: 10%;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(129, 102, 255, 1), transparent 65%);
}

.hero__glow--two {
  bottom: -36px;
  right: 22%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(65, 205, 255, 0.88), transparent 68%);
}

.layout {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.filters-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 24px;
}

.panel__header,
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel__header h2,
.results-toolbar p {
  margin: 0;
}

.ghost-button,
.primary-button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  transition: 180ms ease;
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: white;
  text-decoration: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 36px rgba(118, 112, 255, 0.28);
}

.filters-grid {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.grade-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.grade-tab {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.grade-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(115, 196, 255, 0.34);
}

.grade-tab.is-active {
  border-color: rgba(115, 196, 255, 0.42);
  background: linear-gradient(120deg, rgba(168, 108, 255, 0.32), rgba(90, 207, 255, 0.28));
  box-shadow: 0 14px 30px rgba(76, 110, 255, 0.18);
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(18, 24, 42, 0.78);
  outline: none;
}

:root[data-theme='light'] .field input,
:root[data-theme='light'] .field select {
  background: rgba(255, 255, 255, 0.82);
}

.field input:focus,
.field select:focus {
  border-color: rgba(115, 196, 255, 0.76);
  box-shadow: 0 0 0 4px rgba(115, 196, 255, 0.16);
}

.results-section {
  min-width: 0;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 18px;
}

.result-group {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: calc(var(--radius-lg) + 6px);
  padding: 20px;
  background: linear-gradient(180deg, rgba(58, 68, 104, 0.92), rgba(34, 40, 66, 0.98));
  box-shadow: 0 20px 44px rgba(8, 12, 24, 0.24);
  color: var(--text);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.result-group:hover {
  transform: translateY(-4px);
  border-color: rgba(115, 196, 255, 0.36);
  box-shadow: 0 24px 48px rgba(8, 12, 24, 0.28);
}

:root[data-theme='light'] .result-group {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(242, 246, 255, 0.96));
  box-shadow: 0 20px 40px rgba(108, 124, 163, 0.14);
}

.result-group__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.result-group__header h3 {
  margin: 4px 0 0;
  font-size: 1.08rem;
  line-height: 1.5;
  color: var(--text);
}

.result-group__eyebrow {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.result-group__count {
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.result-group__meta {
  margin-top: 14px;
}

.result-group__stack {
  position: relative;
  min-height: 132px;
  margin-top: 20px;
}

.result-group__stack-item {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(46, 54, 82, 0.95), rgba(29, 35, 56, 0.98));
  color: var(--text);
  box-shadow: 0 18px 36px rgba(8, 12, 24, 0.18);
  overflow: hidden;
}

:root[data-theme='light'] .result-group__stack-item {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(244, 247, 255, 0.98));
}

.result-group__stack-item strong {
  display: -webkit-box;
  display: box;
  overflow: hidden;
  font-size: 0.94rem;
  line-height: 1.45;
  color: var(--text);
  text-overflow: ellipsis;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.result-group__stack-item--1 {
  top: 0;
  z-index: 3;
}

.result-group__stack-item--2 {
  top: 18px;
  left: 12px;
  right: 12px;
  z-index: 2;
  opacity: 0.78;
}

.result-group__stack-item--3 {
  top: 36px;
  left: 24px;
  right: 24px;
  z-index: 1;
  opacity: 0.56;
}

.result-group--single .result-group__stack {
  min-height: auto;
}

.result-group--single .result-group__stack-item--2,
.result-group--single .result-group__stack-item--3 {
  display: none;
}

.result-group--single .result-group__stack-item {
  position: relative;
}

.result-group__footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.84rem;
}

.result-group__footer span {
  flex: 1 1 0;
  min-width: 0;
}

.result-group__footer span:last-child {
  text-align: right;
}

.result-card__type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-2);
}

.result-card__time {
  font-size: 0.82rem;
  color: var(--muted);
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.result-meta span,
.detail-badge {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.76rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.group-explorer {
  position: fixed;
  z-index: 35;
  width: min(720px, calc(100vw - 28px));
}

.group-explorer__content {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(42, 48, 76, 0.96), rgba(26, 31, 52, 0.98));
  backdrop-filter: blur(18px);
  box-shadow: 0 26px 72px rgba(8, 12, 24, 0.28);
}

:root[data-theme='light'] .group-explorer__content {
  background: rgba(255, 255, 255, 0.97);
}

.group-explorer__label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.group-explorer__list {
  display: grid;
  gap: 10px;
}

.group-explorer__sidebar,
.group-explorer__preview,
.group-explorer__item,
.group-explorer__item-top {
  min-width: 0;
}

.group-explorer__item {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  appearance: none;
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.group-explorer__item:hover,
.group-explorer__item.is-active {
  border-color: rgba(115, 196, 255, 0.36);
  background: rgba(115, 196, 255, 0.1);
  transform: translateY(-1px);
}

.group-explorer__item strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  line-height: 1.45;
  text-overflow: ellipsis;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.group-explorer__item span:last-child {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.group-explorer__item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.group-explorer__item-top .result-card__time {
  flex-shrink: 0;
  white-space: nowrap;
}

.group-explorer__preview-body {
  min-width: 0;
  min-height: 320px;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: hidden;
}

.group-explorer__preview-body .preview-page,
.group-explorer__preview-body .preview-docx {
  width: 100%;
  max-width: 100%;
  justify-self: stretch;
}

.hover-preview {
  position: fixed;
  z-index: 30;
  width: min(320px, calc(100vw - 24px));
  pointer-events: none;
}

.hover-preview__content,
.detail-modal__surface {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(48, 56, 84, 0.95), rgba(31, 37, 60, 0.96));
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 72px rgba(8, 12, 24, 0.22);
}

:root[data-theme='light'] .hover-preview__content,
:root[data-theme='light'] .detail-modal__surface {
  background: rgba(255, 255, 255, 0.94);
}

.hover-preview__content {
  padding: 14px;
}

.hover-preview__label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.hover-preview__body,
.detail-preview-pages {
  display: grid;
  gap: 14px;
}

.preview-page,
.preview-docx {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(241, 244, 255, 0.95));
  color: #20263d;
}

.preview-page canvas {
  width: 100%;
  height: auto;
  display: block;
}

.preview-docx {
  padding: 18px;
  max-height: 480px;
  overflow: hidden;
}

.detail-modal {
  width: min(1180px, calc(100vw - 32px));
  border: none;
  padding: 0;
  background: transparent;
}

.detail-modal::backdrop {
  background: rgba(12, 16, 30, 0.52);
  backdrop-filter: blur(8px);
}

.detail-modal__surface {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  padding: 24px;
}

.detail-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.detail-modal__meta h2 {
  margin: 12px 0 10px;
  line-height: 1.35;
  color: var(--text);
}

.detail-modal__meta p {
  color: var(--muted);
  line-height: 1.7;
}

.detail-actions {
  margin-top: 18px;
}

.detail-actions--stack {
  display: grid;
  gap: 10px;
}

.detail-actions--stack .primary-button {
  justify-self: center;
  min-width: min(260px, 100%);
  text-align: center;
}

.detail-action-button {
  width: 100%;
}

.detail-action-button--danger {
  border-color: rgba(255, 126, 178, 0.28);
  background: rgba(255, 126, 178, 0.14);
}

.detail-admin-status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
}

.detail-admin-status[data-state='success'] {
  border-color: rgba(73, 211, 158, 0.3);
  background: rgba(73, 211, 158, 0.12);
}

.detail-admin-status[data-state='error'] {
  border-color: rgba(255, 126, 178, 0.3);
  background: rgba(255, 126, 178, 0.12);
}

.detail-admin-status[data-state='warning'] {
  border-color: rgba(255, 202, 113, 0.3);
  background: rgba(255, 202, 113, 0.12);
}

.detail-action-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.empty-state {
  padding: 26px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    position: static;
  }

  .grade-tabs {
    gap: 8px;
  }

  .grade-tab {
    padding: 9px 12px;
  }

  .detail-modal__surface {
    grid-template-columns: 1fr;
  }

  .hero__topbar {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  body {
    padding: 14px;
  }

  .hero,
  .filters-panel,
  .result-group,
  .result-card {
    padding: 18px;
  }

  .result-group__header,
  .result-card__top,
  .result-card__footer {
    flex-direction: column;
    align-items: flex-start;
  }

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