:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-alt: #f2f6fd;
  --border: #e6edf7;

  --text-main: #122845;
  --text-muted: #5f7697;
  --text-soft: #88a0bf;

  --primary: #4a84dc;
  --primary-dark: #366fc8;
  --primary-light: #eaf2ff;

  --success: #20a06f;
  --warning: #d18b2a;
  --danger: #d14d56;

  /* Radii: cards 16, buttons/inputs 10 (per UI spec) */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(18, 45, 86, 0.05);
  --shadow-md: 0 10px 24px rgba(49, 92, 157, 0.1);
  /* Fewer, cleaner shadows */
  --shadow-card: 0 10px 26px rgba(15, 23, 42, 0.08);
  --transition: 140ms ease;

  --font-base: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --content-max-width: 1200px;
  --content-gutter: 48px;
}

[hidden] {
  display: none !important;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-base);
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* layout */
.app-shell {
  width: min(var(--content-max-width), calc(100vw - var(--content-gutter)));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 0 12px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(226, 232, 240, 0.75);
}

/* Hide header content when mobile nav is open */
body.mobile-nav-open .app-header .header-main,
body.mobile-nav-open .app-header .header-actions {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Keep hamburger button clickable when mobile nav is open */
body.mobile-nav-open .app-header .header-mobile-toggle {
  opacity: 1;
  pointer-events: auto;
  z-index: 70;
  position: relative;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--brand-logo-url, url("/static/assets/platform-logo-placeholder.svg")) center / cover no-repeat;
  color: transparent;
  font-size: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: pointer;
}

.header-title,
.header-title-group h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.header-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Resource pages (flat filters + modal preview) */
.respage {
  padding: 8px 0 30px;
}

.respage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}

.respage-title {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.respage-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.respage-search {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.respage-search .input {
  width: min(360px, 64vw);
}

.res-filters {
  background: var(--surface);
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

.res-filter-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 0;
}

.res-filter-row+.res-filter-row {
  border-top: 1px dashed rgba(226, 232, 240, 0.9);
}

.res-filter-label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 6px;
}

.res-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.res-chip {
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}


.res-chip.active {
  background: rgba(30, 58, 138, 0.14);
  border-color: rgba(30, 58, 138, 0.26);
  color: var(--text-main);
}

.res-list {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.res-card {
  background: var(--surface);
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
  overflow: hidden;
  min-height: 122px;
}

.res-card:hover {
  box-shadow: var(--shadow-card);
  border-color: rgba(226, 232, 240, 0.95);
}

.res-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.res-card-title {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.res-card-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-soft);
  font-size: 12px;
}

.res-type {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(30, 58, 138, 0.1);
  border: 1px solid rgba(30, 58, 138, 0.18);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.res-empty {
  margin: 18px 0 6px;
  padding: 30px 18px;
  text-align: center;
  color: var(--text-muted);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.7);
  border: 1px dashed rgba(226, 232, 240, 0.9);
}

.res-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.46);
}

.res-modal.open {
  display: flex;
}

.res-modal-card {
  width: min(1120px, 100%);
  height: min(82vh, 880px);
  background: var(--surface);
  border-radius: 6px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.res-modal-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(248, 251, 255, 0.7);
}

.res-modal-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.res-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.res-modal-body {
  flex: 1;
  overflow: auto;
  background: var(--surface);
}

.res-docx {
  padding: 20px 22px 28px;
}

.res-modal-close {
  min-width: 40px;
  padding: 8px 10px;
}

/* Fullscreen Preview Modal */
.preview-fullscreen .res-modal-card {
  width: 95vw;
  max-width: 95vw;
  height: 92vh;
  max-height: 92vh;
  border-radius: 6px;
}

.preview-fullscreen .res-modal-head {
  padding: 14px 20px;
  background: var(--surface-soft);
}

.preview-fullscreen .res-modal-head h3 {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-fullscreen .res-modal-body {
  padding: 0;
  background: var(--bg);
}

.preview-fullscreen .resource-preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.preview-fullscreen .res-docx {
  padding: 32px 48px 48px;
  max-width: 900px;
  margin: 0 auto;
  background: var(--surface);
  min-height: 100%;
  box-shadow: var(--shadow-card);
}

/* Preview unavailable state */
.preview-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: #64748b;
  font-size: 15px;
  text-align: center;
  padding: 40px;
}

.preview-unsupported svg {
  opacity: 0.5;
}

@media (max-width: 1080px) {
  .res-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .res-filter-row {
    grid-template-columns: 1fr;
  }

  .res-filter-label {
    padding-top: 0;
  }

  .res-list {
    grid-template-columns: 1fr;
  }

  .res-modal {
    padding: 12px;
  }

  .res-modal-card {
    height: min(86vh, 920px);
    border-radius: 8px;
  }

  .respage-search {
    justify-content: flex-start;
  }

  .respage-search .input {
    width: 100%;
  }
}

/* Admin resources: explorer style (scoped) */
.admin-res-explorer {
  padding: 8px 0 34px;
}

.admin-res-explorer .explorer-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.admin-res-explorer .explorer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.admin-res-explorer .explorer-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.admin-res-explorer .explorer-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.admin-res-explorer .side-card,
.admin-res-explorer .main-card {
  background: rgba(248, 251, 255, 0.65);
  border: 1px solid rgba(226, 232, 240, 0.7);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.admin-res-explorer .side-section {
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.65);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-res-explorer .side-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.admin-res-explorer .side-body {
  padding: 10px 10px 12px;
}

.admin-res-explorer .side-note {
  font-size: 12px;
  color: var(--text-soft);
}

.admin-res-explorer .side-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.admin-res-explorer .side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(226, 232, 240, 0.85);
  transition: background var(--transition), border-color var(--transition);
}

.admin-res-explorer .side-item:hover {
  background: rgba(241, 245, 249, 0.8);
}

.admin-res-explorer .side-item.active {
  background: rgba(30, 58, 138, 0.14);
  border-color: rgba(30, 58, 138, 0.2);
}

.admin-res-explorer .side-item strong {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-res-explorer .tree {
  display: grid;
  gap: 6px;
}

.admin-res-explorer .tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(226, 232, 240, 0.85);
  transition: background var(--transition), border-color var(--transition);
}

.admin-res-explorer .tree-item:hover {
  background: rgba(241, 245, 249, 0.8);
}

.admin-res-explorer .tree-item.active {
  background: rgba(30, 58, 138, 0.14);
  border-color: rgba(30, 58, 138, 0.2);
}

.admin-res-explorer .tree-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.admin-res-explorer .tree-indent {
  width: 14px;
  flex: 0 0 14px;
}

.admin-res-explorer .tree-name {
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-res-explorer .main-head {
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.65);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-res-explorer .crumb {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
}

.admin-res-explorer .main-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-res-explorer .main-controls .input {
  width: min(360px, 46vw);
}

.admin-res-explorer .main-body {
  padding: 10px 12px 12px;
}

.admin-res-explorer .file-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.admin-res-explorer .file-row {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
}

.admin-res-explorer .file-row td {
  padding: 12px 12px;
  vertical-align: middle;
}

.admin-res-explorer .file-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.admin-res-explorer .file-sub {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-res-explorer .mini-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.admin-res-explorer .mini {
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}

.admin-res-explorer .mini:hover {
  background: rgba(241, 245, 249, 0.85);
}

.admin-res-explorer .mini.danger {
  border-color: rgba(209, 77, 86, 0.28);
  color: #b63d45;
}

.admin-res-explorer .bulkbar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

@media (max-width: 980px) {
  .admin-res-explorer .explorer-grid {
    grid-template-columns: 1fr;
  }

  .admin-res-explorer .main-controls .input {
    width: 100%;
  }
}

/* Admin resources: file-manager style (scoped) */
.admin-res-filemgr {
  padding: 8px 0 34px;
}

.admin-res-filemgr .filemgr-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.admin-res-filemgr .filemgr-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.admin-res-filemgr .filemgr-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.admin-res-filemgr .filemgr-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.admin-res-filemgr .fm-kinds {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 10px 12px;
}

.admin-res-filemgr .fm-kind {
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.admin-res-filemgr .fm-kind:hover {
  background: rgba(241, 245, 249, 0.85);
}

.admin-res-filemgr .fm-kind.active {
  background: rgba(30, 58, 138, 0.14);
  border-color: rgba(30, 58, 138, 0.28);
  color: var(--text-main);
}

.admin-res-filemgr .fm-pane,
.admin-res-filemgr .fm-main-card {
  background: var(--surface);
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.admin-res-filemgr .tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-res-filemgr .tag-chip-x {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-weight: 900;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.admin-res-filemgr .tag-chip-x:hover {
  color: #475569;
}

.admin-res-filemgr .fm-pane {
  margin-top: 12px;
}

.admin-res-filemgr .fm-sidebar>.fm-pane:first-child {
  margin-top: 0;
}

.admin-res-filemgr .fm-pane-head,
.admin-res-filemgr .fm-main-head {
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.65);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-res-filemgr .fm-pane-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.admin-res-filemgr .fm-pane-note {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 700;
}

.admin-res-filemgr .fm-pane-body,
.admin-res-filemgr .fm-main-body {
  padding: 10px 12px 12px;
}

.admin-res-filemgr .fm-form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-res-filemgr .fm-form-row .input {
  flex: 1;
  min-width: 160px;
}

.admin-res-filemgr .fm-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.admin-res-filemgr .side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(226, 232, 240, 0.85);
  transition: background var(--transition), border-color var(--transition);
}

.admin-res-filemgr .fm-side-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.admin-res-filemgr .fm-side-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.admin-res-filemgr .fm-side-act {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-weight: 900;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.admin-res-filemgr .fm-side-act:hover {
  background: rgba(241, 245, 249, 0.75);
  color: var(--text-main);
}

.admin-res-filemgr .fm-side-act.danger {
  color: #b63d45;
}

.admin-res-filemgr .fm-side-act.danger:hover {
  background: rgba(209, 77, 86, 0.12);
  color: #a8333b;
}

.admin-res-filemgr .side-item:hover {
  background: rgba(241, 245, 249, 0.8);
}

.admin-res-filemgr .side-item.active {
  background: rgba(30, 58, 138, 0.14);
  border-color: rgba(30, 58, 138, 0.2);
}

.admin-res-filemgr .side-item strong {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-res-filemgr .tree {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.admin-res-filemgr .tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(226, 232, 240, 0.85);
  transition: background var(--transition), border-color var(--transition);
}

.admin-res-filemgr .tree-item:hover {
  background: rgba(241, 245, 249, 0.8);
}

.admin-res-filemgr .tree-item.active {
  background: rgba(30, 58, 138, 0.14);
  border-color: rgba(30, 58, 138, 0.2);
}

.admin-res-filemgr .tree-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.admin-res-filemgr .tree-indent {
  width: 14px;
  flex: 0 0 14px;
}

.admin-res-filemgr .tree-name {
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-res-filemgr .fm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.7);
  border: 1px solid rgba(241, 245, 249, 0.95);
  box-shadow: var(--shadow-card);
}

.admin-res-filemgr .fm-crumb {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.admin-res-filemgr .fm-filterbar {
  margin-top: 12px;
  padding: 10px 12px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #f1f5f9;
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 10px;
}

.admin-res-filemgr .fm-filter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-res-filemgr .fm-filter-top .input {
  width: min(420px, 62vw);
}

.admin-res-filemgr .fm-tag-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-res-filemgr .fm-tag-tools .input {
  width: min(220px, 52vw);
}

.admin-res-filemgr .fm-table-wrap {
  margin-top: 12px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
}

.admin-res-filemgr .file-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 820px;
}

.admin-res-filemgr .file-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  font-size: 12px;
  font-weight: 900;
  color: var(--text-main);
  background: rgba(248, 251, 255, 0.95);
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  padding: 10px 12px;
  white-space: nowrap;
}

.admin-res-filemgr .file-row td {
  padding: 12px 12px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.admin-res-filemgr .file-row:hover td {
  background: rgba(241, 245, 249, 0.6);
}

.admin-res-filemgr .file-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.admin-res-filemgr .file-sub {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-res-filemgr .mini-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.admin-res-filemgr .mini {
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}

.admin-res-filemgr .mini:hover {
  background: rgba(241, 245, 249, 0.85);
}

.admin-res-filemgr .mini.danger {
  border-color: rgba(209, 77, 86, 0.28);
  color: #b63d45;
}

.admin-res-filemgr .fm-foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .admin-res-filemgr .filemgr-grid {
    grid-template-columns: 1fr;
  }

  .admin-res-filemgr .fm-filter-top .input {
    width: 100%;
  }

  .admin-res-filemgr .file-table {
    min-width: 720px;
  }
}

/* Resource pages */
.resource-shell {
  width: min(var(--content-max-width), calc(100vw - var(--content-gutter)));
  margin: 0 auto;
  padding: 12px 0 30px;
}

.resource-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 16px;
}

.resource-toolbar h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.resource-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.resource-select,
.resource-search {
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(248, 251, 255, 0.9);
  padding: 0 12px;
  color: var(--text-main);
  outline: none;
}

.resource-search {
  min-width: 240px;
}

.resource-grid {
  display: grid;
  grid-template-columns: 260px minmax(340px, 1fr) minmax(360px, 1.15fr);
  gap: 18px;
  align-items: stretch;
}

.resource-panel {
  background: rgba(248, 251, 255, 0.65);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.resource-panel-header {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.65);
}

.resource-panel-header h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.resource-panel-body {
  padding: 10px 12px 12px;
  flex: 1;
  overflow: auto;
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-main);
  transition: background var(--transition);
}

.folder-item:hover {
  background: rgba(241, 245, 249, 0.85);
}

.folder-item.active {
  background: rgba(30, 58, 138, 0.14);
}

.folder-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.folder-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-indent {
  width: 12px;
  flex: 0 0 12px;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 0;
}

.tag-chip {
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  user-select: none;
}

.tag-chip.active {
  background: rgba(30, 58, 138, 0.14);
  color: var(--text-main);
  border-color: rgba(30, 58, 138, 0.28);
}

.resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
}

.resource-row:hover {
  background: rgba(241, 245, 249, 0.85);
}

.resource-row.active {
  background: rgba(30, 58, 138, 0.14);
}

.resource-row-main {
  min-width: 0;
}

.resource-title {
  font-weight: 700;
  font-size: 14px;
  margin: 0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-soft);
  font-size: 12px;
}

.resource-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.95);
  color: var(--text-muted);
}

.resource-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.resource-empty {
  padding: 40px 18px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

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

  .resource-panel {
    min-height: 260px;
  }

  .resource-search {
    min-width: 160px;
    width: 100%;
  }

  .resource-controls {
    justify-content: flex-start;
  }
}

.top-nav {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.top-nav-link {
  padding: 8px 2px;
  border-radius: 0;
  font-size: 12px;
  color: #5a7698;
  font-weight: 600;
  position: relative;
  transition: color var(--transition);
}

.top-nav-link:hover {
  color: #284d80;
}

.top-nav-link.active {
  color: var(--text-main);
}

.top-nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  border-radius: 999px;
  background: transparent;
  opacity: 0.95;
}

.top-nav-link.active::after {
  background: rgba(30, 58, 138, 0.9);
}

/* User avatar menu (header right) */
.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.avatar-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  --ripple-color: rgba(60, 110, 180, 0.12);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(30, 58, 138, 0.14);
  color: var(--text-main);
  font-weight: 800;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: var(--shadow-card);
  padding: 10px;
  z-index: 90;
}

.user-menu-head {
  padding: 10px 10px 12px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.user-menu-name {
  font-weight: 800;
  font-size: 13px;
  color: var(--text-main);
}

.user-menu-role {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-soft);
}

.user-menu-items {
  padding: 8px 4px 4px;
  display: grid;
  gap: 4px;
}

.user-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  color: #27425f;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.user-menu-item:hover {
  background: var(--surface-alt);
}

.user-menu-item.danger {
  color: #b0424b;
}

.manager-sub-nav {
  margin-bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 6px;
  background: #f1f5f9;
}

.manager-sub-link {
  padding: 8px 16px;
  border-radius: 8px;
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  text-decoration: none;
}

.manager-sub-link:hover {
  background: #e2e8f0;
  color: #334155;
}

.manager-sub-link.active {
  background: var(--surface);
  color: #0f172a;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(226, 232, 240, 0.85);
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #27425f;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  --ripple-color: rgba(60, 110, 180, 0.12);
  transition:
    background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s ease;
}

.btn:hover {
  background: #f8fbff;
  border-color: #cbdcf2;
  box-shadow: var(--shadow-card);
}

.btn:active {
  background: #f1f6ff;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-card);
  --ripple-color: rgba(255, 255, 255, 0.35);
}

.btn-primary:hover {
  background: #3f79d1;
  border-color: #3f79d1;
  color: #fff;
  box-shadow: var(--shadow-card);
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #566f90;
  --ripple-color: rgba(60, 97, 152, 0.18);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: #29476a;
}

.btn-ghost:active {
  background: #e1e9f5;
}

:where(.btn-start, .btn-detail, .preview-btn, .record-btn, .ghost-btn, .skip-link, .clear-link) {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  --ripple-color: rgba(58, 98, 155, 0.24);
}

:where(.btn-start, .record-btn) {
  --ripple-color: rgba(255, 255, 255, 0.4);
}

.btn-ripple {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  pointer-events: none;
  background: var(--ripple-color);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0.6;
  /* Standard Material entry: rapid expansion */
  animation: rippleEnter 550ms cubic-bezier(0, 0, 0.2, 1) forwards;
  will-change: transform, opacity;
  z-index: 0;
}

.btn-ripple.is-fading {
  /* Exit transition: fade out softly */
  opacity: 0;
  transition: opacity 400ms linear;
}

@keyframes rippleEnter {
  from {
    transform: translate(-50%, -50%) scale(0);
  }

  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #5f7998;
  background: var(--surface-alt);
  border-radius: var(--radius-pill);
  padding: 5px 10px;
}

/* cards */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: none;
}

.panel:hover {
  box-shadow: var(--shadow-card);
}

.section-title {
  margin: 0 0 10px;
  color: #244469;
  font-size: 14px;
  font-weight: 700;
}

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

.empty {
  color: #7f94b1;
  font-size: 13px;
  padding: 10px 0;
}

/* forms */
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #294a71;
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  font-size: 14px;
  padding: 9px 10px;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #8eb2ea;
  box-shadow: var(--shadow-card);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.auth-error,
.auth-success {
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 12px;
  margin-bottom: 6px;
}

.auth-error {
  background: #fff4f4;
  color: #b0424b;
  border: 1px solid #f3ced2;
}

.auth-success {
  background: #f1fcf7;
  color: #287a58;
  border: 1px solid #cceede;
}

/* lists, stats, kv */
.list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}

.list-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.list-item:hover {
  background: #f7faff;
  border-color: #dbe8fb;
}

.list-item:active {
  transform: scale(0.985);
}

.list-item.active {
  border-color: #8ab0e8;
  background: #eef5ff;
  box-shadow: var(--shadow-card);
}

.item-title {
  font-size: 13px;
  font-weight: 600;
  color: #203f64;
}

.item-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #6881a0;
  line-height: 1.45;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.stat-card {
  background: #f7faff;
  border: 1px solid #dfe8f6;
  border-radius: var(--radius-sm);
  padding: 10px;
}

.stat-name {
  font-size: 12px;
  color: #6d83a1;
}

.stat-value {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  color: #235297;
}

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

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
}

.kv-row dt,
.kv-row span {
  color: #67829f;
}

.kv-row dd,
.kv-row b {
  margin: 0;
  font-weight: 600;
  color: #1f4168;
  text-align: right;
}

.control-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* home / bank / res shared */
.hero-layout,
.banner-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 12px;
  margin-bottom: 24px;
}

.hero-panel,
.banner-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Rich Banner Variant */
.banner-layout.rich {
  grid-template-columns: 1fr 340px;
}

.banner-layout.rich .banner-panel {
  background: var(--surface-soft);
  border: 1px solid #e2e8f0;
}

.banner-layout.rich .banner-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  background-size: cover;
  background-position: center;
  opacity: 0.15;
  mask-image: linear-gradient(to right, transparent, black 100%);
  -webkit-mask-image: linear-gradient(to right, transparent, black 100%);
  pointer-events: none;
}

.hero-title,
.banner-title {
  margin: 0;
  font-size: clamp(24px, 2.5vw, 36px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #1e3a8a;
}

.hero-sub,
.banner-sub {
  margin: 12px 0 0;
  font-size: 15px;
  color: #475569;
  line-height: 1.6;
}

.hero-actions,
.banner-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.stats-brief {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.5);
}

/* File Icons System */
.res-file-icon {
  width: 46px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.res-file-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.12));
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.hero-tag {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: #eef5ff;
  color: #587496;
}

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

.feature-card,
.set-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.set-title {
  margin: 0;
  font-size: 16px;
  color: #234972;
}

.set-meta {
  margin: 0;
  font-size: 12px;
  color: #667f9e;
  line-height: 1.5;
}

/* auth pages */
.auth-shell {
  width: min(1240px, calc(100vw - 112px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.auth-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
  min-height: calc(100vh - 84px);
}

.auth-brand {
  border-radius: var(--radius);
  background: var(--surface-soft);
  border: 1px solid #dce8f9;
  padding: 24px;
  display: grid;
  align-content: space-between;
  gap: 20px;
}

.auth-brand h1 {
  margin: 0;
  font-size: clamp(30px, 3.3vw, 46px);
  line-height: 1.1;
  color: #1e4a8d;
}

.auth-brand p {
  margin: 12px 0 0;
  font-size: 15px;
  color: #5a7394;
  line-height: 1.75;
  max-width: 620px;
}

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

.auth-metric {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #dbe8fb;
  border-radius: var(--radius-sm);
  padding: 10px;
}

.auth-metric .n {
  font-size: 22px;
  line-height: 1;
  color: #2c5caa;
  font-weight: 700;
}

.auth-metric .k {
  margin-top: 6px;
  font-size: 12px;
  color: #6882a3;
}

.auth-head {
  margin-bottom: 8px;
}

.auth-title {
  margin: 0;
  font-size: 26px;
  color: #204673;
}

.auth-subtitle {
  margin: 6px 0 0;
  color: #718aa8;
  font-size: 13px;
}

.auth-foot {
  margin-top: 10px;
  font-size: 13px;
  color: #7088a6;
}

.auth-foot a {
  color: #2f6fd8;
  font-weight: 600;
}

.auth-side-panel {
  display: grid;
  align-content: center;
  gap: 6px;
}

/* attempt result */
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 14px;
  color: #28517b;
}

.question-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.68;
  color: #2c4c72;
  background: #f8fbff;
  border-radius: var(--radius-sm);
  border: 1px solid #dfe9f6;
  padding: 10px;
  white-space: pre-wrap;
}

.result-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.result-card.active {
  border-color: #8ab0e8;
  background: #eff6ff;
}

.result-card .title {
  font-size: 13px;
  color: #224a76;
  font-weight: 600;
}

.result-card .sub {
  margin-top: 4px;
  font-size: 12px;
  color: #6f86a3;
}

.word-heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.word-chip {
  border: 1px solid #dce8f8;
  background: #f8fbff;
  border-radius: 6px;
  padding: 8px 9px;
}

.word-chip .w {
  font-size: 13px;
  font-weight: 700;
  color: #22466f;
  line-height: 1.25;
}

.word-chip .s {
  margin-top: 4px;
  font-size: 12px;
  color: #5d7897;
}

.word-chip.good {
  border-color: #b7e9cf;
  background: #f1fbf6;
}

.word-chip.mid {
  border-color: #f2dfb5;
  background: #fffaf0;
}

.word-chip.bad,
.word-chip.miss {
  border-color: #f2cad0;
  background: #fff4f6;
}

.word-breakdown {
  display: grid;
  gap: 8px;
}

.word-row {
  border: 1px solid #dce8f8;
  border-radius: 6px;
  background: #fbfdff;
  padding: 9px 10px;
}

.word-row.good {
  border-left: 3px solid #2ca36f;
}

.word-row.mid {
  border-left: 3px solid #d09b34;
}

.word-row.bad,
.word-row.miss {
  border-left: 3px solid #cf4d5f;
}

.word-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.word-name {
  font-size: 14px;
  font-weight: 700;
  color: #204265;
}

.word-main-score {
  font-size: 14px;
  font-weight: 700;
  color: #2c5e9f;
}

.word-row-meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: #6983a2;
}

.phones {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.phone {
  border: 1px solid #d6e4f6;
  border-radius: 6px;
  background: #f5f9ff;
  font-size: 12px;
  color: #3d5d83;
  padding: 2px 7px;
}

.phone b {
  font-weight: 700;
}

.phone.good {
  color: #1d8d5e;
  border-color: #bce9d4;
  background: #edf9f3;
}

.phone.mid {
  color: #966e27;
  border-color: #efd9af;
  background: #fff9ee;
}

.phone.bad {
  color: #a23b47;
  border-color: #f1c3ca;
  background: #fff2f5;
}

/* loading + toast */
#globalTopProgress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.18s ease;
  background: rgba(207, 222, 244, 0.35);
}

#globalTopProgress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(28vw, 240px);
  min-width: 96px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(75, 127, 232, 0) 0%, rgba(75, 127, 232, 0.45) 18%, #4b7fe8 58%, rgba(75, 127, 232, 0.15) 100%);
  box-shadow: 0 0 10px rgba(75, 127, 232, 0.24);
  will-change: transform;
  animation: topProgressSweep 1.15s cubic-bezier(0.32, 0.72, 0.2, 1) infinite;
}

#globalTopProgress.active {
  opacity: 1;
}

@keyframes topProgressSweep {
  0% {
    transform: translateX(-130%);
  }

  100% {
    transform: translateX(calc(100vw + 160px));
  }
}

#globalLoadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(242, 247, 255, 0.58);
  z-index: 1900;
  display: none;
  align-items: center;
  justify-content: center;
}

#globalLoadingOverlay.active {
  display: flex;
}

.loading-card {
  min-width: 220px;
  border: 1px solid #d8e5fa;
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #d3e1f8;
  border-top-color: #3f7fe8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: #355c91;
  font-size: 13px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#globalToastStack {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 2100;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 28px));
}

.toast {
  border-radius: var(--radius-sm);
  border: 1px solid #d9e5f7;
  background: var(--surface);
  color: #2c4f79;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  padding: 11px 16px;
  box-shadow: var(--shadow-card);
  animation: toastEnter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes toastEnter {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast.success {
  border-color: #c8e9da;
  color: #2b7d5b;
}

.toast.warning {
  border-color: #f0deb8;
  color: #8d6929;
}

.toast.error {
  border-color: #f0c7cb;
  color: #9c3b43;
}

.header-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), border-color var(--transition);
}

.header-mobile-toggle:hover {
  background: var(--surface-alt);
  border-color: var(--primary);
}

.header-mobile-toggle:active {
  background: var(--surface-soft);
}

.hamburger-icon {
  width: 20px;
  height: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, background 0.2s ease;
  transform-origin: center;
}

.header-mobile-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.header-mobile-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.header-mobile-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 65;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.mobile-nav-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-nav-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(300px, 85vw);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  z-index: 68;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-nav-panel.active {
  transform: translateX(0);
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  background: var(--surface-soft);
}

.mobile-nav-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.mobile-nav-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.mobile-nav-close:hover {
  background: var(--surface-alt);
  color: var(--text-main);
  border-color: var(--primary);
}

.mobile-nav-body {
  padding: 12px 0;
}

.mobile-nav-section {
  padding: 8px 18px;
}

.mobile-nav-section-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mobile-nav-links {
  display: grid;
  gap: 2px;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-link:hover {
  background: var(--surface-alt);
}

.mobile-nav-link:active {
  background: rgba(30, 58, 138, 0.12);
}

.mobile-nav-link.active {
  background: rgba(30, 58, 138, 0.14);
  color: var(--primary-dark);
}

.mobile-nav-link-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  flex-shrink: 0;
}

.mobile-nav-link.active .mobile-nav-link-icon {
  color: var(--primary);
}

.mobile-nav-divider {
  height: 1px;
  background: rgba(226, 232, 240, 0.9);
  margin: 12px 18px;
}

.mobile-nav-actions {
  display: grid;
  gap: 8px;
  padding: 8px 18px;
}

.mobile-nav-actions .btn {
  width: 100%;
  justify-content: center;
}

.mobile-user-info {
  padding: 16px 18px;
  background: var(--surface-soft);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.mobile-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(30, 58, 138, 0.14);
  color: var(--text-main);
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.mobile-user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.mobile-user-role {
  font-size: 13px;
  color: var(--text-soft);
}

/* responsive */
@media (max-width: 1200px) {

  .app-shell,
  .auth-shell {
    width: calc(100vw - 40px);
  }

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

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

  .hero-layout,
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    min-height: auto;
  }
}

@media (max-width: 900px) {
  .header-mobile-toggle {
    display: flex;
  }

  .mobile-nav-overlay {
    display: block;
  }

  .mobile-nav-panel {
    display: block;
  }

  .header-actions {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
  }

  .header-actions.mobile-visible {
    position: static;
    clip: auto;
    width: auto;
    height: auto;
    overflow: visible;
  }

  .top-nav {
    display: none;
  }

  .header-actions>.btn[data-guest-only] {
    display: none;
  }

  .header-actions>.user-menu {
    display: none;
  }
}

@media (max-width: 760px) {

  .app-shell,
  .auth-shell {
    width: calc(100vw - 18px);
    padding-top: 10px;
  }

  .app-header {
    flex-wrap: nowrap;
    align-items: center;
    padding: 8px 0 10px;
  }

  .header-main {
    flex: 1;
    min-width: 0;
  }

  .header-title,
  .header-title-group h1 {
    font-size: 20px;
  }

  .header-subtitle {
    display: none;
  }

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

  .result-card-grid,
  .section-grid,
  .auth-metrics,
  .split {
    grid-template-columns: 1fr;
  }

  .list {
    max-height: 320px;
  }
}

@media (max-width: 480px) {
  .brand-badge {
    width: 30px;
    height: 30px;
  }

  .header-title,
  .header-title-group h1 {
    font-size: 18px;
  }

  .mobile-nav-panel {
    width: calc(100vw - 48px);
  }
}

@media (hover: none) and (pointer: coarse) {
  .mobile-nav-link {
    min-height: 48px;
  }

  .mobile-nav-close {
    min-width: 44px;
    min-height: 44px;
  }

  .header-mobile-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

.icp-footer {
  text-align: center;
  padding: 20px;
  margin-top: 40px;
  border-top: 1px solid #e2e8f0;
  background: var(--bg);
  width: 100%;
  clear: both;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.icp-footer a {
  color: #64748b;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.icp-footer a:hover {
  color: #2b74d8;
  text-decoration: underline;
}

.icp-icon {
  width: 13px;
  height: 13px;
  margin-right: 6px;
  flex: 0 0 auto;
  object-fit: contain;
}
