@import url("https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=Crimson+Pro:wght@500;600;700&display=swap");

:root {
  --ink: #12263a;
  --ink-soft: #3d5163;
  --muted: #5c6b73;
  --paper: #f4efe6;
  --paper-deep: #ebe4d6;
  --card: #fffcf7;
  --line: #d9cfc0;
  --line-strong: #c4b6a2;
  --teal: #0f5c56;
  --teal-deep: #0a3f3b;
  --teal-mid: #157a72;
  --teal-soft: #d7efe9;
  --gold: #b45309;
  --gold-soft: #f3e0c8;
  --exam: #9f1239;
  --official: #1d4ed8;
  --course: #0f766e;
  --lecture: #b45309;
  --quiz: #6d28d9;
  --danger: #b91c1c;
  --ok: #047857;
  --shadow: 0 10px 30px rgba(18, 38, 58, 0.08);
  --shadow-lg: 0 24px 50px rgba(18, 38, 58, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --header: 72px;
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
  --serif: "Crimson Pro", "Times New Roman", serif;
  --focus: 0 0 0 3px rgba(15, 92, 86, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(21, 122, 114, 0.12), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(180, 83, 9, 0.08), transparent 45%),
    var(--paper);
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--teal);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button,
a,
.explorer-item,
.explorer-sub,
.doc-card,
.subject-card {
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.72;
  cursor: wait;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--teal);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 100;
}

.skip:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header);
  overflow: visible;
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--teal-deep) 92%, black);
  color: #f6f1e8;
  box-shadow: 0 8px 24px rgba(10, 63, 59, 0.28);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  flex-shrink: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(160deg, #1d9b90, #0f5c56);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-text span {
  font-size: 0.72rem;
  opacity: 0.78;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.nav-link {
  color: rgba(246, 241, 232, 0.82);
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.nav-link:hover,
.nav-link.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn,
.menu-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  min-height: 44px;
  white-space: nowrap;
  flex-shrink: 0;
}

.user-menu {
  position: relative;
  flex-shrink: 0;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  min-height: 44px;
}

.user-menu-btn svg {
  opacity: 0.8;
  transition: transform 160ms ease;
}

.user-menu.is-open .user-menu-btn svg {
  transform: rotate(180deg);
}

.user-menu-card {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 240px;
  padding: 12px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

.user-menu.is-open .user-menu-card {
  display: block;
}

.user-menu-name {
  margin: 0;
  font-weight: 700;
}

.user-menu-role {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.user-menu-link,
.user-menu-logout {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  font-weight: 600;
}

.user-menu-link:hover {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.user-menu-logout {
  color: var(--danger);
}

.user-menu-logout:hover {
  background: #fde8ee;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.82rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--gold);
  color: #fff;
}

.btn-primary:hover {
  background: #9a3f07;
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: currentColor;
}

.btn-light {
  background: #fff;
  color: var(--teal-deep);
  border-color: var(--line);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-teal {
  background: var(--teal);
  color: #fff;
}

.menu-toggle {
  display: none;
}

main {
  flex: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  align-items: center;
  padding: 12px 0 8px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
h3,
.serif {
  font-family: var(--serif);
  letter-spacing: -0.02em;
}

.hero h1 {
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  line-height: 1.12;
  margin: 14px 0 12px;
}

.lede {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0 0 22px;
}

.search-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px;
  box-shadow: var(--shadow);
  position: relative;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-row .btn {
  flex-shrink: 0;
}

.search-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border: 0;
  background: transparent;
  padding: 0 14px;
  font-size: 1rem;
  color: var(--ink);
}

.search-row input::placeholder {
  color: #8a7c6c;
}

.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 20;
  display: none;
}

.suggest.is-open {
  display: block;
}

.suggest button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 12px 16px;
  min-height: 48px;
  color: var(--ink);
}

.suggest button:hover,
.suggest button.is-active {
  background: var(--paper-deep);
}

.hero-art {
  background:
    linear-gradient(160deg, rgba(15, 92, 86, 0.08), rgba(180, 83, 9, 0.08)),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  min-height: 280px;
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.stat-card b {
  display: block;
  font-size: 1.4rem;
  font-family: var(--serif);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.section {
  margin-top: 42px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.7rem;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.subject-grid,
.doc-grid,
.feature-grid {
  display: grid;
  gap: 14px;
}

.subject-grid {
  grid-template-columns: repeat(5, 1fr);
}

.doc-grid {
  grid-template-columns: repeat(3, 1fr);
}

.feature-grid {
  grid-template-columns: repeat(4, 1fr);
}

.subject-card,
.doc-card,
.feature-card,
.panel,
.login-card,
.empty,
.admin-table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.subject-card {
  padding: 16px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: inherit;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.subject-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.subject-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
}

.subject-card strong {
  font-size: 1rem;
}

.subject-card span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: auto;
}

.doc-card {
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 230px;
  color: inherit;
  transition: transform 180ms ease;
}

.doc-card:hover {
  transform: translateY(-3px);
}

.doc-card h3 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.3;
}

.doc-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  margin-top: auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.doc-card-foot span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--paper-deep);
  color: var(--ink-soft);
  border: 1px solid transparent;
}

.chip.exam { background: #fde8ee; color: var(--exam); }
.chip.official { background: #e8efff; color: var(--official); }
.chip.course { background: #ddf4ef; color: var(--course); }
.chip.lecture { background: #f8ead8; color: var(--lecture); }
.chip.quiz { background: #eee7fb; color: var(--quiz); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.filter-search {
  position: relative;
  flex: 1 1 280px;
  min-width: min(100%, 240px);
}

.filter-search input {
  width: 100%;
  padding-right: 44px;
}

.filter-search-ico {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: grid;
  place-items: center;
  pointer-events: none;
}

.filter-bar select,
.filter-bar input,
.form-grid input,
.form-grid select,
.form-grid textarea,
.login-card input {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 0.95rem;
}

.filter-bar select,
.filter-bar input {
  min-width: 150px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.feature-card {
  padding: 18px;
}

.feature-card h3 {
  margin: 12px 0 6px;
  font-size: 1.15rem;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--teal-soft);
  color: var(--teal);
  display: grid;
  place-items: center;
}

.page-head {
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 8px 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.crumb {
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crumb a {
  color: var(--teal-mid);
}

.detail {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr;
  gap: 20px;
}

.panel {
  padding: 22px;
}

.about-lead {
  margin-bottom: 18px;
}

.about-lead p {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 72ch;
}

.about-lead p + p {
  margin-top: 12px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 18px;
}

.about-grid h2 {
  font-size: 1.25rem;
  margin: 10px 0 8px;
}

.about-grid p {
  margin: 0;
  color: var(--ink-soft);
}

.about-body h2 {
  font-size: 1.35rem;
  margin: 22px 0 10px;
}

.about-body h2:first-child {
  margin-top: 0;
}

.about-body p,
.about-body li {
  color: var(--ink-soft);
  max-width: 72ch;
}

.about-steps {
  margin: 0;
  padding-left: 1.2rem;
}

.about-steps li {
  margin: 8px 0;
}

.about-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 800px) {
  .about-grid {
    grid-template-columns: 1fr;
  }
}

#app:focus,
#app:focus-visible {
  outline: none;
  box-shadow: none;
}

.skel-card,
.skel-line,
.skel-preview {
  background: linear-gradient(90deg, var(--paper-deep) 25%, #fff 50%, var(--paper-deep) 75%);
  background-size: 200% 100%;
  animation: skel 1.2s ease-in-out infinite;
  border-radius: 14px;
}

.skel-card {
  min-height: 160px;
  border: 1px solid var(--line);
}

.skel-line {
  height: 28px;
  width: 60%;
  margin-bottom: 16px;
}

.skel-preview {
  min-height: 320px;
  margin: 12px 0;
}

@keyframes skel {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skel-card, .skel-line, .skel-preview { animation: none; }
}

.preview-stage {
  position: relative;
  min-height: 72vh;
}

.preview-wait {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  gap: 10px;
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-size: 0.95rem;
}

.preview-stage.is-ready .preview-wait {
  display: none;
}

.drive-frame {
  width: 100%;
  min-height: 72vh;
  height: 72vh;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
}

.doc-preview {
  white-space: pre-wrap;
  font-family: var(--serif);
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 20px;
  min-height: 280px;
  line-height: 1.7;
}

.side-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-list a {
  color: inherit;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.login-wrap {
  min-height: 60vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
}

.login-card h1 {
  margin: 8px 0 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
}

.demo-box {
  margin-top: 16px;
  background: var(--paper);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid textarea {
  min-height: 180px;
  resize: vertical;
}

.admin-table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

th {
  background: var(--paper-deep);
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.dash-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.dash-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.dash-card b {
  display: block;
  font-family: var(--serif);
  font-size: 1.8rem;
  line-height: 1.2;
  margin-top: 4px;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  z-index: 80;
  opacity: 0;
  transform: translateY(8px);
  transition: 200ms ease;
}

.toast.is-on {
  opacity: 1;
  transform: none;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 36px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-mark {
  color: var(--teal);
  display: grid;
  place-items: center;
}

.footer-brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--teal-deep);
  line-height: 1.2;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
}

.footer-nav a {
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-nav a:hover {
  color: var(--gold);
}

.pwd-wrap {
  position: relative;
}

.pwd-wrap input {
  width: 100%;
  padding-right: 48px;
}

.pwd-wrap .toggle-pwd {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  min-height: 40px;
  color: var(--muted);
}

.drawer {
  display: none;
}

.required {
  color: var(--danger);
}

.alert {
  background: #fde8ee;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  display: none;
}

.alert.is-on {
  display: block;
}

.pager {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.pager button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.pager button.is-active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

@media (max-width: 1024px) {
  .subject-grid { grid-template-columns: repeat(3, 1fr); }
  .doc-grid, .feature-grid, .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .hero, .detail { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .header-nav { display: none; }
  .menu-toggle { display: grid; }
  .header-tools > .btn-primary { display: none; }
  .brand-text span { display: none; }
  .user-chip > span:not(.avatar) { display: none; }
  .user-chip .btn { display: none; }
  .user-menu-label { display: none; }
  .subject-grid, .doc-grid, .feature-grid, .dash-grid, .form-grid, .stat-grid {
    grid-template-columns: 1fr;
  }
  .user-chip span:last-child { display: none; }
  .drawer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    top: var(--header);
    left: 0;
    right: 0;
    background: var(--teal-deep);
    padding: 12px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
  }
  .drawer.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
  .drawer a,
  .drawer button {
    color: #fff;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 10px;
    background: none;
    border: 0;
    font-size: 1rem;
    width: 100%;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.explorer {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 70vh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.explorer-side {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
}

.explorer-kicker {
  margin: 0 8px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.explorer-subs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.explorer-sub {
  text-align: left;
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  color: var(--ink);
  font-weight: 600;
}

.explorer-sub:hover,
.explorer-sub.is-on {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.explorer-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.explorer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 70%, white);
}

.explorer-toolbar .btn {
  transition: transform 160ms ease, background 160ms ease;
}

.explorer-toolbar .btn:active {
  transform: scale(0.97);
}

.explorer-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.quota {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(280px, 100%);
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.quota-track {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--paper-deep);
  overflow: hidden;
}

.quota-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--teal);
}

.quota b {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.ex-path {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  min-height: 44px;
}

.ex-path-item {
  border: 0;
  background: none;
  color: var(--teal);
  font-weight: 600;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 8px;
}

.ex-path-item:hover {
  background: var(--teal-soft);
}

.ex-path-sep {
  color: var(--muted);
  padding: 0 2px;
}

.explorer-drop {
  flex: 1;
  min-height: 360px;
  padding: 12px;
}

.explorer-hint {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 2px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  background: color-mix(in srgb, var(--teal-soft) 50%, white);
}

.explorer-drop.is-over {
  outline: 2px dashed var(--teal);
  background: var(--teal-soft);
}

.explorer-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.explorer-headrow,
.explorer-item {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 90px 90px 100px 150px;
  align-items: center;
  gap: 8px;
  text-align: left;
  width: 100%;
}

.explorer-headrow {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.explorer-headrow span:last-child,
.explorer-item-when {
  text-align: right;
}

.explorer-item {
  background: #fff;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 48px;
  color: inherit;
  transition: background 160ms ease, border-color 160ms ease;
}

.explorer-item:hover {
  background: var(--teal-soft);
}

.explorer-item.is-on {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: var(--focus);
}

.explorer-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.explorer-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-item-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.explorer-empty {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.explorer-loading {
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.explorer-loading-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 0;
  padding: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.explorer-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--teal-soft);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.explorer-skel-row {
  pointer-events: none;
}

.explorer-skel-icon,
.explorer-skel-bar {
  display: block;
  background: linear-gradient(90deg, var(--paper-deep) 25%, #fff 50%, var(--paper-deep) 75%);
  background-size: 200% 100%;
  animation: skel 1.2s ease-in-out infinite;
}

.explorer-skel-icon {
  width: 22px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
}

.explorer-skel-bar {
  height: 10px;
  border-radius: 99px;
  max-width: 220px;
}

.explorer-skel-meta {
  width: 72%;
  max-width: none;
  justify-self: start;
}

.explorer-skel-meta.explorer-item-when {
  justify-self: end;
  width: 80%;
}

@media (prefers-reduced-motion: reduce) {
  .explorer-spinner { animation: none; border-top-color: var(--teal); }
  .explorer-skel-icon, .explorer-skel-bar { animation: none; }
}

.explorer-preview {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.explorer-preview-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.explorer-preview iframe {
  flex: 1;
  border: 0;
  min-height: 420px;
  background: #fff;
}

@media (max-width: 900px) {
  .explorer {
    grid-template-columns: 1fr;
  }
  .explorer-headrow,
  .explorer-item {
    grid-template-columns: minmax(0, 1fr) 88px;
  }
  .explorer-headrow span:nth-child(n+3),
  .explorer-item .explorer-item-meta:nth-of-type(n+2) {
    display: none;
  }
  .upload-row {
    grid-template-columns: 1fr;
  }
  .quota {
    width: 100%;
    margin-left: 0;
  }
}

.upload-dialog {
  width: min(600px, calc(100% - 32px));
  border: 0;
  border-radius: 24px;
  padding: 32px;
  background: #fcf9f0;
  color: #1c1b1b;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.upload-dialog::backdrop {
  background: rgba(156, 163, 175, 0.8);
}

.upload-dialog-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.upload-dialog h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #1c1b1b;
}

.upload-dialog-head p {
  margin: 0;
  font-size: 0.875rem;
  color: #484747;
}

.upload-dialog form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.upload-dialog .field {
  margin: 0;
  gap: 6px;
}

.upload-dialog label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  font-weight: 700;
  color: #1c1b1b;
  margin: 0;
}

.upload-dialog input,
.upload-dialog select {
  width: 100%;
  min-height: 40px;
  font-size: 0.875rem;
}

.upload-dialog input[name="title"] {
  border: 2px solid #8eaaa6;
  border-radius: 0;
  background: #fcf9f0;
  padding: 8px 12px;
  box-shadow: none;
}

.upload-dialog input[name="title"]:focus {
  border-color: var(--teal-deep);
  box-shadow: none;
}

.upload-dialog select {
  border: 1px solid #7a7a7a;
  border-radius: 0;
  background-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a7a7a' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  padding: 8px 36px 8px 12px;
  box-shadow: none;
}

.upload-dialog select:focus {
  border-color: var(--teal-deep);
  box-shadow: 0 0 0 1px var(--teal-deep);
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.upload-pick {
  width: 100%;
  margin: 8px 0 0;
  padding: 24px 16px;
  min-height: 128px;
  border: 0;
  border-radius: 12px;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23CACACA' stroke-width='3' stroke-dasharray='10%2c 10' stroke-linecap='square'/%3e%3c/svg%3e");
  color: inherit;
  text-align: center;
}

.upload-pick:hover {
  background-color: #dddad1;
}

.upload-pick strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
  font-weight: 700;
  color: #1c1b1b;
}

.upload-pick span,
.upload-pick em {
  display: block;
  color: #484747;
  font-size: 0.875rem;
  font-style: normal;
}

.upload-pick em:not(:empty) {
  margin-top: 8px;
  color: var(--teal-deep);
  font-weight: 700;
}

.upload-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.upload-cancel,
.upload-submit {
  min-height: 42px;
  padding: 10px 24px;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 700;
}

.upload-cancel {
  border: 1px solid #7a7a7a;
  background: transparent;
  color: var(--teal-deep);
}

.upload-cancel:hover {
  background: #dddad1;
}

.upload-submit {
  border: 0;
  background: #a95200;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.upload-submit:hover {
  background: #8c4400;
}

.upload-submit:disabled {
  opacity: 0.72;
  cursor: wait;
}

.ex-menu {
  position: fixed;
  z-index: 90;
  min-width: 168px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.ex-menu button {
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  color: inherit;
}

.ex-menu button:hover {
  background: var(--teal-soft);
}

.ex-menu button[data-menu="delete"]:hover {
  background: #fde8ee;
  color: var(--danger);
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.admin-board {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.admin-pane {
  padding: 18px;
  min-height: 320px;
}

.admin-mons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-mon {
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  min-height: 56px;
}

.admin-mon:hover {
  border-color: var(--teal-mid);
  background: var(--teal-soft);
}

.admin-mon-bar {
  width: 6px;
  align-self: stretch;
  border-radius: 99px;
}

.admin-mon-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-mon-body strong {
  font-size: 0.98rem;
}

.admin-mon-body span {
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-mon-go {
  color: var(--teal);
  font-weight: 600;
  font-size: 0.88rem;
}

.admin-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.admin-file-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  color: inherit;
}

.admin-file-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

@media (max-width: 900px) {
  .admin-board {
    grid-template-columns: 1fr;
  }
}

@media print {
  .site-header, .footer, .btn, .filter-bar, .toolbar, .explorer-toolbar { display: none !important; }
  body, main { background: #fff; width: auto; }
  .doc-preview { border: 0; }
}
