/* ==========================================================================
   SMP design system — tokens, reset and shared components.
   Loaded by every page before its page stylesheet.
   ========================================================================== */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Surfaces */
  --bg: #f5f6f8;
  --bg-subtle: #eceff2;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f3f5f7;
  --surface-hover: #f1f3f5;
  --border: #e2e5e9;
  --border-strong: #cdd2d8;

  /* Text */
  --text: #0e161f;
  --text-muted: #48525e;
  --text-subtle: #66707c;

  /* SecurelyX blue (navy #0d1534 is used for dark brand panels). Mirrored in db/branding.js for emails. */
  --accent: #3a6df0;
  --accent-hover: #2a58d6;
  --accent-soft: #eaf0fe;
  --accent-ink: #1d3a9e;
  --accent-text: #ffffff;
  --brand-navy: #0d1534;

  /* Status */
  --success: #15803d;
  --success-soft: #e7f5ec;
  --warning: #9a5a06;
  --warning-soft: #fcf2df;
  --danger: #b93a30;
  --danger-hover: #9c2f26;
  --danger-soft: #fcebe9;

  --overlay: rgba(14, 22, 31, 0.48);
  --focus-ring: 0 0 0 3px rgba(58, 109, 240, 0.32);

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(14, 22, 31, 0.05);
  --shadow-sm: 0 1px 2px rgba(14, 22, 31, 0.04), 0 1px 3px rgba(14, 22, 31, 0.06);
  --shadow-md: 0 4px 12px rgba(14, 22, 31, 0.08), 0 1px 3px rgba(14, 22, 31, 0.06);
  --shadow-lg: 0 24px 48px -12px rgba(14, 22, 31, 0.22), 0 2px 6px rgba(14, 22, 31, 0.06);

  /* Shape */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 240ms;

  --control-h: 36px;
  --control-h-lg: 42px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0a0e13;
  --bg-subtle: #0f141a;
  --surface: #11171e;
  --surface-raised: #161d25;
  --surface-sunken: #0c1116;
  --surface-hover: #1a222b;
  --border: #222b35;
  --border-strong: #2f3a46;

  --text: #e8edf2;
  --text-muted: #a6b0bb;
  --text-subtle: #8792a0;

  --accent: #7b9cff;
  --accent-hover: #9bb4ff;
  --accent-soft: rgba(123, 156, 255, 0.14);
  --accent-ink: #a9c0ff;
  --accent-text: #0a1230;

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --warning: #f3b64c;
  --warning-soft: rgba(243, 182, 76, 0.12);
  --danger: #f47c72;
  --danger-hover: #f79a92;
  --danger-soft: rgba(244, 124, 114, 0.12);

  --overlay: rgba(2, 5, 8, 0.66);
  --focus-ring: 0 0 0 3px rgba(123, 156, 255, 0.38);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.65);

  color-scheme: dark;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

html[data-text-size="small"] { font-size: 14.88px; }
html[data-text-size="large"] { font-size: 17.92px; }
html[data-text-size="largest"] { font-size: 20px; }

html[data-reduce-motion="1"] *,
html[data-reduce-motion="1"] *::before,
html[data-reduce-motion="1"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

html[data-contrast="more"] { --text-muted: #2b333c; --text-subtle: #3d4651; --border: #8b949e; --border-strong: #5f6a76; }
html[data-contrast="more"][data-theme="dark"] { --text-muted: #d3dae1; --text-subtle: #bcc5ce; --border: #6d7885; --border-strong: #93a0ae; }

body {
  font-family: var(--font-sans);
  font-size: 0.875rem; /* 14px at the default size; follows the Text size setting */
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

ul,
ol {
  list-style: none;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--text);
}

strong {
  font-weight: 600;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

[hidden],
.hidden {
  display: none !important;
}

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

/* ---------- Buttons ---------- */
.btn,
.login-button,
.sso-button,
.submit-button,
.new-message-button,
.create-message-button,
.file-browse-button,
.logout-button,
.modal-btn,
.download-btn,
.export-proof-btn,
.btn-copy,
.clear-date-btn,
#sendAccessorReplyBtn,
#replySuccessOkBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  user-select: none;
}

.btn:hover,
.sso-button:hover,
.file-browse-button:hover,
.logout-button:hover,
.modal-btn:hover,
.download-btn:hover,
.export-proof-btn:hover,
.btn-copy:hover,
.clear-date-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn:active,
.login-button:active,
.sso-button:active,
.submit-button:active,
.new-message-button:active,
.create-message-button:active,
.modal-btn:active,
.download-btn:active,
#sendAccessorReplyBtn:active,
#replySuccessOkBtn:active {
  transform: translateY(1px);
}

/* Primary */
.btn--primary,
.login-button,
.submit-button,
.new-message-button,
.create-message-button,
#confirmButton,
#submitSecretKeyBtn,
#dismissSecretKeyBtn,
#sendReplyBtn,
#sendAccessorReplyBtn,
#replySuccessOkBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn--primary:hover,
.login-button:hover,
.submit-button:hover,
.new-message-button:hover,
.create-message-button:hover,
#confirmButton:hover,
#submitSecretKeyBtn:hover,
#dismissSecretKeyBtn:hover,
#sendReplyBtn:hover,
#sendAccessorReplyBtn:hover,
#replySuccessOkBtn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}

/* Danger */
.btn--danger,
.btn-delete {
  color: var(--danger);
  border-color: var(--border-strong);
  background: var(--surface);
}

.btn--danger:hover,
.btn-delete:hover {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}

/* Ghost */
.btn--ghost,
.clear-date-btn {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-muted);
}

.btn--ghost:hover,
.clear-date-btn:hover {
  background: var(--surface-hover);
  border-color: transparent;
  color: var(--text);
}

.btn--lg {
  height: var(--control-h-lg);
  padding: 0 18px;
  font-size: 0.875rem;
}

.btn--sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.78125rem;
}

.btn--icon {
  width: var(--control-h);
  padding: 0;
}

.btn--block {
  width: 100%;
}

.btn i,
.download-btn i {
  font-size: 0.8125rem;
}

button:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- Form controls ---------- */
.input-field,
.field-input,
.modal-select,
input[type="search"],
input[type="date"] {
  width: 100%;
  height: var(--control-h-lg);
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.input-field::placeholder,
.field-input::placeholder {
  color: var(--text-subtle);
}

.input-field:hover,
.field-input:hover,
.modal-select:hover {
  border-color: color-mix(in srgb, var(--text-subtle) 55%, var(--border-strong));
}

.input-field:focus,
.field-input:focus,
.modal-select:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.input-field:disabled {
  background: var(--surface-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}

.modal-select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-subtle) 50%), linear-gradient(135deg, var(--text-subtle) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label,
.form-group > label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.field-help {
  font-size: 0.78125rem;
  color: var(--text-subtle);
}

.mono {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
}

/* Range */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}

input[type="range"]:focus-visible {
  box-shadow: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--focus-ring);
}

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.badge--plain::before {
  display: none;
}

.badge--accent,
.badge--active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: transparent;
}

.badge--danger,
.badge--expired {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  font-size: 0.71875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

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

.theme-toggle__track {
  position: relative;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  font-size: 0.875rem;
}

.theme-toggle__track i {
  grid-area: 1 / 1;
  transition: opacity var(--dur) var(--ease), transform var(--dur-slow) var(--ease);
}

.theme-toggle__moon {
  opacity: 0;
  transform: rotate(-60deg) scale(0.6);
}

:root[data-theme="dark"] .theme-toggle__sun {
  opacity: 0;
  transform: rotate(60deg) scale(0.6);
}

:root[data-theme="dark"] .theme-toggle__moon {
  opacity: 1;
  transform: none;
}

/* Fallback if theme.js rebuilds the toggle with its default thumb markup */
.theme-toggle__thumb {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 2px solid currentColor;
}

.theme-toggle--floating {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

/* ---------- Tooltips ---------- */
.tooltip-container {
  position: relative;
  display: inline-flex;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--text-subtle);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: help;
  background: var(--surface);
  flex-shrink: 0;
}

.tooltip-text,
.tooltip-icon[data-tooltip]::after {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 40;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
  pointer-events: none;
}

.tooltip-icon[data-tooltip] {
  position: relative;
}

.tooltip-icon[data-tooltip]::after {
  content: attr(data-tooltip);
  left: auto;
  right: -6px;
  transform: translate(0, 4px);
}

.tooltip-container:hover .tooltip-text,
.tooltip-container:focus-within .tooltip-text {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.tooltip-icon[data-tooltip]:hover::after,
.tooltip-icon[data-tooltip]:focus::after {
  opacity: 1;
  visibility: visible;
  transform: translate(0, 0);
}

/* ---------- Modal / dialog ---------- */
.modal,
.auth-modal,
.reply-success-modal,
.ui-dialog {
  position: fixed;
  inset: 0;
  /* Above full-screen editors (3400), the file viewer (3500) and menus (4000); below toasts (5000) */
  z-index: 4500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--overlay);
  overflow-y: auto;
  animation: smp-fade var(--dur) var(--ease);
}

.auth-modal:not([hidden]),
.reply-success-modal:not(.hidden),
.ui-dialog {
  display: flex;
}

.modal-content,
.auth-modal__panel,
.reply-success-content,
.ui-dialog__panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: auto;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: smp-rise var(--dur-slow) var(--ease);
}

.modal-content h2,
.auth-modal__panel h2,
.reply-success-content h2,
.ui-dialog__panel h2 {
  font-size: 1.125rem;
  margin-bottom: 6px;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.close-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

#modalMessage {
  padding-right: 24px;
  color: var(--text);
  font-size: 0.90625rem;
  line-height: 1.6;
}

#confirm-and-cancel-div,
.secret-modal-buttons,
.auth-modal__actions,
.ui-dialog__footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

/* Keep the confirm button visually primary but put Cancel first in reading order. */
#confirm-and-cancel-div #confirmButton {
  order: 2;
}

.ui-dialog__panel {
  max-width: 440px;
  padding: 0;
  overflow: hidden;
}

.ui-dialog__header {
  padding: 20px 24px 0;
}

.ui-dialog__header p {
  margin-top: 4px;
  color: var(--text-muted);
}

.ui-dialog__body {
  display: grid;
  gap: 12px;
  padding: 16px 24px 4px;
  max-height: 55vh;
  overflow-y: auto;
}

.ui-dialog__footer {
  margin-top: 16px;
  padding: 14px 24px;
  background: var(--surface-sunken);
  border-top: 1px solid var(--border);
}

.ui-dialog__error {
  font-size: 0.8125rem;
  color: var(--danger);
}

.check-list {
  display: grid;
  gap: 2px;
  margin: 0 -8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.check-item:hover {
  background: var(--surface-hover);
}

.check-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.check-list__actions {
  display: flex;
  gap: 4px;
  margin: 0 -10px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 5000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 440px);
  padding: 12px 14px 12px 16px;
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--bg);
  font-size: 0.84375rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
}

.toast.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast-icon {
  font-size: 0.9375rem;
  color: var(--accent);
}

:root[data-theme="dark"] .toast-icon {
  color: #3a6df0;
}

/* "Powered by SecurelyX.com" — always shown, not part of branding */
.powered-by {
  margin-top: 14px;
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-align: center;
}

.powered-by a {
  color: inherit;
  text-decoration: none;
}

.powered-by a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.powered-by--page {
  margin: 24px auto 32px;
}

.powered-by--sidebar {
  margin: 0;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast-close {
  margin-left: 4px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: inherit;
  opacity: 0.7;
  font-size: 1.125rem;
  line-height: 1;
}

.toast-close:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--bg) 14%, transparent);
}

/* ---------- Loading overlay ---------- */
.loading-spinner,
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.loading-overlay {
  display: flex;
}

.loading-shell {
  display: grid;
  justify-items: center;
  gap: 16px;
  width: 100%;
  max-width: 340px;
  padding: 28px 24px 24px;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.loading-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.71875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.loading-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.loading-orbit {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
}

.spinner,
.spinner-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: smp-spin 0.8s linear infinite;
}

.loading-copy h3 {
  font-size: 0.9375rem;
  margin-bottom: 4px;
}

.loading-copy p {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.loading-progress {
  width: 100%;
  gap: 8px;
}

.loading-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.loading-progress-track,
.file-progress-container {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  overflow: hidden;
}

#uploadProgressBar,
.file-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur) linear;
}

/* Progress overlay created in JS (reply uploads) */
#globalProgressOverlay {
  background: color-mix(in srgb, var(--bg) 72%, transparent) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#globalProgressOverlay > div {
  background: var(--surface-raised) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg);
  padding: 22px 24px !important;
  font-size: 0.8125rem;
}

#globalProgressOverlay > div > div:first-child {
  background: var(--surface-sunken) !important;
  height: 6px !important;
}

#globalProgressBar {
  background: var(--accent) !important;
}

#globalProgressText {
  margin-top: 12px !important;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Files ---------- */
.file-list {
  display: grid;
  gap: 6px;
}

.file-list:empty {
  display: none;
}

.file-item,
.reply-file-row,
.uploaded-file-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.file-name,
.reply-file,
.uploaded-file-name {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-file,
.remove-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.remove-file:hover,
.remove-chip:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.file-item .file-progress-container,
.reply-file-row .file-progress-container,
.uploaded-file-item .file-progress-container {
  flex-basis: 100%;
}

/* Drop zones */
.drop-zone,
#fileDropZone,
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.drop-zone:hover,
#fileDropZone:hover,
.file-drop:hover,
#fileDropZone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#fileDropZone > i,
.file-drop > i,
.drop-zone__icon {
  font-size: 1.25rem;
  color: var(--accent);
}

.drop-zone strong {
  color: var(--text);
}

/* ---------- Replies (shared by sender + recipient views) ---------- */
.reply-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.reply-box--mine {
  border-left: 3px solid var(--accent);
}

.reply-box--other {
  border-left: 3px solid var(--border-strong);
}

.reply-meta {
  display: grid;
  gap: 6px;
}

.reply-meta-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.reply-owner-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
}

.reply-owner-badge--mine {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.reply-owner-badge--other {
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.reply-meta-time {
  font-size: 0.78125rem;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.reply-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.reply-meta-grid strong {
  color: var(--text-subtle);
  font-weight: 500;
}

.reply-message-label,
.reply-file-label {
  font-size: 0.71875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.reply-files {
  display: grid;
  gap: 6px;
}

/* ---------- SunEditor skin ---------- */
.sun-editor {
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-md) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  font-family: var(--font-sans) !important;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.sun-editor .se-toolbar {
  background: var(--surface-sunken) !important;
  outline: none !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 4px 6px !important;
}

.sun-editor .se-btn-module-border {
  border-color: transparent !important;
}

.sun-editor .se-btn {
  color: var(--text-muted) !important;
  border-radius: var(--radius-sm) !important;
}

.sun-editor .se-btn:enabled:hover,
.sun-editor .se-btn:enabled:focus {
  background: var(--surface-hover) !important;
  color: var(--text) !important;
}

.sun-editor .se-btn:enabled.active {
  background: var(--accent-soft) !important;
  color: var(--accent-ink) !important;
}

.sun-editor .se-wrapper,
.sun-editor .se-wrapper-inner,
.sun-editor .se-wrapper-wysiwyg {
  background: var(--surface) !important;
  color: var(--text) !important;
}

.sun-editor .se-resizing-bar {
  background: var(--surface-sunken) !important;
  border-top: 1px solid var(--border) !important;
}

.sun-editor .se-list-layer,
.sun-editor .se-dialog .se-dialog-inner .se-dialog-content,
.sun-editor .se-submenu {
  background: var(--surface-raised) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-md) !important;
}

.sun-editor .se-list-layer .se-list-inner .se-list-basic li button {
  color: var(--text) !important;
}

.sun-editor .se-list-layer .se-list-inner .se-list-basic li button:hover {
  background: var(--surface-hover) !important;
}

.sun-editor-editable {
  font-family: var(--font-sans) !important;
}

/* (SecurelyX app) Text in a reader without its own frame (the message on the recipient page) follows the page
   theme like the framed editors do (src/theme.js): links, quotes and code in the theme's colours, not the editor's
   default blue */
.is-reader .sun-editor-editable a {
  color: var(--accent) !important;
}

.is-reader .sun-editor-editable blockquote {
  border-left: 3px solid color-mix(in srgb, var(--accent) 40%, transparent) !important;
  background: color-mix(in srgb, var(--accent) 7%, transparent) !important;
  color: var(--text-muted) !important;
}

.is-reader .sun-editor-editable code,
.is-reader .sun-editor-editable pre {
  background: color-mix(in srgb, var(--text) 7%, transparent) !important;
  color: var(--text) !important;
}

.is-reader .sun-editor-editable table,
.is-reader .sun-editor-editable th,
.is-reader .sun-editor-editable td,
.is-reader .sun-editor-editable hr {
  border-color: var(--border) !important;
}

/* Read-only viewers: the toolbar only holds the full-screen button, so float it
   in the corner instead of giving it a whole bar. */
.is-reader .sun-editor {
  position: relative;
}

.is-reader .sun-editor:not(.se-fullscreen-mode) .se-toolbar {
  position: absolute !important;
  top: 6px;
  right: 6px;
  left: auto !important;
  z-index: 3;
  width: auto !important;
  padding: 0 !important;
  background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm);
}

.is-reader .sun-editor:not(.se-fullscreen-mode) .se-toolbar .se-btn-module {
  margin: 0 !important;
}

.is-reader .sun-editor .se-toolbar-sticky-dummy {
  display: none !important;
}

/* Keep the text clear of the floating full-screen button */
.is-reader .sun-editor:not(.se-fullscreen-mode) .se-wrapper {
  padding-right: 46px;
}

/* ---------- Empty / status text ---------- */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 1.375rem;
  color: var(--text-subtle);
}

.empty-state strong {
  color: var(--text);
  font-size: 0.875rem;
}

/* ---------- Animations ---------- */
@keyframes smp-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes smp-fade {
  from {
    opacity: 0;
  }
}

@keyframes smp-rise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

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

  .spinner,
  .spinner-circle {
    animation: smp-spin 1.6s linear infinite !important;
  }
}

@media (pointer: coarse) {
  .btn,
  .login-button,
  .sso-button,
  .submit-button,
  .new-message-button,
  .create-message-button,
  .modal-btn,
  .download-btn,
  .export-proof-btn,
  .btn-copy,
  #sendAccessorReplyBtn,
  #replySuccessOkBtn {
    min-height: 44px;
  }

  .theme-toggle,
  .btn--icon {
    width: 44px;
    height: 44px;
  }
}

/* ---------- Announcement / maintenance bar (admin panel → System; added by src/brand.js) ---------- */
.smp-notice {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
}

.smp-notice__item {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 10px 16px;
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--border);
}

.smp-notice__item i {
  margin-top: 3px;
}

.smp-notice__item--info {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.smp-notice__item--warning {
  background: var(--warning-soft);
  color: var(--warning);
}
