/* ==============================================================================
   Saptari Post CMS — User Login & Reader Account Module Styles
   ============================================================================== */

/* Inline Email Field & "Send Code" Option */
.contact-email-field-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.contact-email-field-wrap input[type="email"] {
    width: 100%;
    padding-right: 110px !important;
}

.contact-inline-send-code {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--brand, #bd2434);
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 0.775rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
    z-index: 2;
    line-height: 1.2;
}

.contact-inline-send-code:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-50%) scale(1.02);
}

.contact-inline-send-code:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(30%);
}

.contact-inline-verified-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    font-weight: 700;
    color: #15803d;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    padding: 4px 8px;
    pointer-events: none;
    z-index: 2;
}

/* Inline OTP Verification Box */
.contact-otp-box {
    margin: 12px 0 16px;
    padding: 16px 18px;
    background: var(--card-bg, rgba(255, 255, 255, 0.85));
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    animation: otpSlideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes otpSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.contact-otp-inputs {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.contact-otp-inputs input {
    font-size: 1.15rem;
    letter-spacing: 0.25em;
    text-align: center;
    max-width: 240px;
    font-weight: 700;
    padding: 8px 12px;
}

.contact-verify-otp-btn {
    white-space: nowrap;
    padding: 10px 18px;
    font-weight: 600;
    height: 42px;
}

.contact-otp-status {
    margin-top: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 20px;
}

.status-success { color: #15803d; font-weight: 600; }
.status-error { color: #dc2626; font-weight: 600; }
.status-info { color: #2563eb; }

/* Locked / Disabled Submit Button */
button[data-contact-submit]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(40%);
    pointer-events: auto;
}

button[data-contact-submit]:disabled:hover {
    transform: none;
    filter: grayscale(40%);
}

/* Signed in badge on contact form */
.contact-signed-in-badge {
    margin-bottom: 18px;
}

.badge-verified {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #ecfdf5;
    color: #15803d;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-role {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Header Topline Account Link */
.topline-account-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-left: 12px;
}

.topline-account-link .account-user-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    stroke-width: 2.1;
}

.badge-unread {
    background: var(--brand, #bd2434);
    color: #ffffff;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 800;
    line-height: 1.2;
}

/* ==============================================================================
   Reader Account Dashboard (/account)
   ============================================================================== */
.account-dashboard {
    max-width: 1200px;
    margin: 0 auto 48px;
}

/* Account Header Panel — Relative Container for Top-Right Sign Out */
header.account-header.panel {
  position: relative;
  padding: 20px;
  border-radius: 12px;
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--line, #e5e7eb);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

/* Top-Right Compact Sign Out Button */
.account-signout-top {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
  z-index: 2;
}

.account-signout-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.account-signout-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.account-signout-btn:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

/* Identity Section (Leaves room on right for Sign Out button) */
.account-header__identity {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-right: 92px;
}

.account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand, #b91c1c);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 800;
  flex-shrink: 0;
}

.account-header__info {
  min-width: 0;
  flex: 1;
}

.account-header__name {
  margin: 0 0 2px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text, #0f172a);
  line-height: 1.25;
  word-break: break-word;
}

.account-header__email {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--muted, #64748b);
  word-break: break-all;
}

.account-header__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.account-badge--verified {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.account-badge--role {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.account-badge--uid {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

/* Compact Action Buttons Bar (Saved stories, Contact newsroom, Edit profile) */
.account-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line, #f1f5f9);
}

.account-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  font-size: 0.8rem !important;
  font-weight: 600;
  color: var(--text, #1e293b);
  background: var(--bg-alt, #f8fafc);
  border: 1px solid var(--line, #cbd5e1);
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.account-action-btn svg {
  width: 15px;
  height: 15px;
  color: var(--muted, #475569);
  flex-shrink: 0;
}

.account-action-btn:hover {
  background: var(--line, #f1f5f9);
  border-color: #94a3b8;
  color: var(--text, #0f172a);
}

.account-action-btn--edit {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

.account-action-btn--edit svg {
  color: #be123c;
}

.account-action-btn--edit:hover,
.account-action-btn--edit[aria-expanded="true"] {
  background: #ffe4e6;
  border-color: #fda4af;
}

/* Profile & Password Drawer */
.account-profile-drawer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line, #cbd5e1);
}

.account-profile-form__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.account-profile-form__header h3 {
  margin: 0 0 2px;
  font-size: 0.98rem;
  font-weight: 700;
}

.account-profile-form__header p {
  margin: 0;
  font-size: 0.8rem;
}

.password-last-updated-pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.password-last-updated-pill.is-unset {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.account-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.account-password-box {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg-alt, #f8fafc);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
}

.account-password-box h4 {
  margin: 0 0 10px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text, #1e293b);
}

/* ==============================================================================
   Password Input Wrap & Visibility Toggle Button Fix
   ============================================================================== */

.password-input-wrap {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
}

.password-input-wrap input {
  width: 100% !important;
  padding-right: 44px !important; /* Prevents text from colliding with the toggle button */
  box-sizing: border-box !important;
}

.pw-toggle-btn {
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  z-index: 10 !important; /* Ensures button stays on top of input focus rings */
  background: transparent !important;
  border: 0 !important;
  padding: 6px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: var(--muted, #64748b) !important;
  line-height: 1 !important;
  pointer-events: auto !important;
  transition: color 0.15s ease, transform 0.15s ease !important;
}

.pw-toggle-btn svg {
  width: 18px !important;
  height: 18px !important;
  stroke: currentColor !important;
  display: block !important;
  pointer-events: none !important; /* Prevents SVG path from intercepting click */
}

.pw-toggle-btn:hover {
  color: var(--brand, #dc2626) !important;
  transform: translateY(-50%) scale(1.08) !important;
}

.pw-toggle-btn:focus-visible {
  outline: 2px solid var(--brand, #dc2626) !important;
  outline-offset: 2px !important;
  border-radius: 4px !important;
}

/* Dark Mode Overrides */
body.theme-dark .pw-toggle-btn {
  color: #94a3b8 !important;
}
body.theme-dark .pw-toggle-btn:hover {
  color: #fca5a5 !important;
}

.pw-strength-checklist {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pw-strength-checklist li {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--line, #e2e8f0);
  color: var(--muted, #475569);
  transition: all 0.15s ease;
}

.pw-strength-checklist li.is-met {
  background: #dcfce7;
  color: #166534;
}

.pw-history-mini {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line, #e2e8f0);
  font-size: 0.76rem;
  color: var(--muted, #475569);
}

.pw-history-mini ul {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 4px;
}

.pw-history-mini li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.account-profile-form__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.account-save-btn {
  height: 34px;
  padding: 0 16px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--brand, #b91c1c);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.account-save-btn:hover {
  filter: brightness(1.1);
}

/* Mobile Specific Refinements (< 640px) */
@media (max-width: 640px) {
  header.account-header.panel {
    padding: 16px 14px;
  }
  .account-signout-top {
    top: 12px;
    right: 12px;
  }
  .account-signout-btn {
    height: 28px;
    padding: 0 8px;
    font-size: 0.71rem;
  }
  .account-header__identity {
    gap: 11px;
    padding-right: 78px;
  }
  .account-avatar {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
  }
  .account-header__name {
    font-size: 1.08rem;
  }
  .account-header__email {
    font-size: 0.78rem;
  }
  .account-header__actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
  }
  .account-action-btn {
    height: 32px;
    padding: 0 6px;
    font-size: 0.73rem !important;
    gap: 4px;
  }
  .account-action-btn svg {
    width: 13px;
    height: 13px;
  }
}

/* Dark Theme Overrides */
body.theme-dark .account-signout-btn {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}
body.theme-dark .account-signout-btn:hover {
  background: #dc2626;
  color: #ffffff;
}
body.theme-dark .account-badge--uid {
  background: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}
body.theme-dark .account-action-btn {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}
body.theme-dark .account-action-btn:hover {
  background: #334155;
}
body.theme-dark .account-action-btn--edit {
  background: #4c0519;
  border-color: #881337;
  color: #fda4af;
}
body.theme-dark .account-password-box {
  background: #0f172a;
  border-color: #334155;
}
body.theme-dark .pw-strength-checklist li {
  background: #334155;
  color: #94a3b8;
}
body.theme-dark .pw-strength-checklist li.is-met {
  background: #064e3b;
  color: #6ee7b7;
}

/* Dashboard Columns */
.account-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    align-items: start;
}

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

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 18px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--line, #e2e8f0);
}

.section-title-row h2 {
    margin: 0;
    font-size: 1.25rem;
}

/* Conversational Chat Container */
.chat-thread-container {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    padding: 0;
}

.chat-thread {
    max-height: 520px;
    min-height: 220px;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    background: var(--surface, #ffffff);
}

.chat-empty-intro {
    text-align: center;
    padding: 36px 20px;
    margin: auto 0;
}

.chat-empty-icon {
    font-size: 2.2rem;
    display: inline-block;
    margin-bottom: 8px;
}

.chat-empty-intro h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.chat-empty-intro p {
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.5;
    font-size: 0.9rem;
}

/* Chat Bubbles */
.chat-bubble-wrap {
    display: flex;
    width: 100%;
}

.chat-bubble-wrap--user {
    justify-content: flex-end;
}

.chat-bubble-wrap--admin {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 82%;
    padding: 12px 16px;
    font-size: 0.925rem;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
}

.chat-bubble--user {
    background: var(--brand, #bd2434);
    color: #ffffff;
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 2px 8px rgba(189, 36, 52, 0.2);
}

.chat-bubble-subject {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 4px;
    opacity: 0.92;
    letter-spacing: 0.2px;
}

.chat-bubble--user .chat-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.725rem;
    color: rgba(255, 255, 255, 0.82);
}

.chat-status-badge {
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

.chat-status--awaiting {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.chat-status--replied {
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

/* Admin / Editorial Reply Bubble */
.chat-bubble--admin {
    background: var(--bg, #f8fafc);
    color: var(--text, #1e293b);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 14px 14px 14px 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.chat-author-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.775rem;
    font-weight: 700;
    color: var(--brand, #bd2434);
    margin-bottom: 6px;
}

.chat-author-pill {
    background: var(--brand, #bd2434);
    color: #ffffff;
    font-size: 0.625rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.chat-bubble--admin .chat-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.725rem;
    color: var(--muted, #64748b);
}

.chat-official-label {
    background: var(--line, #e2e8f0);
    color: var(--muted, #475569);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Chat Lock Banner */
.chat-lock-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px dashed var(--line, #cbd5e1);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.chat-lock-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.chat-lock-text strong {
    display: block;
    margin-bottom: 2px;
    color: var(--text, #0f172a);
    font-size: 0.9rem;
}

.chat-lock-text p {
    margin: 0;
    color: var(--muted, #64748b);
    font-size: 0.825rem;
    line-height: 1.4;
}

/* Chat Composer Bar */
.chat-composer {
    border-top: 1px solid var(--line, #e2e8f0);
    padding: 16px 20px;
    background: var(--surface, #ffffff);
}

.chat-composer-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-subject-input {
    width: 100%;
    border: 1px solid var(--line, #cbd5e1);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg, #f8fafc);
}

.chat-composer textarea {
    width: 100%;
    border: 1px solid var(--line, #cbd5e1);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 72px;
    background: var(--bg, #f8fafc);
    color: var(--text, #1e293b);
    box-sizing: border-box;
}

.chat-composer textarea:focus,
.chat-subject-input:focus {
    outline: 2px solid var(--brand, #bd2434);
    background: #ffffff;
}

.chat-composer-locked textarea:disabled {
    background: rgba(0, 0, 0, 0.04);
    cursor: not-allowed;
    color: var(--muted, #94a3b8);
    resize: none;
    border-color: var(--line, #e2e8f0);
}

.chat-composer-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.chat-composer-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Saved Stories Sidebar Preview */
.saved-preview-list {
    padding: 16px 18px;
    border-radius: 10px;
}

.saved-preview-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--line, #e2e8f0);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.saved-preview-item:last-child {
    border-bottom: none;
}

.saved-preview-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--line, #f1f5f9);
}

.saved-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.saved-preview-body {
    flex-grow: 1;
    min-width: 0;
}

.saved-preview-title {
    display: block;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 6px;
    color: var(--text, #1e293b);
    text-decoration: none;
    font-size: 0.925rem;
}

.saved-preview-title:hover {
    color: var(--brand, #bd2434);
    text-decoration: underline;
}

.saved-preview-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.775rem;
}

.account-saved-remove-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--muted, #94a3b8);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: color 0.15s, background-color 0.15s;
}

.account-saved-remove-btn:hover {
    color: #e04b37;
    background-color: rgba(224, 75, 55, 0.1);
}

.account-saved-remove-btn:focus-visible {
    outline: 2px solid var(--brand, #bd2434);
    outline-offset: 1px;
}

.saved-preview-footer {
    margin-top: 14px;
    padding-top: 10px;
}

.full-width {
    width: 100%;
    text-align: center;
}

.view-all-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--brand, #bd2434);
    text-decoration: none;
}

.view-all-link:hover {
    text-decoration: underline;
}

/* Reader Login Page */
.reader-login-page {
    max-width: 520px;
    margin: 0 auto 48px;
}

.reader-login-panel {
    padding: 28px 32px;
    border-radius: 12px;
}

.reader-login-otp-section {
    margin: 16px 0 20px;
}


/* OTP Input Error & Success Styling */
.otp-input-error {
    border-color: #e02424 !important;
    background-color: #fff8f8 !important;
    box-shadow: 0 0 0 3px rgba(224, 36, 36, 0.15) !important;
    color: #e02424;
}

.otp-input-error::placeholder {
    color: #e02424 !important;
    opacity: 0.85;
    font-size: 0.85rem;
}

.otp-input-success {
    border-color: #057a55 !important;
    background-color: #f3faf7 !important;
    box-shadow: 0 0 0 3px rgba(5, 122, 85, 0.15) !important;
}

/* Subtle Horizontal Shake Animation */
@keyframes otpShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.otp-shake {
    animation: otpShake 0.4s ease-in-out;
}

/* Status Message Formatting */
.otp-status-message {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.otp-status-message--error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
}

.otp-status-message--success {
    background-color: #def7ec;
    color: #03543f;
    border: 1px solid #31c48d;
}

/* Dark mode overrides */
body.theme-dark .otp-input-error {
    border-color: #f87171 !important;
    background-color: rgba(224, 36, 36, 0.12) !important;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2) !important;
    color: #fca5a5;
}

body.theme-dark .otp-input-error::placeholder {
    color: #fca5a5 !important;
}

body.theme-dark .otp-input-success {
    border-color: #34d399 !important;
    background-color: rgba(16, 185, 129, 0.12) !important;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2) !important;
}

body.theme-dark .otp-status-message--error {
    background-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: #b91c1c;
}

body.theme-dark .otp-status-message--success {
    background-color: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-color: #047857;
}


/* ==============================================================================
   Reader Account Lockout Security Modal
   ============================================================================== */
.reader-lockout-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 16px;
}

.reader-lockout-modal {
    background: #ffffff;
    border-radius: 12px;
    max-width: 440px;
    width: 100%;
    padding: 32px 28px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.reader-lockout-icon {
    font-size: 42px;
    margin-bottom: 12px;
    line-height: 1;
}

.reader-lockout-modal h2 {
    font-size: 1.25rem;
    font-weight: 750;
    color: #111827;
    margin: 0 0 10px;
}

.reader-lockout-msg {
    font-size: 0.95rem;
    color: #b91c1c;
    font-weight: 600;
    line-height: 1.45;
    margin: 0 0 16px;
    background: #fef2f2;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #fecaca;
}

.reader-lockout-timer {
    font-family: ui-monospace, monospace;
    font-size: 1.15rem;
    font-weight: 800;
    color: #374151;
    background: #f3f4f6;
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.reader-lockout-note {
    font-size: 0.825rem;
    color: #6b7280;
    margin-bottom: 20px;
    line-height: 1.4;
}

/* Dark theme support */
body.theme-dark .reader-lockout-modal {
    background: #1f2937;
    color: #f9fafb;
    border: 1px solid #374151;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

body.theme-dark .reader-lockout-modal h2 {
    color: #f9fafb;
}

body.theme-dark .reader-lockout-msg {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
    border-color: #991b1b;
}

body.theme-dark .reader-lockout-timer {
    background: #111827;
    color: #e5e7eb;
    border: 1px solid #374151;
}

body.theme-dark .reader-lockout-note {
    color: #9ca3af;
}

.reader-uid-badge,
.reader-uid-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1e293b;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

body.theme-dark .reader-uid-badge,
body.theme-dark .reader-uid-pill {
  background: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}


/* Reader Auth Tabs */
.reader-auth-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 5px;
  border-radius: 10px;
  margin-bottom: 24px;
  border: 1px solid #e2e8f0;
}

.reader-auth-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.reader-auth-tab.is-active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.reader-auth-panel.is-hidden {
  display: none;
}

.label-row-between {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
}

.pw-switch-to-otp-btn {
  background: transparent;
  border: 0;
  color: var(--brand, #dc2626);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.pw-switch-to-otp-btn:hover {
  text-decoration: underline;
}

.reader-login-footer-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.5;
}

/* Dark Mode Overrides */
body.theme-dark .reader-auth-tabs,
body[data-theme="dark"] .reader-auth-tabs {
  background: #1e293b;
  border-color: #334155;
}
body.theme-dark .reader-auth-tab,
body[data-theme="dark"] .reader-auth-tab {
  color: #94a3b8;
}
body.theme-dark .reader-auth-tab.is-active,
body[data-theme="dark"] .reader-auth-tab.is-active {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
body.theme-dark .reader-login-footer-hint,
body[data-theme="dark"] .reader-login-footer-hint {
  border-color: #334155;
  color: #94a3b8;
}


/* ==============================================================================
   Background Scroll Lock (Locks Page Behind Modal)
   ============================================================================== */

html.glass-modal-locked,
body.glass-modal-locked {
  overflow: hidden !important;
  height: 100vh !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
  -webkit-overflow-scrolling: auto !important;
}

.glass-error-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  overscroll-behavior: contain;
  touch-action: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.glass-error-modal-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.glass-error-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}

.glass-error-modal {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(239, 68, 68, 0.38);
  border-radius: 22px;
  padding: 32px 28px 28px;
  text-align: center;
  box-shadow: 0 25px 60px -15px rgba(220, 38, 38, 0.28), 
              0 10px 25px -5px rgba(15, 23, 42, 0.1),
              inset 0 1px 0 rgba(255, 255, 255, 1);
  transform: scale(0.92) translateY(12px);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.glass-error-modal-overlay.is-active .glass-error-modal {
  transform: scale(1) translateY(0);
  animation: glassShake 0.4s ease-in-out;
}

@keyframes glassShake {
  0%, 100% { transform: scale(1) translateX(0); }
  20%, 60% { transform: scale(1) translateX(-5px); }
  40%, 80% { transform: scale(1) translateX(5px); }
}

/* Top-Right Close Button */
.glass-error-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.glass-error-close-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  transform: scale(1.08);
}

/* Icon and Glowing Halo */
.glass-error-icon-box {
  position: relative;
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.glass-error-icon-glow {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.45) 0%, rgba(220, 38, 38, 0.15) 50%, transparent 70%);
  filter: blur(8px);
  animation: pulseGlow 2.2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.6; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.1); }
}

.glass-error-icon {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 2px solid rgba(239, 68, 68, 0.45);
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px -4px rgba(220, 38, 38, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.9);
}

/* Modal Typography */
.glass-error-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #0f172a;
  margin: 0 0 10px;
}

.glass-error-message-box {
  background: rgba(254, 242, 242, 0.7);
  border: 1px solid rgba(254, 202, 202, 0.8);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.glass-error-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: #991b1b;
  line-height: 1.45;
  margin: 0;
}

.glass-error-hint {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.45;
  margin: 0 0 24px;
}

/* Action Buttons */
.glass-error-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.glass-error-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.glass-error-btn--primary {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}

.glass-error-btn--primary:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.42);
}

.glass-error-btn--secondary {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(203, 213, 225, 0.8);
  color: #334155;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.glass-error-btn--secondary:hover {
  background: #ffffff;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

/* Dark Mode Overrides */
body.theme-dark .glass-error-modal,
body[data-theme="dark"] .glass-error-modal {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.theme-dark .glass-error-close-btn,
body[data-theme="dark"] .glass-error-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

body.theme-dark .glass-error-title,
body[data-theme="dark"] .glass-error-title {
  color: #f8fafc;
}

body.theme-dark .glass-error-message-box,
body[data-theme="dark"] .glass-error-message-box {
  background: rgba(185, 28, 28, 0.18);
  border-color: rgba(239, 68, 68, 0.3);
}

body.theme-dark .glass-error-text,
body[data-theme="dark"] .glass-error-text {
  color: #fca5a5;
}

body.theme-dark .glass-error-hint,
body[data-theme="dark"] .glass-error-hint {
  color: #94a3b8;
}

body.theme-dark .glass-error-btn--secondary,
body[data-theme="dark"] .glass-error-btn--secondary {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(51, 65, 85, 0.9);
  color: #e2e8f0;
}

body.theme-dark .glass-error-btn--secondary:hover,
body[data-theme="dark"] .glass-error-btn--secondary:hover {
  background: #334155;
  color: #ffffff;
}

body.theme-dark .glass-error-icon,
body[data-theme="dark"] .glass-error-icon {
  background: linear-gradient(135deg, rgba(185, 28, 28, 0.4) 0%, rgba(127, 29, 29, 0.6) 100%);
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}
