/* =====================================================
   Formulaires Terrain — Design System
   Inspired by Things 3 + Apple Health
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }

:root {
  /* Surfaces */
  --bg:           #F2F2F7;
  --surface:      #FFFFFF;
  --surface-alt:  #F9F9FB;
  --separator:    rgba(60, 60, 67, 0.10);
  --separator-2:  rgba(60, 60, 67, 0.06);

  /* Text */
  --text:         #1C1C1E;
  --text-2:       #3C3C43;
  --muted:        #8E8E93;
  --muted-2:      #AEAEB2;

  /* Accent */
  --accent:       #0A84FF;
  --accent-soft:  #E8F1FF;
  --accent-press: #0066D6;

  /* Semantic */
  --green:        #34C759;
  --green-soft:   #E8F8EE;
  --orange:       #FF9500;
  --orange-soft:  #FFF4E5;
  --red:          #FF3B30;
  --red-soft:     #FFECEC;
  --indigo:       #5E5CE6;

  /* Geometry */
  --r-xs:  8px;
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  24px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  /* Motion */
  --ease:        cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:    160ms;
  --dur:         240ms;
  --dur-slow:    420ms;

  /* Layout */
  --header-h: 50px;
  --viewport-h: 100dvh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
  overscroll-behavior-y: contain;
  min-height: var(--viewport-h);
  touch-action: manipulation;
}

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

h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.center { text-align: center; }

/* ==================== Icons ==================== */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}
.icon svg {
  width: 100%; height: 100%;
  stroke: currentColor; fill: none;
  stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ==================== View ==================== */
.view { min-height: var(--viewport-h); display: flex; flex-direction: column; }

/* ==================== Auth ==================== */
.auth-screen {
  min-height: var(--viewport-h);
  background:
    radial-gradient(circle at 20% -10%, #DCE7FF 0%, transparent 45%),
    radial-gradient(circle at 100% 110%, #FFE4DC 0%, transparent 50%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: max(24px, var(--safe-top));
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  animation: cardIn var(--dur-slow) var(--ease-spring) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.brand-mark {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--indigo) 100%);
  color: #fff;
  display: grid; place-items: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 20px rgba(10, 132, 255, 0.32);
}
.brand-mark .icon { width: 28px; height: 28px; }
.auth-card h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  text-align: center; margin-bottom: 4px;
}
.auth-sub {
  text-align: center; color: var(--muted);
  font-size: 14px; margin-bottom: 26px;
}

/* ==================== Fields ==================== */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: 8px; letter-spacing: -0.005em;
}
.field-hint { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; font-family: inherit;
  min-height: 46px;
  font-size: 16px; padding: 13px 14px;
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  background: var(--surface-alt);
  color: var(--text); outline: none;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
  padding-right: 40px;
}

/* PIN cells */
.pin-field {
  display: flex; gap: 10px; justify-content: center; margin-bottom: 4px;
}
.pin-cell {
  flex: 1; max-width: 60px; height: 60px;
  font-size: 26px; font-weight: 600; text-align: center;
  border: 1.5px solid var(--separator);
  border-radius: var(--r-md);
  background: var(--surface-alt); color: var(--text);
  outline: none; font-variant-numeric: tabular-nums;
  transition: all var(--dur-fast) var(--ease);
  -webkit-text-security: disc; text-security: disc;
}
.pin-cell::-webkit-outer-spin-button,
.pin-cell::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pin-cell:focus {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft); transform: scale(1.02);
}
.pin-cell.filled { border-color: var(--text); background: var(--surface); }

/* ==================== Buttons ==================== */
.btn {
  appearance: none; border: 0;
  min-height: 44px;
  padding: 13px 18px; font-size: 16px; font-weight: 600;
  letter-spacing: -0.01em; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 100ms var(--ease),
              background var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.28);
}
.btn-primary:hover { background: var(--accent-press); }
.btn-soft {
  background: var(--surface-alt); color: var(--text);
  border: 1px solid var(--separator);
}
.btn-soft:hover { background: #EFEFF4; }
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(255, 59, 48, 0.18);
}
.btn-danger:hover { background: #FFDADA; }
.btn-icon {
  width: 44px; height: 44px; padding: 0;
  border-radius: var(--r-pill);
  background: transparent; color: var(--text-2);
  border: 0; display: grid; place-items: center;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-icon:hover { background: var(--surface-alt); color: var(--text); }
.btn-icon .icon { width: 20px; height: 20px; }

/* ==================== App shell ==================== */
.app-shell { background: var(--bg); }
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--separator);
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: 8px 20px;
  padding-top: calc(8px + var(--safe-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.app-header-left .app-title {
  font-size: 17px; font-weight: 700; letter-spacing: -0.015em;
}
.app-header-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.offline-badge,
.storage-badge {
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.update-app-btn {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  white-space: nowrap;
}
.update-app-btn .icon {
  width: 16px;
  height: 16px;
}
@media (max-width: 420px) {
  .offline-badge {
    max-width: 34px;
    padding-inline: 8px;
  }
  .offline-badge span:not(.icon) {
    display: none;
  }
  .storage-badge {
    max-width: 148px;
    padding-inline: 8px;
  }
  .update-app-btn span:not(.icon) {
    display: none;
  }
  .update-app-btn {
    width: 34px;
    min-width: 34px;
    padding: 0;
  }
}
.app-main {
  flex: 1; padding: 20px;
  padding-bottom: calc(var(--safe-bot) + 24px);
  max-width: 680px; width: 100%; margin: 0 auto;
}
.tab { animation: tabIn var(--dur) var(--ease) both; }
@keyframes tabIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==================== Card ==================== */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card-h {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.card-h h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.018em; }

/* ==================== Visit form sections ==================== */
.form-section-nav {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  z-index: 15;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 12px;
  background: var(--bg);
  margin-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.form-section-tab {
  flex: 0 0 auto;
  min-width: 124px;
  border: 1px solid var(--separator);
  background: var(--surface-alt);
  color: var(--text-2);
  border-radius: var(--r-md);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  transition: all var(--dur-fast) var(--ease);
}
.form-section-tab-badge {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
  line-height: 1;
}
.form-section-tab-badge .icon {
  width: 12px;
  height: 12px;
}
.form-section-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.form-section-head {
  margin-bottom: 16px;
}
.form-section-head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.018em;
}
.form-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 0 8px;
  border-top: 1px solid var(--separator);
}
.form-group-title:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.form-grid {
  display: grid;
  gap: 12px;
}
.form-field.is-empty .input,
.form-field.is-empty .textarea,
.form-field.is-empty .upload-btn {
  border-color: rgba(255, 149, 0, 0.48);
  background: var(--orange-soft);
}
.required-dot {
  color: var(--orange);
  margin-left: 3px;
}
.photo-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.photo-field-head .field-label { margin-bottom: 0; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.form-actions .form-save-btn { flex: 1; min-width: 0; }
.btn-step-arrow {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  padding: 0;
}
.btn-step-arrow .icon {
  width: 20px;
  height: 20px;
}

/* ==================== Uploader ==================== */
.uploader { display: flex; gap: 10px; margin-bottom: 12px; }
.upload-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px;
  background: var(--surface-alt);
  border: 1.5px dashed var(--separator);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.upload-btn:hover {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.upload-btn .icon { width: 18px; height: 18px; }
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.thumb {
  position: relative; aspect-ratio: 1 / 1;
  border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-alt);
  animation: thumbIn var(--dur) var(--ease-spring) both;
}
@keyframes thumbIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-remove {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.7); color: #fff;
  border: 0; display: grid; place-items: center;
  transition: transform var(--dur-fast) var(--ease);
}
.thumb-remove:hover { transform: scale(1.1); }
.thumb-remove .icon { width: 12px; height: 12px; stroke-width: 2.5; }

/* ==================== Badges ==================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; letter-spacing: -0.005em;
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2.5; }
.badge.green  { background: var(--green-soft);  color: var(--green); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red    { background: var(--red-soft);    color: var(--red); }
.badge.gray   { background: var(--separator-2); color: var(--muted); }
.badge.blue   { background: var(--accent-soft); color: var(--accent); }
.dot-status { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* ==================== List items ==================== */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
}
.list-toolbar-copy {
  min-width: 0;
}
.list-toolbar h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.018em;
}
.list-toolbar p {
  font-size: 13.5px;
  margin: 2px 0 0;
}
.list-new-btn {
  flex: 0 0 auto;
  min-height: 42px;
  padding-inline: 14px;
}
.list-toolbar-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.list-backup-btn {
  min-height: 42px;
  padding-inline: 12px;
  font-size: 14px;
}
.list-cleanup-btn {
  min-height: 42px;
  padding-inline: 12px;
  font-size: 14px;
}
.form-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 8px;
}
.form-topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
@media (max-width: 420px) {
  .list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .list-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .list-backup-btn,
  .list-cleanup-btn,
  .list-new-btn {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
  }
  .item-head {
    flex-direction: column;
  }
  .item-badges {
    justify-content: flex-start;
    max-width: 100%;
  }
}
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  animation: itemIn var(--dur) var(--ease) both;
  overflow: hidden;
}
.item-unsaved {
  border: 1px solid rgba(255, 149, 0, 0.24);
}
.item-main {
  padding: 16px 18px 12px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.item-main:active { transform: scale(0.995); }
.item-main:hover { background: var(--surface-alt); }
.item-main[role="button"]:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: -3px;
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.item-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 6px;
}
.item-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  min-width: 0;
  overflow-wrap: anywhere;
}
.item-badges {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 58%;
}
.item-meta { font-size: 12.5px; color: var(--muted); }
.item-body {
  font-size: 14.5px; color: var(--text-2);
  line-height: 1.45; margin-top: 6px;
}
.item-meta-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted); margin-top: 8px;
}
.item-meta-row .icon { width: 13px; height: 13px; }
.item-photo-count {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.item-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.item-thumbs a, .item-thumbs .ph {
  width: 56px; height: 56px;
  border-radius: var(--r-sm); overflow: hidden;
  background: var(--surface-alt);
  display: grid; place-items: center; color: var(--muted);
}
.item-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.item-thumbs .ph .icon { width: 18px; height: 18px; }
.item-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  padding: 0 18px 16px;
}
.item-action-btn {
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
}
.item-action-btn .icon {
  width: 16px;
  height: 16px;
}

/* Section header */
.section-h {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 16px 8px 6px;
}

/* ==================== Empty state ==================== */
.empty {
  text-align: center; padding: 56px 20px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: var(--surface-alt);
  display: inline-grid; place-items: center;
  color: var(--muted-2); margin-bottom: 14px;
}
.empty-icon .icon { width: 32px; height: 32px; stroke-width: 1.5; }
.empty h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.012em; margin-bottom: 4px; }
.empty p { font-size: 13.5px; color: var(--muted); margin: 0; }

/* ==================== Skeleton ==================== */
.skel {
  background: linear-gradient(90deg, var(--separator-2) 0%, var(--separator) 50%, var(--separator-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}
.skel-item {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.skel-line { height: 14px; margin-bottom: 8px; }
.skel-line.short { width: 40%; }
.skel-line.medium { width: 70%; }

/* ==================== Toasts ==================== */
.toast-stack {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--safe-bot) + 16px);
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; align-items: center;
}
html.keyboard-open .toast-stack {
  bottom: 12px;
}
.toast {
  pointer-events: auto;
  background: rgba(28, 28, 30, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff; padding: 12px 16px;
  border-radius: var(--r-md);
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; font-weight: 500; letter-spacing: -0.01em;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.18);
  max-width: 440px; width: max-content;
  animation: toastIn var(--dur) var(--ease-spring) both;
}
.toast.toast-out { animation: toastOut var(--dur) var(--ease) forwards; }
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.is-success .icon { color: var(--green); }
.toast.is-error   .icon { color: var(--red); }
.toast.is-info    .icon { color: #fff; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* ==================== Progress ==================== */
.progress-overlay {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bot) + 74px);
  z-index: 95;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.progress-panel {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  pointer-events: auto;
}
.progress-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.progress-title {
  font-size: 14px;
  font-weight: 700;
}
.progress-detail {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}
.progress-track {
  height: 5px;
  overflow: hidden;
  margin-top: 12px;
  background: var(--separator-2);
  border-radius: var(--r-pill);
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--dur-fast) var(--ease);
}
.progress-bar.is-indeterminate {
  width: 42%;
  animation: progressIndeterminate 1.1s ease-in-out infinite;
}
@keyframes progressIndeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(260%); }
}

/* ==================== Sheet ==================== */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 80; opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed; left: 8px; right: 8px;
  bottom: calc(8px + var(--safe-bot));
  background: var(--surface);
  border-radius: var(--r-xl);
  z-index: 90;
  transform: translateY(110%);
  transition: transform var(--dur-slow) var(--ease-spring);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.sheet.is-open { transform: translateY(0); }
.sheet-title {
  padding: 16px 20px 8px;
  font-size: 13px; color: var(--muted);
  text-align: center; font-weight: 500;
}
.sheet-btn {
  width: 100%; background: transparent;
  border: 0; border-top: 1px solid var(--separator);
  min-height: 52px;
  padding: 16px 20px;
  font-size: 17px; font-weight: 500; color: var(--accent);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  letter-spacing: -0.01em;
  transition: background var(--dur-fast) var(--ease);
}
.sheet-btn:hover { background: var(--surface-alt); }
.sheet-btn.is-cancel { color: var(--text-2); font-weight: 600; }
.sheet-btn .icon { width: 20px; height: 20px; }

/* ==================== Error ==================== */
.error-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--red-soft); color: var(--red);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
  animation: shake 360ms var(--ease);
}
.error-msg .icon { width: 16px; height: 16px; flex-shrink: 0; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

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