/* Creator DMs: phone first, one hand, big targets. Autora navy and teal. */

:root {
  --navy: #071327;
  --teal: #19d1c2;
  --blue: #5b95d6;

  --bg: #eef3fb;
  --surface: #ffffff;
  --surface-2: #f3f6fc;
  --text: #0b1830;
  --muted: #5a6780;
  --border: #d8e1f0;
  --bubble: #e1eafa;
  --bubble-text: #0b1830;
  --check-bg: #fff4d6;
  --check-text: #6b4a00;
  --notice-bg: #ffe3e3;
  --notice-text: #8a1c1c;
  --primary: var(--teal);
  --primary-text: var(--navy);
  --done: #0f9b8e;
  --shadow: 0 1px 2px rgba(7, 19, 39, 0.06), 0 6px 20px rgba(7, 19, 39, 0.06);

  --radius: 18px;
  --radius-btn: 14px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050d1c;
    --surface: #0c1a33;
    --surface-2: #10224a;
    --text: #e8eef9;
    --muted: #9aa8c2;
    --border: #1c3058;
    --bubble: #16305c;
    --bubble-text: #eef3fb;
    --check-bg: #3a2e0c;
    --check-text: #ffd98a;
    --notice-bg: #3d1414;
    --notice-text: #ffc2c2;
    --done: #3fe0d2;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.offscreen { position: fixed; top: 0; left: -9999px; opacity: 0; }

/* ---------- header ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
.bar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
}
.bar-title { flex: 1; min-width: 0; }
.bar h1 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.bar-sub { margin: 2px 0 0; font-size: 13px; color: #b8c6e2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.6; }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sync-btn {
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--teal);
  color: var(--navy);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  animation: pop-in 0.22s ease-out;
}
.sync-count {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  line-height: 26px;
  text-align: center;
}
.sync-btn.busy { opacity: 0.75; }
.sync-btn.busy .sync-count { display: none; }
.sync-btn.busy { padding-right: 14px; }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- layout ---------- */
.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px max(var(--gutter), env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.list { display: grid; gap: 14px; }

/* ---------- creator card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
  transition: height 0.24s ease, opacity 0.2s ease, transform 0.2s ease, padding 0.24s ease, margin 0.24s ease;
}
.card.leaving { opacity: 0; transform: translateX(24px); padding-top: 0; padding-bottom: 0; margin-bottom: -14px; }

.card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 13px; }
.badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge.p0 { background: var(--teal); color: var(--navy); }
.badge.p1 { background: var(--blue); color: #fff; }
.badge.p2 { background: #f2c14e; color: var(--navy); }
.badge.p3 { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.p4 { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.tag { color: var(--muted); font-weight: 600; }
.followers { margin-left: auto; color: var(--muted); }

.handle {
  margin: 10px 0 0;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.meta { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.check {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--check-bg);
  color: var(--check-text);
  font-size: 14px;
}

.dm {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 18px 18px 18px 6px;
  background: var(--bubble);
  color: var(--bubble-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
}
.dm.empty-dm { color: var(--muted); font-style: italic; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.actions-send { grid-template-columns: 1fr; }
.mark-all { margin-top: 4px; }

.btn {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 650;
  font-size: 16px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.copy.done { border-color: var(--done); color: var(--done); background: transparent; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 700; }
.btn.wide { width: 100%; }
.tick { flex-shrink: 0; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

details { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; font-size: 14px; color: var(--muted); }
summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details p { margin: 6px 0 10px; color: var(--text); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
dt { font-weight: 600; }
dd { margin: 0; overflow-wrap: anywhere; color: var(--text); }

/* ---------- queue of sent DMs ---------- */
.queue {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.queue h2 { margin: 0; font-size: 15px; }
.queue ul { list-style: none; margin: 0; padding: 0; }
.queue li { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--border); }
.queue li:last-child { border-bottom: 0; }
.q-handle { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.queue-hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.link-btn {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

/* ---------- states ---------- */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 14px;
}
.notice span { flex: 1; }
.notice .link-btn { color: inherit; text-decoration: underline; }

.empty { text-align: center; padding: 48px 16px; }
.empty h2 { margin: 0 0 6px; font-size: 22px; }
.empty p { margin: 0 auto 18px; max-width: 34ch; color: var(--muted); }

.skeleton {
  height: 260px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.foot { text-align: center; margin-top: 28px; }

/* ---------- sign in ---------- */
.login { display: grid; place-items: center; min-height: 60vh; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
}
.login-card h2 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 16px; color: var(--muted); font-size: 15px; }
.login-card label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.login-card input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
}
.field-error { min-height: 22px; margin: 6px 0 8px !important; color: #d33 !important; font-size: 14px !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--navy);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 16px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-action { border: 0; background: none; color: var(--teal); font-weight: 700; min-height: 32px; cursor: pointer; }

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