:root {
  --bg: #07090d;
  --bg-elev: #0e1218;
  --card: #141a22;
  --card-sent: #12352d;
  --line: #263040;
  --line-sent: #2f6f5c;
  --text: #f4f7fb;
  --text-sent: #d7f4e8;
  --muted: #8e9aaf;
  --muted-sent: #9dccb6;
  --faint: #667085;
  --accent: #4f8cff;
  --accent-2: #7aa7ff;
  --accent-press: #3a73e0;
  --good: #3ee0b0;
  --good-bg: rgba(62, 224, 176, 0.16);
  --chip: #1b2330;
  --chip-on: #1d3b73;
  --chip-left: #1d3b73;
  --chip-sent: #1a4a3d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  min-height: 100%;
}

body {
  padding-bottom: calc(24px + var(--safe-bottom));
}

button, input, textarea, a.btn {
  font: inherit;
  color: inherit;
}

a { color: var(--accent-2); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(7, 9, 13, 0.98) 70%, rgba(7, 9, 13, 0.88));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: calc(12px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
}

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

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.count {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
  line-height: 1.35;
}

.count b { color: var(--text); font-weight: 700; }
.count .sent-n { color: var(--good); }

.search-wrap { position: relative; }

.search {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 12px 44px 12px 14px;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
}

.clear-search {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  display: none;
}

.clear-search.show { display: block; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0 0;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--chip-on);
  border-color: var(--accent);
  color: #eaf2ff;
}

.chip.chip-left[aria-pressed="true"] {
  background: var(--chip-left);
}

.chip.chip-sent[aria-pressed="true"] {
  background: var(--chip-sent);
  border-color: var(--good);
  color: #d8fff0;
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.list {
  padding: 14px 14px 0;
  display: grid;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.card.is-sent {
  background: var(--card-sent);
  border-color: var(--line-sent);
}

.card.is-sent .name { color: var(--text-sent); }
.card.is-sent .sub { color: var(--muted-sent); }
.card.is-sent .note {
  background: #0d241e;
  border-color: #245247;
  color: #cfeadd;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.name {
  margin: 0;
  font-size: 1.28rem;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.sent-badge {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(62, 224, 176, 0.45);
  background: var(--good-bg);
  color: var(--good);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
}

.note {
  margin: 14px 0 0;
  padding: 12px 12px 10px;
  background: #0c1016;
  border: 1px solid #222a36;
  border-radius: 12px;
  white-space: pre-wrap;
  color: #dbe4f0;
  font-size: 0.98rem;
  line-height: 1.45;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 650;
  cursor: pointer;
  padding: 12px 10px;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:active { background: var(--accent-press); }

.card.is-sent .btn-primary {
  background: #2f6f5c;
}

.btn-copy {
  background: #1b2430;
  border-color: var(--line);
  color: var(--text);
}

.btn-copy.copied {
  background: var(--good-bg);
  border-color: rgba(62, 224, 176, 0.45);
  color: var(--good);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

@media (max-width: 420px) {
  .actions { grid-template-columns: 1fr; }
}
