:root {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  color: #1f2933;
  background: #f5f7fa;
  --brand: #12a9e8;
  --brand-dark: #063b5c;
  --accent: #f2b84b;
  --ink: #1f2933;
  --muted: #6b7280;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button, input, textarea, select {
  font: inherit;
}
h1, h2, h3 {
  font-family: 'Montserrat', 'Inter', sans-serif;
  letter-spacing: -0.035em;
  color: var(--brand-dark);
  margin: 0;
}
.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.boot-loader {
  color: var(--brand-dark);
  background: #f5f7fa;
}
.boot-loader > div {
  display: grid;
  justify-items: center;
  gap: 14px;
}
.page-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(18,169,232,.22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: admin-spin .75s linear infinite;
}
.card {
  background: white;
  border: 1px solid rgba(6, 59, 92, 0.12);
  border-radius: 24px;
  box-shadow: 0 18px 42px rgba(6, 59, 92, 0.12);
}
.login {
  width: min(430px, 100%);
  padding: 36px;
  display: grid;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--brand-dark);
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 1.25rem;
  line-height: 1.1;
  margin-bottom: 8px;
}
.brand img {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(18, 169, 232, 0.24);
}
.login h1 {
  font-size: 2rem;
}
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .7rem;
  font-weight: 800;
  color: var(--accent);
}
.muted {
  color: var(--muted);
}
label {
  display: grid;
  gap: 7px;
  font-size: .8rem;
  font-weight: 750;
}
input, textarea, select {
  width: 100%;
  border: 1px solid #d4d4d8;
  border-radius: 11px;
  background: #fff;
  padding: 11px 13px;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: 3px solid rgba(18, 169, 232, 0.45);
  border-color: var(--brand);
}
button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(18, 169, 232, 0.28);
}
button:disabled {
  cursor: wait;
  transform: none;
  opacity: .82;
}
button.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
button.is-loading::before {
  content: '';
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 3px solid rgba(255,255,255,.45);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: admin-spin .7s linear infinite;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  button.is-loading::before, .page-spinner { animation-duration: 1.4s; }
}
.quiet {
  background: #ecebea;
  color: #3f3f46;
  border-radius: 11px;
  box-shadow: none;
}
.quiet:hover {
  box-shadow: none;
  background: #e4e4e7;
}
.error {
  color: #b91c1c;
  min-height: 1.2em;
}
#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
}
aside {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 22px;
  background: var(--brand-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
aside h2 {
  font-size: 1.8rem;
  color: #fff;
}
aside nav {
  display: grid;
  gap: 8px;
}
aside nav button {
  background: transparent;
  text-align: left;
  color: #eaf8fe;
  border-radius: 11px;
  box-shadow: none;
}
aside nav button:hover {
  background: rgba(255,255,255,0.1);
  transform: none;
  box-shadow: none;
}
aside nav button.active {
  background: #fff;
  color: var(--brand-dark);
}
aside nav button.active:hover {
  background: #fff;
}
aside a {
  display: block;
  color: #fff;
  text-decoration: none;
  margin-bottom: 15px;
}
.workspace {
  padding: 38px clamp(24px, 5vw, 72px);
}
.workspace>header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
}
.workspace h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}
.stats {
  display: flex;
  gap: 10px;
}
.stat {
  background: #fff;
  padding: 12px 16px;
  border: 1px solid rgba(6, 59, 92, 0.12);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(6, 59, 92, 0.07);
}
.stat strong {
  display: block;
  font-size: 1.25rem;
  color: var(--brand-dark);
}
.stat span {
  font-size: .7rem;
  color: var(--muted);
}
.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin: 32px 0 15px;
}
.toolbar input {
  padding: 14px;
}
.toolbar.has-study-filters {
  grid-template-columns: minmax(220px, 1fr) minmax(380px, 1.25fr) auto;
}
.study-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}
.study-filters label {
  position: relative;
  min-width: 0;
}
.study-filters label span {
  position: absolute;
  left: 13px;
  top: 6px;
  z-index: 1;
  color: var(--muted);
  font-size: .62rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  pointer-events: none;
}
.study-filters select {
  min-width: 0;
  height: 100%;
  min-height: 48px;
  padding: 19px 34px 5px 12px;
}
.table {
  background: #fff;
  border: 1px solid rgba(6, 59, 92, 0.12);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(6, 59, 92, 0.07);
}
.row {
  display: grid;
  grid-template-columns: minmax(250px, 2fr) minmax(150px, 1fr) minmax(140px, 1fr) 110px;
  gap: 18px;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid #eee;
}
.row.study-row {
  grid-template-columns: minmax(230px, 1.7fr) minmax(155px, 1fr) minmax(130px, .8fr) minmax(145px, .9fr) 155px;
}
.table-header {
  background: #f8fafc;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding-top: 11px;
  padding-bottom: 11px;
}
.table-header span:last-child { text-align: right; }
.row:last-child {
  border: 0;
}
.row small, .row .secondary {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
.row button {
  justify-self: end;
  background: #f2f1ef;
  color: #27272a;
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: none;
}
.row button:hover {
  transform: translateY(-1px);
  background: #e4e4e7;
}
.empty {
  text-align: center;
  padding: 60px;
  color: var(--muted);
}
#notice {
  min-height: 24px;
  color: #15803d;
}
dialog {
  width: min(680px, calc(100% - 30px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  box-shadow: 0 30px 100px #0004;
}
dialog::backdrop {
  background: rgba(6, 59, 92, 0.6);
  backdrop-filter: blur(4px);
}
dialog form>header, dialog form>footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 26px;
  border-bottom: 1px solid #eee;
}
dialog form>footer {
  justify-content: flex-end;
  border-top: 1px solid #eee;
  border-bottom: 0;
}
.icon {
  background: transparent;
  color: #333;
  font-size: 1.8rem;
  padding: 4px;
  box-shadow: none;
}
.icon:hover {
  box-shadow: none;
  background: rgba(0,0,0,0.05);
}
.fields {
  padding: 25px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px;
}
.fields .wide {
  grid-column: 1/-1;
}
.editor-error {
  min-height: 20px;
  margin: 0 26px 18px;
  color: #b91c1c;
  font-weight: 600;
}
textarea {
  min-height: 90px;
  resize: vertical;
}
.upload {
  display: flex;
  gap: 8px;
}
.upload input {
  min-width: 0;
}
.audio-preview {
  display: grid;
  gap: 8px;
  color: var(--brand-dark);
  font-weight: 700;
}
.audio-preview audio {
  width: 100%;
}
.user-row {
  grid-template-columns: minmax(190px, 1.5fr) minmax(100px, .7fr) minmax(150px, .8fr) minmax(90px, .5fr) minmax(280px, 1.8fr);
}
.user-actions {
  flex-wrap: wrap;
}
.row .mobile-user-meta {
  display: none;
}
.status-pill {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: .75rem;
  font-weight: 800;
}
.status-pill.disabled {
  background: #fff1f2;
  color: #be123c;
}
.readonly-field {
  display: grid;
  gap: 7px;
  font-size: .8rem;
}
.readonly-field strong {
  padding: 11px 13px;
  border-radius: 11px;
  background: #f4f4f5;
}
.dialog-message {
  padding: 24px 26px;
  line-height: 1.55;
}
.dialog-message p {
  margin: 0;
}
.small-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
}
#user-action-confirm.danger {
  background: #be123c;
}
@media(max-width:800px) {
  #app { display: block; }
  aside {
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 18px;
  }
  aside nav { display: flex; }
  aside>div:last-child { display: none; }
  .workspace { padding: 25px 16px; }
  .workspace>header { display: block; }
  .stats { margin-top: 18px; }
  .toolbar.has-study-filters { grid-template-columns: 1fr; }
  .row, .row.study-row, .row.user-row { grid-template-columns: 1fr auto; }
  .table-header { display: none; }
  .row>*:not(:first-child):not(:last-child) { display: none; }
  .row .mobile-user-meta { display: block; }
  .fields { grid-template-columns: 1fr; }
  .fields .wide { grid-column: auto; }
}
@media(max-width:520px) {
  aside nav button { font-size: 0; padding: 11px; }
  aside nav button::first-letter { font-size: 1rem; }
  .toolbar { grid-template-columns: 1fr; }
  .study-filters { grid-template-columns: 1fr; }
  .stats { overflow: auto; }
}

button.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}
button.icon-btn svg {
  width: 18px;
  height: 18px;
}

.settings-grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: minmax(0, 820px);
}
.settings-card {
  background: #fff;
  border: 1px solid rgba(6, 59, 92, 0.12);
  border-radius: 20px;
  padding: clamp(22px, 4vw, 36px);
  box-shadow: 0 10px 24px rgba(6, 59, 92, 0.07);
}
.settings-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
}
.settings-heading h2 {
  margin-top: 6px;
  font-size: clamp(1.35rem, 3vw, 2rem);
}
.settings-card > .muted {
  line-height: 1.65;
  max-width: 68ch;
}
.settings-help {
  margin: 22px 0 4px;
  border: 1px solid rgba(6, 59, 92, .14);
  border-radius: 15px;
  background: #f8fafc;
  overflow: hidden;
}
.settings-help summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  color: var(--brand-dark);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.settings-help summary::-webkit-details-marker {
  display: none;
}
.settings-help summary::after {
  content: '⌄';
  margin-left: auto;
  font-size: 1.3rem;
  line-height: 1;
  transition: transform .2s ease;
}
.settings-help[open] summary::after {
  transform: rotate(180deg);
}
.settings-help summary:hover {
  background: #f1f5f9;
}
.settings-help summary:focus-visible {
  outline: 3px solid rgba(18, 169, 232, .45);
  outline-offset: -3px;
}
.settings-help summary > span:nth-child(2) {
  display: grid;
  gap: 3px;
}
.settings-help summary small {
  color: var(--muted);
  font-weight: 500;
}
.settings-help-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand-dark);
  font-weight: 850;
}
.settings-help-content {
  padding: 4px 18px 18px;
  border-top: 1px solid rgba(6, 59, 92, .1);
}
.settings-help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 24px;
}
.settings-help-grid section {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 0;
}
.settings-step {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  color: var(--brand-dark);
  background: #e0f2fe;
  font-size: .75rem;
  font-weight: 850;
}
.settings-help h3 {
  font-size: .95rem;
  letter-spacing: -.015em;
}
.settings-help p {
  margin: 6px 0 0;
  color: #52606d;
  font-size: .84rem;
  line-height: 1.55;
}
.settings-help-note {
  padding: 13px 15px;
  border-radius: 11px;
  color: #075985;
  background: #eaf8fe;
  font-size: .82rem;
  line-height: 1.5;
}
.cache-switch {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 14px;
  margin: 26px 0;
  cursor: pointer;
}
.cache-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.cache-switch-track {
  width: 52px;
  height: 30px;
  padding: 3px;
  border-radius: 999px;
  background: #d4d4d8;
  transition: background-color .2s ease;
}
.cache-switch-track::after {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  transition: transform .2s ease;
}
.cache-switch input:checked + .cache-switch-track {
  background: var(--brand);
}
.cache-switch input:checked + .cache-switch-track::after {
  transform: translateX(22px);
}
.cache-switch input:focus-visible + .cache-switch-track {
  outline: 3px solid rgba(18, 169, 232, .45);
  outline-offset: 3px;
}
.cache-switch-copy {
  display: grid;
  gap: 4px;
}
.cache-switch-copy strong {
  color: var(--brand-dark);
  font-size: .92rem;
}
.cache-switch-copy small {
  max-width: 64ch;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  line-height: 1.45;
}
.settings-warning,
.settings-clean {
  display: grid;
  gap: 5px;
  padding: 16px 18px;
  border-radius: 13px;
}
.settings-warning {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
}
.settings-clean {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.settings-meta {
  margin: 24px 0 0;
  display: grid;
  gap: 0;
}
.settings-meta div {
  display: grid;
  grid-template-columns: minmax(190px, .7fr) 1fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}
.settings-meta dt {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
}
.settings-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 26px;
}

@media(max-width:620px) {
  .settings-heading { display: grid; }
  .settings-help-grid { grid-template-columns: 1fr; }
  .settings-help summary small { display: none; }
  .settings-meta div { grid-template-columns: 1fr; gap: 4px; }
  .settings-actions button { width: 100%; }
}
