/* ============================ ClipSync styles ============================ */

:root {
  --bg: #0b1020;
  --bg-soft: #0f172a;
  --card: #151d33;
  --card-2: #1b2540;
  --border: #26304d;
  --text: #e6eaf5;
  --muted: #8b93ab;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #eef1f7;
  --bg-soft: #e6eaf3;
  --card: #ffffff;
  --card-2: #f4f6fb;
  --border: #dbe1ee;
  --text: #101828;
  --muted: #5b6478;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100vh; }

/* ------------------------------- login ------------------------------- */

#login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 20% -10%, rgba(99, 102, 241, 0.25), transparent 60%),
    radial-gradient(800px 400px at 110% 110%, rgba(14, 165, 233, 0.18), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  text-align: center;
}

.logo { font-size: 44px; line-height: 1; }

.login-card h1 { margin: 12px 0 4px; font-size: 26px; }

.subtitle { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

#login-form { text-align: left; display: flex; flex-direction: column; gap: 8px; }

#login-form label { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 6px; }

.hint { font-size: 12px; margin-top: 16px; }

/* ------------------------------- layout ------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.status.offline .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 80px;
}

/* ------------------------------- cards ------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#compose { padding: 14px; margin-bottom: 14px; }

#clip-input {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
}

#clip-input:focus, input:focus, .search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.compose-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.compose-row .hint { margin: 0; }

/* ------------------------------- toolbar ------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  min-width: 180px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ------------------------------- clips ------------------------------- */

.clip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  animation: rise 0.18s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.clip-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  max-height: 220px;
  overflow: hidden;
  cursor: pointer;
}

.clip.expanded .clip-content { max-height: none; }

.clip-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.clip-device { font-weight: 600; }

.clip-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* ------------------------------- buttons ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
}

.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger  { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-small   { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block   { width: 100%; margin-top: 14px; }

/* ------------------------------- empty ------------------------------- */

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.empty-icon { font-size: 40px; margin-bottom: 8px; }

/* ------------------------------- modal ------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.modal-head h2 { margin: 0; font-size: 17px; }

.modal-body { padding: 6px 18px 18px; }

.modal-body h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 20px 0 8px;
}

.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }

.error { color: var(--danger); font-size: 13px; margin: 6px 0 0; }
.ok { color: var(--ok); font-size: 13px; margin: 6px 0 0; }

/* urls & devices lists */

.urls, .devices { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.urls li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.urls a {
  color: var(--accent-2);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  text-decoration: none;
}

.urls a:hover { text-decoration: underline; }

.qr-wrap { text-align: center; margin-top: 12px; }

.qr-wrap img {
  width: 190px;
  height: 190px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}

.devices li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.device-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.device-info strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#pw-form { display: flex; flex-direction: column; gap: 8px; }

#pw-form input {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}

/* ------------------------------- toasts ------------------------------- */

#toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: rise 0.2s ease;
  max-width: 100%;
  word-break: break-word;
}

.toast-ok   { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }

.toast.out { opacity: 0; transition: opacity 0.3s; }

/* ------------------------------- mobile ------------------------------- */

@media (max-width: 560px) {
  .content { padding: 12px 10px 80px; }
  .brand { font-size: 15px; }
  .compose-row .hint { display: none; }
  .status-text { display: none; }
}
