:root {
  --red: #c8102e;
  --red-dark: #9a0c24;
  --red-light: #fdecef;
  --bg: #f6f4f4;
  --card: #ffffff;
  --text: #1f1a1a;
  --muted: #6b6161;
  --border: #e5dede;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }
.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 18px; padding: 6px 8px; border-radius: 8px; }
.icon-btn:hover { background: #eee; color: var(--text); }
.btn-primary {
  background: linear-gradient(135deg, var(--red), #e11d48);
  color: #fff; border: none; border-radius: 10px;
  padding: 10px 18px; font-weight: 700; font-size: 15px;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-weight: 600; font-size: 14px; color: var(--text);
}
.btn-ghost:hover { background: #fff; }
.link-btn { background: none; border: none; color: var(--red); font-weight: 700; font-size: inherit; text-decoration: underline; padding: 0; }

/* ---------- Auth screen ---------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2b0208 0%, var(--red-dark) 45%, var(--red) 100%);
  padding: 16px;
}
.auth-card {
  background: #fff; border-radius: 18px; padding: 32px 28px;
  width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-logo {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--red), #e11d48);
  color: #fff; font-size: 38px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.auth-card h1 { text-align: center; font-size: 30px; }
.auth-tagline { text-align: center; color: var(--muted); margin: 6px 0 20px; }
.auth-tabs { display: flex; gap: 6px; background: var(--red-light); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.auth-tab { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--muted); }
.auth-tab.active { background: #fff; color: var(--red); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.auth-card label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 5px; }
.auth-card input[type=text], .auth-card input[type=password] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
}
.auth-card input:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
.auth-card .btn-primary { width: 100%; margin-top: 18px; }
.auth-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; text-align: center; }
.avatar-picker, .color-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.avatar-picker button, .color-picker button {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent;
  font-size: 18px; background: #f3f0f0; display: flex; align-items: center; justify-content: center;
}
.avatar-picker button.selected, .color-picker button.selected { border-color: var(--red); }
.auth-card .btn-ghost { width: 100%; margin-top: 14px; }
.auth-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 12px; }

/* ---------- Launchpad ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: linear-gradient(135deg, var(--red-dark), var(--red));
  color: #fff; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; background: #fff; color: var(--red);
  font-size: 26px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 20px; font-weight: 800; line-height: 1.1; }
.brand-sub { font-size: 12px; opacity: .85; }
.search-box {
  flex: 1; min-width: 180px; max-width: 480px; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.16); border-radius: 999px; padding: 8px 14px;
}
.search-box input { flex: 1; background: transparent; border: none; outline: none; color: #fff; font-size: 15px; }
.search-box input::placeholder { color: rgba(255,255,255,.75); }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.sync-status { font-size: 13px; opacity: .9; }
.me-card { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.14); border-radius: 12px; padding: 5px 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.me-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.account-badge { background: #fff; color: var(--red); font-size: 11px; border-radius: 999px; padding: 1px 6px; font-weight: 800; }
.me-status { font-size: 11px; opacity: .85; }
.me-card .icon-btn { color: #fff; }
.me-card .icon-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

.toolbar { display: flex; align-items: center; gap: 12px; padding: 16px 20px 4px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 700; color: var(--muted);
}
.chip.active { background: var(--red); border-color: var(--red); color: #fff; }
.guest-hint { padding: 8px 20px 0; color: var(--muted); font-size: 14px; }

.main { flex: 1; padding: 16px 20px 24px; max-width: 1200px; width: 100%; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 12px 12px; text-align: center; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(200,16,46,.14); border-color: var(--red); }
.tile-link { text-decoration: none; color: inherit; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.tile-icon {
  width: 56px; height: 56px; border-radius: 14px; background: var(--red-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: var(--red); overflow: hidden; flex-shrink: 0;
}
.tile-icon img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.tile-title { font-weight: 700; font-size: 14px; word-break: break-word; }
.tile-domain { font-size: 12px; color: var(--muted); word-break: break-all; }
.tile-cat {
  font-size: 11px; font-weight: 700; color: var(--red); background: var(--red-light);
  border-radius: 999px; padding: 2px 8px;
}
.tile-by { font-size: 11px; color: var(--muted); }
.tile-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; }
.tile-actions .icon-btn { font-size: 14px; padding: 4px 6px; background: rgba(255,255,255,.9); }
.tile-actions .icon-btn.danger:hover { color: var(--red); }
.tile-actions .confirming { color: var(--red); font-weight: 800; font-size: 12px; }

.state { text-align: center; padding: 60px 20px; color: var(--muted); }
.state h2 { color: var(--text); margin: 10px 0 6px; }
.empty-icon { font-size: 48px; }
.state .btn-primary { margin-top: 16px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 12px; border-top: 1px solid var(--border); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-card label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 5px; }
.modal-card input[type=text] { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; }
.modal-card input:focus { outline: 2px solid var(--red); border-color: var(--red); }
.icon-modes { display: flex; gap: 12px; flex-wrap: wrap; }
.icon-mode { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 5px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.icon-preview-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.tile-icon.preview { width: 44px; height: 44px; font-size: 20px; }
.preview-name { font-weight: 700; color: var(--text); word-break: break-all; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1f1a1a; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  max-width: 90vw; text-align: center;
}
.mobile-only { display: none; }

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .topbar { gap: 10px; padding: 10px 12px; }
  .search-box { order: 3; flex-basis: 100%; max-width: none; }
  .toolbar, .main { padding-left: 12px; padding-right: 12px; }
  .brand-sub { display: none; }
  .me-info { display: none; }
  .sync-status { display: none; }
}
