/* ClipSync — design system
   Accent teal (le lien / la synchro). Neutres à biais froid. Thèmes clair + sombre. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eceff5;
  --border: rgba(17, 24, 39, 0.09);
  --text: #10151f;
  --muted: #616b7d;
  --accent: #0d9488;
  --accent-weak: rgba(13, 148, 136, 0.13);
  --accent-ink: #ffffff;
  --online: #16a34a;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 12px 34px rgba(17, 24, 39, 0.12);
  --r: 16px;
  --r-sm: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e17;
    --surface: #131a27;
    --surface-2: #1c2432;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e8edf6;
    --muted: #8b95a9;
    --accent: #2dd4bf;
    --accent-weak: rgba(45, 212, 191, 0.15);
    --accent-ink: #04231f;
    --online: #34d399;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.app {
  max-width: 540px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 20px calc(env(safe-area-inset-bottom) + 28px);
}

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 20px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo-img { width: 28px; height: 28px; display: block; }
.wordmark { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  box-shadow: var(--shadow-sm); transition: color .15s, transform .1s;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:hover { color: var(--text); }

/* Status */
.status {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 15px 17px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.on { background: var(--online); box-shadow: 0 0 0 4px color-mix(in srgb, var(--online) 22%, transparent); }
.dot.off { opacity: .55; }
#statusText { font-weight: 600; font-size: 15px; }
.spacer { flex: 1; }
#statusSub { color: var(--muted); font-size: 13px; }

/* Actions */
.actions { display: flex; flex-direction: column; gap: 10px; }
button.primary, button.secondary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; border-radius: var(--r); padding: 18px; cursor: pointer;
  font-family: inherit; transition: transform .1s, filter .15s;
}
button.primary {
  border: none; background: var(--accent); color: var(--accent-ink);
  font-size: 17px; font-weight: 700;
  box-shadow: var(--shadow-sm), 0 8px 20px var(--accent-weak);
}
button.primary:active { transform: scale(0.985); filter: brightness(1.06); }
button.primary:disabled { opacity: .5; box-shadow: none; }
button.secondary {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 16px; font-weight: 600;
}
button.secondary:active { transform: scale(0.985); }
button svg { flex: none; }

/* Progress */
#progress { margin-top: 4px; }
#progressLabel { font-size: 13px; color: var(--muted); margin-bottom: 7px; word-break: break-word; }
#progress .bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
#progressBar { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .15s ease; }

.hint { color: var(--muted); font-size: 13px; text-align: center; margin: 16px 6px 24px; }
.hint b { color: var(--text); font-weight: 600; }

/* Sections */
.block { margin-top: 6px; }
h2 {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin: 20px 4px 10px;
}

/* Recherche */
.search {
  width: 100%; margin: 0 0 12px; padding: 11px 14px 11px 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); font-size: 15px; font-family: inherit;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

/* Historique */
.item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 15px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.item .meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.item .meta.sub { display: block; margin: 8px 0 0; }
.item .dir { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dir-in { color: var(--accent); }
.item .dir-out { color: var(--muted); }
.item .time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .body { word-break: break-word; white-space: pre-wrap; max-height: 150px; overflow: auto; font-size: 15px; }
.item .body.muted { color: var(--muted); white-space: normal; }
.item .file-row { display: flex; align-items: center; gap: 12px; }
.item .file-ic { font-size: 22px; flex: none; line-height: 1; }
.item .file-meta { display: flex; flex-direction: column; min-width: 0; }
.item .file-name { font-size: 15px; font-weight: 600; word-break: break-word; }
.item .file-size { font-size: 12px; color: var(--muted); }
.item img { max-width: 100%; border-radius: 10px; display: block; }
.item .copy {
  margin-top: 12px; background: var(--accent-weak); color: var(--accent);
  border: none; border-radius: var(--r-sm); padding: 10px 16px; font-weight: 600; font-size: 14px;
  font-family: inherit; cursor: pointer;
}
.item .copy:active { transform: scale(0.97); }
.empty {
  color: var(--muted); font-size: 14px; padding: 20px 16px; text-align: center;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r);
}

/* Appareils */
.device {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 13px 15px; margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.device .name { flex: 1; font-size: 15px; font-weight: 600; }
.device .plat { color: var(--muted); font-size: 12px; text-transform: capitalize; }

/* Réglages */
dialog {
  border: none; border-radius: 22px; background: var(--surface); color: var(--text);
  width: min(92vw, 430px); padding: 24px 22px; box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(6, 10, 18, 0.55); backdrop-filter: blur(4px); }
dialog h3 { margin: 0 0 6px; font-size: 19px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin: 16px 0 7px; }
.lbl-note { color: var(--muted); font-weight: 400; }
input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 14px; font-size: 16px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.dialog-actions { display: flex; gap: 10px; margin-top: 24px; }
.dialog-actions button { flex: 1; border: none; border-radius: var(--r-sm); padding: 14px; font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer; }
.dialog-actions .save { background: var(--accent); color: var(--accent-ink); }
.dialog-actions .cancel { background: var(--surface-2); color: var(--text); }
.dialog-actions button:active { transform: scale(0.98); }

/* Popup « Envoyer à » */
#targetList { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.target-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 13px 15px; cursor: pointer; font-family: inherit;
  transition: transform .1s;
}
.target-opt:active { transform: scale(0.99); }
.target-opt .t-name { font-weight: 600; font-size: 15px; }
.target-opt .t-sub { color: var(--muted); font-size: 12px; text-transform: capitalize; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  background: var(--text); color: var(--bg);
  padding: 13px 20px; border-radius: 14px; font-size: 14px; font-weight: 600;
  opacity: 0; transition: opacity .22s, transform .22s; pointer-events: none;
  max-width: 88vw; text-align: center; box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
