* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces */
  --color-surface-muted: #f7f7f8;
  --color-surface: #ffffff;
  --color-surface-warm: #f0f4ff;

  /* Text */
  --color-text: #1e1e2a;
  --color-text-subtle: #5a5a6a;
  --color-heading: #14141f;
  --color-label: #5a5a6a;
  --color-muted: #5a5a6a;
  --color-text-soft: #5a5a6a;
  --color-text-on-accent: #ffffff;

  /* Accent — IAA Blue */
  --color-accent: #3a7bc8;
  --color-accent-hover: #2f6ab0;
  --color-accent-press: #255a98;

  /* Borders */
  --color-border-input: #e2e2e8;
  --color-border-strong: #cdcdd6;
  --color-border-fieldset: #e2e2e8;
  --color-border-subtle: #e2e2e8;

  /* Feedback */
  --color-success-bg: #dff0d8;
  --color-success-text: #3c6e47;
  --color-success-border: #c8e0c0;
  --color-error-bg: #fbe9e7;
  --color-error-text: #872e2e;
  --color-error-border: #f5cecb;

  /* Buttons — default */
  --color-btn-default: #e8e8ee;
  --color-btn-default-hover: #d8d8e0;
  --color-btn-default-press: #c8c8d4;

  /* Cards */
  --color-staff-card-press: #e0ecf9;

  /* Shadows & overlay */
  --color-overlay: rgba(0,0,0,var(--opacity-overlay));
  --opacity-overlay: 0.5;
  --opacity-shadow: 0.15;
  --shadow-focus-ring: 0 0 0 2px rgba(58,123,200,0.15);
  --shadow-modal: 0 8px 30px rgba(0,0,0,var(--opacity-shadow));

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Surface — 2-stop depth: muted → surface → warm */
    --color-surface-muted: #0e0e12;
    --color-surface: #16161a;
    --color-surface-warm: #161824;

    /* Text — dark backgrounds need lighter, more saturated values */
    --color-text: #e8e8ec;
    --color-heading: #f0f0f4;
    --color-label: #a4a4b8;
    --color-muted: #707084;
    --color-text-subtle: #808096;

    /* Borders — card separation needs more contrast */
    --color-border-input: #2e2e38;
    --color-border-strong: #3e3e48;
    --color-border-fieldset: #2e2e38;
    --color-border-subtle: #22222a;

    /* Feedback — light backgrounds, dark text (light-mode values are invisible in dark) */
    --color-success-bg: #14281a;
    --color-success-text: #6ec478;
    --color-success-border: #1a3a24;
    --color-error-bg: #2c1a1a;
    --color-error-text: #e8a09e;
    --color-error-border: #3e2828;

    /* Buttons — lighter default so hover transition is perceptible */
    --color-btn-default: #3a3a44;
    --color-btn-default-hover: #484854;
    --color-btn-default-press: #565662;
    --color-staff-card-press: #161824;

    /* Shadows — stronger dark-mode overlay, inset highlight for elevation */
    --opacity-overlay: 0.35;
    --shadow-focus-ring: 0 0 0 2px rgba(58,123,200,0.4);
    --shadow-card-highlight: inset 0 1px 0 rgba(255,255,255,0.04);
  }
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-surface-muted);
  color: var(--color-text);
  line-height: 1.5;
}

.container {
  max-width: 640px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ---------- Auth screen (login) ---------- */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-screen .container {
  margin: 0;
  width: 100%;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--color-heading);
  text-wrap: balance;
}

.success-msg {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid var(--color-success-border);
}

.field,
.field-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-label);
}

.help-text {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.field-row {
  display: flex;
  gap: 1rem;
}
.field-row .field {
  flex: 1;
}

input[type="text"],
input[type="email"],
input[type="datetime-local"],
input[type="date"],
input[type="time"],
select,
textarea,
input[type="password"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s;
  background: var(--color-surface);
  color: var(--color-text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus-ring);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.hidden { display: none !important; }

/* A11y helper */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-block;
  padding: 0.8rem 1rem;
  background: var(--color-btn-default);
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.25;
  transition: background 0.15s;
}

.btn:hover { background: var(--color-btn-default-hover); }
.btn:active { background: var(--color-btn-default-press); }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  padding: 0.75rem 1.5rem;
}
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:active { background: var(--color-accent-press); }

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.staff-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.staff-name-display {
  font-size: 0.9rem;
  color: var(--color-text-subtle);
  flex: 1 1 12rem;
  min-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.locations {
  border: 1px solid var(--color-border-fieldset);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.locations legend {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0 0.5rem;
}

.checkbox-group label {
  font-weight: 400;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
}

.form-actions {
  margin-top: 1.5rem;
}

.errors {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  border: 1px solid var(--color-error-border);
}
.errors ul { margin: 0.25rem 0 0 1.25rem; }
.errors li { margin-bottom: 0.25rem; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal), var(--shadow-card-highlight);
  /* ponytail: dark-mode border prevents content from blending into background */
  border: 1px solid var(--color-border-subtle);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.modal-header h2 { font-size: 1.1rem; margin: 0; }

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-muted);
  line-height: 1;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}
.btn-close:hover { color: var(--color-heading); }

.modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

#staff-search-input {
  margin-bottom: 1rem;
}

.staff-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.staff-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: transparent;
  font: inherit;
  transition: background 0.1s, border-color 0.1s;
}

.staff-card:hover {
  background: var(--color-surface-warm);
  border-color: var(--color-accent);
}

.staff-card:active {
  background: var(--color-staff-card-press);
  border-color: var(--color-accent);
}

.staff-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.staff-card img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-border-strong);
  flex-shrink: 0;
}

.staff-card .staff-info {
  flex: 1;
  min-width: 0;
}

.staff-card .staff-name {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
}

.staff-card .staff-detail {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.staff-card .staff-detail span {
  display: inline-block;
  margin-right: 0.5rem;
}

/* Loading spinner */
.spinner {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-soft);
}

/* Button disabled / loading */
.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Login page */
.login-section {
  margin-top: 3rem;
  text-align: center;
}

.login-section p {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.login-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid var(--color-error-border);
  font-size: 0.9rem;
}

.office-staff-list {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--color-muted);
  line-height: 1.4;
}
.office-staff-list:empty {
  display: none;
}

/* Office tag chips for "otros" multi-despacho */
.office-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.office-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.office-tag-chip .remove-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--color-muted);
  padding: 0;
  border-radius: 50%;
}
.office-tag-chip .remove-tag:hover {
  color: var(--color-error-text);
  background: var(--color-error-bg);
}

/* ============ Tab bar ============ */
.tab-bar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  border-bottom: 2px solid var(--color-border-subtle);
  margin-bottom: 1.5rem;
  gap: 0;
}

.tab-bar-tabs {
  display: flex;
  gap: 0;
  flex: 1;
}

.tab {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-subtle);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
  text-align: center;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-accent);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-accent);
}

.tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.logout-box {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-subtle);
  background: transparent;
  text-decoration: none;
  border: 1px solid #d4a0a0;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-logout:hover {
  color: var(--color-error-text);
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
}

/* ============ Panels ============ */
.panel {
  display: block;
}

.panel.hidden {
  display: none;
}

/* ============ History filters ============ */
.history-filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}

.history-filters .field {
  margin-bottom: 0;
  flex: 1;
  min-width: 140px;
}

.history-filters label {
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.history-filters input,
.history-filters select {
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
}

.export-buttons {
  flex: 0 0 auto;
  min-width: auto;
}

.export-btn-group {
  display: flex;
  gap: 0.4rem;
}

.btn-export {
  padding: 0.45rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-subtle);
  transition: all 0.12s;
}

.btn-export:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-surface-warm);
}

.btn-export:active {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  border-color: var(--color-accent);
}

/* ============ History cards ============ */
.history-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-right: 2.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  /* ponytail: dark-mode inset highlight gives cards visual lift from the page */
  box-shadow: var(--shadow-card-highlight);
  transition: border-color 0.15s;
  position: relative;
}

.history-card:hover {
  border-color: var(--color-border-strong);
}

.history-card-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  opacity: 0;
}

.history-card:hover .history-card-delete {
  opacity: 1;
}

.history-card-delete:hover {
  background: var(--color-danger-bg, #fee2e2);
  color: var(--color-danger, #dc2626);
}

.history-card-delete:active {
  background: var(--color-danger, #dc2626);
  color: white;
}

.history-card-photo {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-border-strong);
  margin-top: 0.15rem;
}

.history-card-badge {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-on-accent);
  margin-top: 0.15rem;
}

.history-card-badge.plantilla,
.history-card-badge.colaborador {
  background: #3a7bc8;
}

.history-card-badge.visitante {
  background: #6c9e3a;
}

.history-card-badge.otros {
  background: #b07a3a;
}

.history-card-body {
  flex: 1;
  min-width: 0;
}

.history-card-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.history-card-date {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
  white-space: nowrap;
}

.history-card-building {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--color-surface-muted);
  color: var(--color-text-subtle);
}

.history-card-person {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 0.1rem;
}

.history-card-person-type {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.history-card-meta {
  font-size: 0.8rem;
  color: var(--color-muted);
  line-height: 1.4;
}

.history-card-meta span {
  display: inline-block;
  margin-right: 0.5rem;
}

.history-empty {
  text-align: center;
  padding: 2rem;
  color: var(--color-muted);
}

.history-status {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
  text-align: center;
}

/* ============ Office autocomplete ============ */
.office-autocomplete {
  display: flex;
  gap: 0.4rem;
  position: relative;
}

.office-autocomplete input {
  flex: 1;
}

/* ---------- .btn-add-office (multi-despacho removed — commented out) ---------- */
/* Multi-despacho was replaced by a single office field. Style kept for reference.

.btn-add-office {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}

.btn-add-office:hover {
  background: var(--color-surface-warm);
  border-color: var(--color-accent);
}

.btn-add-office:active {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  border-color: var(--color-accent);
}

*/

/* ---------- Delete confirmation modal (design system) ---------- */
.ds-modal-inner {
  background: var(--color-surface);
  border-radius: var(--radius-md, 8px);
  width: 90%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal, 0 8px 30px rgba(0,0,0,0.15));
}

.ds-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border, #e2e2e8);
}

.ds-modal-title {
  font-family: Inter, system-ui, sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text, #14141f);
}

.ds-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-muted, #5a5a6a);
  line-height: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm, 4px);
  transition: background 0.15s, color 0.15s;
}

.ds-modal-close:hover {
  color: var(--color-text, #14141f);
}

.ds-modal-body {
  padding: 1rem 1.25rem;
}

.ds-modal-body p {
  color: var(--color-text-subtle, #5a5a6a);
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.ds-modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 0.75rem 1.25rem 1rem;
}

.ds-btn-delete {
  background: var(--color-danger, #dc2626);
  color: #fff;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.25;
  transition: background 0.15s;
}

.ds-btn-delete:hover {
  background: #b91c1c;
}

.ds-btn-delete:active {
  background: #991b1b;
}

.ds-btn-delete:focus-visible {
  outline: 2px solid var(--color-danger, #dc2626);
  outline-offset: 2px;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  /* ponytail: drop shadow is invisible on dark backgrounds — inset top highlight provides dark-mode elevation */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255,255,255,0.03);
}

.autocomplete-dropdown.hidden {
  display: none;
}

.autocomplete-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text);
  transition: background 0.1s;
}

.autocomplete-item:hover {
  background: var(--color-surface-warm);
}

.autocomplete-item.active {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
}

.autocomplete-empty {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  font-style: italic;
}

@media (max-width: 600px) {
  .history-filters {
    flex-direction: column;
  }

  .history-filters .field {
    min-width: auto;
  }

  .history-card {
    flex-direction: column;
    gap: 0.4rem;
    padding-right: 2.5rem;
  }

  .history-card-header {
    flex-wrap: wrap;
  }

  .ds-modal-footer {
    flex-direction: column;
  }

  .ds-modal-inner {
    width: 94%;
    max-width: 380px;
  }
}

/* ============ Help icon + modal ============ */
.help-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  font-size: 0.85rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  margin-left: 0.35rem;
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 1;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out;
  z-index: 1;
}

/* Invisible hit-area layer → 44px touch target */
.help-icon::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  pointer-events: none;
}

.help-icon:hover::before {
  background: transparent;
}

.help-icon:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.help-icon:active {
  background: var(--color-accent-press);
  border-color: var(--color-accent-press);
  transform: scale(0.95);
}

.help-icon:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Help modal overlay */
.help-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-modal-inner {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--color-border-subtle);
  position: relative;
}

.help-modal-heading {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 1rem 0 0.375rem;
  margin: 0;
  color: var(--color-heading);
}

.help-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-muted);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}

.help-modal-close:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.help-modal-close:hover {
  background: var(--color-surface-warm);
  color: var(--color-text);
}

.help-modal-content {
  padding: 0 1.25rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

.help-modal-text {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text-subtle);
  padding-left: 0.375rem;
}

.help-modal-text p {
  margin: 0 0 0.5rem;
}

.help-modal-text p:last-child {
  margin-bottom: 0;
}

.help-modal-text ul,
.help-modal-text ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.help-modal-text li {
  margin-bottom: 0.35rem;
}

@media (max-width: 600px) {
  .help-modal-inner {
    width: 94%;
    max-width: 380px;
  }
}

/* ---------- Dark-mode browser surfaces (per impeccable craft floor) ---------- */
@media (prefers-color-scheme: dark) {
  ::selection {
    background: rgba(58, 123, 200, 0.35);
    color: #ffffff;
  }

  ::-moz-selection {
    background: rgba(58, 123, 200, 0.35);
    color: #ffffff;
  }

  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--color-surface-muted);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-input);
  }

  ::-webkit-scrollbar-corner {
    background: var(--color-surface-muted);
  }

  ::placeholder {
    color: var(--color-muted);
    opacity: 1;
  }
}


