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

:root {
  --color-primary: #f26522;
  --color-primary-dark: #d4551a;
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #212121;
  --color-text-secondary: #757575;
  --color-border: #e0e0e0;
  --color-danger: #d32f2f;
  --topbar-height: 48px;
  --sidebar-width: 280px;
  /* iOS "Aggiungi a Home": la webapp parte in standalone e con
     viewport-fit=cover + status-bar translucida disegna SOTTO l'orologio.
     Queste insets riservano lo spazio. Su Android/desktop valgono 0,
     quindi il layout resta identico. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
  height: 100%;
  font-family: 'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
}

/* === Top Bar === */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* la barra si estende dietro la status bar (sfondo arancio pieno) ma il
     contenuto — menu/titolo — viene spinto sotto orologio e notch */
  height: calc(var(--topbar-height) + var(--safe-top));
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-top) calc(4px + var(--safe-right)) 0 calc(4px + var(--safe-left));
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

#topbar-title {
  font-family: 'Audiowide', sans-serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: .5px;
}

.topbar-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-btn:hover {
  background: rgba(255,255,255,.15);
}

/* Battery badge */
.battery-badge {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(255,255,255,.2);
}

/* === Sidebar === */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  /* box-sizing:border-box globale: allargo la sidebar di quanto le tolgo
     in padding, così la larghezza utile resta --sidebar-width */
  width: calc(var(--sidebar-width) + var(--safe-left));
  padding: var(--safe-top) 0 var(--safe-bottom) var(--safe-left);
  background: var(--color-surface);
  z-index: 300;
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0,0,0,.15);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header h2 {
  font-size: 16px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.account-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.account-list li {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background .15s;
}

.account-list li:hover {
  background: #f5f5f5;
}

.account-list li.active {
  background: #fff3e0;
  border-left: 3px solid var(--color-primary);
}

.account-list li .account-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.account-list li .account-info {
  flex: 1;
  min-width: 0;
}

.account-list li .account-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-list li .account-url {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-list li .account-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 4px;
}

.sidebar-add-btn {
  margin: 8px 16px 16px;
  padding: 10px;
  background: none;
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all .15s;
}

.sidebar-add-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* === Main content === */
#main-content {
  position: fixed;
  top: calc(var(--topbar-height) + var(--safe-top));
  left: var(--safe-left);
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  overflow-y: auto;
}

/* openHAB iframe — fills the area below the topbar, header stays visible */
.openhab-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.openhab-frame.hidden { display: none; }

/* Account cards */
.account-cards {
  padding: 20px 16px;
  max-width: 480px;
  margin: 0 auto;
}

.account-cards.hidden {
  display: none;
}

.account-cards h2 {
  font-size: 15px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.account-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: box-shadow .15s;
}

.account-card:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
}

.account-card .card-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  flex-shrink: 0;
}

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

.account-card .card-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 2px;
}

.account-card .card-page {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.account-card .card-connect {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.account-card .card-connect:hover {
  background: var(--color-primary-dark);
}

.card-default-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--color-primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  vertical-align: middle;
  letter-spacing: .5px;
}

/* Welcome screen */
.welcome-screen {
  position: absolute;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.welcome-screen.hidden {
  display: none;
}

.welcome-content h1 {
  margin: 16px 0 8px;
  font-size: 22px;
}

.welcome-content p {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right))
           calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  /* 100% = altezza già al netto delle insets del contenitore .modal;
     su iOS 90vh includerebbe status bar/home indicator e sborderebbe */
  max-height: min(90vh, 100%);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

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

.modal-header h2 {
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--color-text-secondary);
  line-height: 1;
}

.modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  flex: 1;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 16px;
}

.tab {
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-section {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px 16px 4px;
  margin: 18px 0;
}

.form-section legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #d4551a;
}

.form-section > .form-hint {
  display: block;
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text-secondary);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color .15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* Buttons */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: #f5f5f5;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Status box */
.status-box {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.status-box.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-box.error {
  background: #ffebee;
  color: #c62828;
}

.status-box.info {
  background: #e3f2fd;
  color: #1565c0;
}

.text-muted {
  color: var(--color-text-secondary);
  font-size: 13px;
}

/* Static value (non-editable field) */
.static-value {
  padding: 10px 12px;
  background: #f5f5f5;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* Forgot password link */
.forgot-password-link {
  display: inline-block;
  font-size: 13px;
  color: var(--color-primary);
  text-decoration: none;
  margin-bottom: 8px;
}

.forgot-password-link:hover {
  text-decoration: underline;
}

/* About page */
.about-logo {
  text-align: center;
  margin: 16px 0 8px;
}

.about-logo-img {
  max-width: 200px;
  height: auto;
}

.about-credit {
  text-align: center;
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

/* Password toggle */
.input-password-wrapper {
  position: relative;
}

.input-password-wrapper input {
  padding-right: 42px;
}

.btn-toggle-password {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
}

.btn-toggle-password:hover {
  color: var(--color-primary);
}

/* Form hint */
.form-hint {
  display: block;
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* Hidden helper */
.hidden {
  display: none !important;
}

/* Connection badge */
.connection-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge-lan {
  background: #a5d6a7;
  color: #1b5e20;
}

.badge-cloud {
  background: #90caf9;
  color: #0d47a1;
}

/* ===== Accessible UI =====
   Three modes coexist on the same DOM, switched via .acc-mode-* on the
   root container: 'none' (default), 'visual' (non vedente — large
   fonts + ARIA), 'motor' (4 zones per page in 2x2 grid). */
.accessible-ui {
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Motor mode owns the full viewport so the 2x2 grid can fill it. Other
   modes stay block-flow and scroll naturally via #main-content. */
.acc-mode-motor.accessible-ui {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: none;
  padding: 12px;
}

.acc-loading, .acc-empty {
  text-align: center;
  padding: 40px 16px;
  font-size: 16px;
  color: var(--color-text-secondary);
}

/* ----- page header (drill-in) ----- */
.acc-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.acc-page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  flex: 1;
}

.acc-back-btn {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  color: var(--color-text);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}

.acc-back-btn:hover, .acc-back-btn:focus-visible {
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: none;
}

/* ----- shared section heading (Frame label) ----- */
.acc-frame-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--color-border);
}

/* ----- generic card (used by all three modes) ----- */
.acc-widget,
.acc-visual-card,
.acc-motor-cell {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  box-sizing: border-box;
  width: 100%;
}

.acc-widget:focus-visible,
.acc-visual-card:focus-visible,
.acc-motor-cell:focus-visible,
.acc-mapped-btn:focus-visible,
.acc-stepper-btn:focus-visible,
.acc-motor-pager-btn:focus-visible {
  outline: 4px solid var(--color-primary);
  outline-offset: 2px;
}

.acc-widget:active, .acc-visual-card:active, .acc-motor-cell:active {
  transform: scale(.97);
}

.acc-card-label {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}

.acc-card-state {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
}

.acc-on { background: #e8f5e9; border-color: #4caf50; }
.acc-on .acc-card-state { color: #2e7d32; }
.acc-off .acc-card-state { color: var(--color-text-secondary); }

.acc-card-text {
  cursor: default;
  background: #f5f5f5;
}

.acc-card-page .acc-card-state {
  font-size: 28px;
  color: var(--color-primary);
}

/* ----- stepper (slider/setpoint) ----- */
.acc-card-stepper { gap: 10px; }
.acc-stepper-controls {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.acc-stepper-btn {
  flex: 1;
  min-height: 48px;
  border-radius: 10px;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
}
.acc-stepper-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.acc-stepper-btn:active { background: var(--color-primary); color: #fff; }

/* ----- mapped (selection / mapped switch) ----- */
.acc-mapped-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.acc-mapped-btn {
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  flex: 1 1 auto;
  min-width: 96px;
}
.acc-mapped-btn:hover { border-color: var(--color-primary); }
.acc-mapped-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ===== mode: none (default) ===== */
.acc-mode-none .acc-widget {
  /* Stack-friendly cards, ~1-2 columns */
  min-height: 100px;
}

/* ===== mode: visual (non vedente) =====
   Single column, large text, prominent focus, semantic. Screen
   readers find aria-pressed/aria-live attached at the JS layer. */
.acc-mode-visual .acc-page-title { font-size: 32px; }
.acc-mode-visual .acc-back-btn { font-size: 20px; padding: 12px 22px; }
.acc-mode-visual .acc-frame-title { font-size: 18px; }

.acc-visual-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.acc-visual-section {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 12px 0 4px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-border);
}

.acc-visual-card {
  padding: 22px 18px;
  min-height: 90px;
  border-width: 3px;
}

.acc-visual-card .acc-card-label { font-size: 24px; }
.acc-visual-card .acc-card-state { font-size: 22px; }
.acc-mode-visual .acc-stepper-btn { min-height: 64px; font-size: 32px; }
.acc-mode-visual .acc-mapped-btn  { min-height: 56px; font-size: 20px; }

/* ===== mode: motor (disabilità motoria) =====
   Always 2x2 zones filling the available space. Page indicator + huge
   prev/next at the bottom. Empty cells are still visible (subtle) so
   the layout doesn't shift unpredictably. */
.acc-motor {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.acc-motor-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.acc-motor-cell {
  font-size: 22px;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-width: 3px;
  padding: 16px;
  min-height: 0;
}

.acc-motor-cell .acc-card-label { font-size: 22px; }
.acc-motor-cell .acc-card-state { font-size: 28px; }
.acc-motor-cell.acc-card-page .acc-card-state { font-size: 48px; }

.acc-motor-empty {
  background: transparent;
  border-style: dashed;
  cursor: default;
  opacity: .35;
}

.acc-motor-cell .acc-stepper-controls { width: 100%; }
.acc-motor-cell .acc-stepper-btn { min-height: 56px; font-size: 28px; }
.acc-motor-cell .acc-mapped-buttons { width: 100%; }
.acc-motor-cell .acc-mapped-btn { font-size: 18px; min-height: 48px; }

.acc-motor-pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.acc-motor-pager-btn {
  height: 56px;
  border: 3px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 12px;
  font-size: 36px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
}
.acc-motor-pager-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.acc-motor-pager-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.acc-motor-page-indicator {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-align: center;
  min-width: 64px;
}

/* Stack to single column on narrow phones for "none" mode only — motor
   keeps its 2x2 grid (the whole point) and visual is single column by
   design. */
@media (max-width: 600px) {
  .acc-mode-none .acc-widget { padding: 14px 12px; }
}

/* === NFC tag write modal === */
.nfc-item-list, .nfc-command-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.nfc-item-row, .nfc-command-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .12s;
}

.nfc-item-row:last-child, .nfc-command-row:last-child {
  border-bottom: 0;
}

.nfc-item-row:hover, .nfc-command-row:hover {
  background: rgba(242, 101, 34, .08);
}

.nfc-item-row .nfc-item-name {
  font-weight: 600;
  font-size: 14px;
}

.nfc-item-row .nfc-item-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.nfc-item-row .nfc-item-state {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-left: 12px;
  flex-shrink: 0;
}

.nfc-command-row {
  font-size: 15px;
}

.nfc-back-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 14px;
  cursor: pointer;
  padding: 0 0 12px;
}

.nfc-selected-item {
  background: rgba(242, 101, 34, .08);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.nfc-selected-name {
  font-weight: 700;
}

.nfc-selected-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.nfc-write-prompt {
  text-align: center;
  padding: 20px 8px;
}

.nfc-write-icon {
  color: var(--color-primary);
  margin-bottom: 12px;
  animation: nfc-pulse 1.4s infinite ease-in-out;
}

@keyframes nfc-pulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50%      { transform: scale(1.12); opacity: 1; }
}

.nfc-write-prompt h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.nfc-write-status {
  margin-top: 16px;
  font-weight: 600;
  min-height: 1.4em;
}

.nfc-write-status.error { color: #d83232; }
.nfc-write-status.ok    { color: #2e8a45; }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 16px;
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ===== Continuous alarm overlay (foreground web / iOS WebView) ===== */
.alarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right))
           calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  background: var(--color-danger);
  color: #fff;
  text-align: center;
  cursor: pointer;
  animation: alarm-flash 0.8s steps(1) infinite;
}
@keyframes alarm-flash {
  0%, 100% { background: var(--color-danger); }
  50%      { background: #7f1010; }
}
.alarm-overlay__inner {
  max-width: 480px;
  width: 100%;
}
.alarm-overlay__icon { font-size: 72px; line-height: 1; }
.alarm-overlay__acc {
  margin-top: 12px;
  font-size: 18px;
  font-weight: 700;
  opacity: 0.9;
}
.alarm-overlay__title {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
}
.alarm-overlay__body {
  margin-top: 12px;
  font-size: 20px;
  line-height: 1.4;
}
.alarm-overlay__btn {
  margin-top: 32px;
  width: 100%;
  padding: 22px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--color-danger);
  background: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
}
.alarm-overlay__btn:active { transform: scale(0.98); }

/* === Account import/export (QR sync) === */
.sidebar-spacer { flex: 1 1 auto; min-height: 12px; }
.sidebar-sync-btn { border-style: solid; }
#btn-export-accounts { margin-bottom: 4px; }

.export-checks {
  margin: 8px 0 12px;
  max-height: 45vh;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.export-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  font-size: 15px;
}
.export-check:last-child { border-bottom: none; }
.export-check input { width: 18px; height: 18px; accent-color: var(--color-primary); }

.sync-warning {
  background: #fff3e0;
  color: #8a4b00;
  border: 1px solid #ffcc80;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin: 0 0 14px;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 12px;
}
#export-qr-canvas {
  width: 320px;
  max-width: 78vw;
  height: auto;
  image-rendering: pixelated;
  border-radius: 8px;
}
.import-video {
  width: 320px;
  max-width: 78vw;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #000;
  border-radius: 8px;
}
.sync-status {
  text-align: center;
  min-height: 20px;
  color: var(--color-text-secondary);
  margin: 4px 0 12px;
}

@media (prefers-color-scheme: dark) {
  .sync-warning { background: #3a2a10; color: #ffcc80; border-color: #6b4a12; }
}
