:root {
  color-scheme: dark;
  --bg: #121316;
  --surface: #191a1f;
  --raised: #202127;
  --hover: #272830;
  --line: #303138;
  --line-strong: #494b56;
  --text: #e6e6ed;
  --muted: #a0a1ad;
  --dim: #777986;
  --purple: #b6a5ff;
  --purple-bg: #302943;
  --ember: #e6883f;
  --green: #93cfad;
  --red: #e6a2a9;
  --red-bg: #39252b;
  --amber: #dfbf84;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, select {
  font: inherit;
}

a {
  color: var(--purple);
  text-underline-offset: 4px;
}

a:hover {
  color: var(--text);
}

button, a, input, select, summary {
  outline-offset: 4px;
}

:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

h1, h2, h3, p {
  margin: 0 0 12px;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 600;
}

h2 {
  font-size: 17px;
  line-height: 1.35;
  font-weight: 600;
}

h3 {
  font-size: 14.5px;
  font-weight: 600;
}

fieldset {
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}

.muted, .help {
  color: var(--muted);
}

.help {
  font-size: 12px;
  margin: 7px 0 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
}

.wordmark img {
  object-fit: contain;
  flex-shrink: 0;
}

.login-shell {
  width: min(100%, 456px);
  padding: 64px 20px 32px;
  margin: 0 auto;
  min-width: 0;
}

.login-shell > .wordmark {
  margin-bottom: 28px;
}

.panel {
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  min-width: 0;
}

.login-panel h1 {
  margin-bottom: 10px;
}

.login-panel form {
  margin-top: 26px;
}

.login-help {
  padding-top: 22px;
  border-top: 1px solid var(--line);
  margin-top: 22px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.field {
  min-width: 0;
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 7px;
}

input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #494b56;
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

input:hover, select:hover {
  border-color: #75717f;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  border: 1px solid #494b56;
  border-radius: 7px;
  background: var(--raised);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

.button:hover:not(:disabled) {
  background: #272830;
  border-color: #75717f;
}

.button.primary {
  background: var(--purple-bg);
  border-color: #73618f;
  color: #e7ddff;
}

.button.primary:hover:not(:disabled) {
  background: #403356;
  border-color: var(--purple);
}

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

button:disabled, fieldset:disabled .button {
  opacity: .55;
  cursor: wait;
}

input:disabled, select:disabled {
  opacity: .65;
}

.full-width {
  width: 100%;
}

.feedback {
  overflow-wrap: anywhere;
  word-break: break-word;
  margin: 14px 0 0;
}

.feedback:empty {
  margin: 0;
}

.feedback.error {
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #7a4c56;
  border-radius: 7px;
  padding: 11px 13px;
}

.feedback.success {
  color: var(--green);
}

.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px max(24px, calc((100vw - 1060px) / 2));
  border-bottom: 1px solid var(--line);
  background: #101114;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  font-size: 13px;
}

.header-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
}

.account-shell {
  max-width: 1060px;
  margin: 0 auto;
  padding: 36px 24px 64px;
  min-width: 0;
}

.page-heading {
  margin-bottom: 26px;
}

#identity {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.password-panel {
  max-width: 590px;
  margin-top: 24px;
}

.password-panel form {
  margin-top: 22px;
}

.notice {
  max-width: 720px;
  margin: 24px 0;
  padding: 18px 20px;
  border: 1px solid #716045;
  border-radius: 9px;
  background: #29251e;
  color: var(--amber);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.notice h2 {
  font-size: 16px;
  margin-bottom: 6px;
}

.notice p {
  margin: 0;
}

#admin-section {
  margin-top: 42px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.section-heading h2 {
  margin-bottom: 5px;
}

.section-heading .button {
  flex-shrink: 0;
}

#admin-fields {
  margin-top: 20px;
}

.create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(145px, .7fr);
  gap: 16px;
  margin-top: 20px;
}

.create-grid .field {
  margin-bottom: 0;
}

#create-user-form > .button {
  margin-top: 18px;
}

.user-list {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.user-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.user-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.user-heading h3 {
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-bottom: 5px;
}

.user-heading > div {
  min-width: 0;
}

.user-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  color: var(--muted);
}

.badge.active {
  color: var(--green);
  border-color: #3f5c4c;
}

.badge.pending {
  color: var(--amber);
  border-color: #716045;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.role-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.role-form .field {
  margin: 0;
}

.role-form select {
  min-width: 165px;
}

.reset-details {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 14px;
}

.reset-details summary {
  cursor: pointer;
  color: var(--purple);
  width: fit-content;
  padding: 8px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.reset-form {
  max-width: 440px;
  margin-top: 14px;
}

.reset-form .help {
  margin-bottom: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 10px;
  left: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--purple);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* -------------------------------------------------------------
   Reel Lab Responsive System: Auth & User Surfaces
   Breakpoints:
     - Desktop: >= 1180px (dense desktop layout, h1 26px, body 13px)
     - Compact: 960px - 1179px (compact layout)
     - Mobile: <= 959px (single-column forms, 44px tap targets, 16px inputs, gutter 16px, body 14px, h1 22px)
     - Narrow Mobile: <= 430px (360px - 430px, gutter 12px)
------------------------------------------------------------- */
@media (max-width: 959px) {
  body {
    font-size: 14px !important;
    line-height: 1.55 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  h1, .page-heading h1, .login-panel h1 {
    font-size: 22px !important;
    line-height: 1.25 !important;
  }

  input, select {
    font-size: 16px !important;
    min-height: 44px;
  }

  .login-shell {
    width: 100%;
    max-width: 100%;
    padding: 24px 16px max(32px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
  }

  .account-header {
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .account-header .wordmark {
    font-size: 16px;
    min-height: 44px;
  }

  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
  }

  .header-actions a,
  .header-actions .button {
    min-height: 44px;
    box-sizing: border-box;
  }

  .account-shell {
    padding: 20px 16px max(32px, env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .panel {
    padding: 18px 16px;
    border-radius: 10px;
  }

  .section-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .section-heading .button {
    width: 100%;
    min-height: 44px;
  }

  .create-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  #create-user-form > .button {
    width: 100%;
    min-height: 44px;
  }

  .password-panel {
    max-width: 100%;
    width: 100%;
  }

  .password-panel .button {
    width: 100%;
    min-height: 44px;
  }

  .user-card {
    padding: 16px;
  }

  .user-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .user-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .role-form {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .role-form .field {
    width: 100%;
  }

  .role-form select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .role-form .button {
    width: 100%;
    min-height: 44px;
  }

  .user-actions > .button.danger {
    width: 100%;
    min-height: 44px;
  }

  .reset-details summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
  }

  .reset-form {
    max-width: 100%;
    width: 100%;
  }

  .reset-form .button {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 430px) {
  .login-shell {
    padding: 20px 12px max(24px, env(safe-area-inset-bottom, 0px));
  }

  .account-header {
    padding: 12px;
  }

  .account-shell {
    padding: 16px 12px max(24px, env(safe-area-inset-bottom, 0px));
  }

  .panel {
    padding: 16px 12px;
  }

  .user-card {
    padding: 14px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
