:root {
  --bg: #ffffff;
  --inset: #f6f7f9;
  --hover: #f2f4f7;
  --border: rgba(20, 30, 45, 0.12);
  --text: #17212e;
  --text2: #5b6675;
  --muted: #97a1ad;
  --accent: #2f6fd0;
  --danger: #d43a3a;
  --warn: #b06a10;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171c24;
    --inset: #10151c;
    --hover: #1e2530;
    --border: rgba(235, 240, 248, 0.11);
    --text: #e8edf4;
    --text2: #9aa6b5;
    --muted: #667180;
    --accent: #6ba0e8;
    --danger: #e05252;
    --warn: #d99a3d;
  }
}

* { box-sizing: border-box; }

body {
  width: 360px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-height: 560px;
  overflow-y: auto;
}

.ic { display: block; flex: none; }

.header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
}

.header .title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.iconbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.iconbtn:hover { background: var(--hover); color: var(--text2); }
.iconbtn.spin .ic { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.row:hover { background: var(--hover); }

.row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.row .chev { color: var(--muted); transition: transform 0.12s ease; }
.row.open .chev { transform: rotate(90deg); }

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}

.avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: none;
}

.pfps { display: flex; flex: none; }

.pfp {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: none;
}

.pfps .pfp { box-shadow: 0 0 0 1.5px var(--inset); }
.pfps .pfp + .pfp { margin-left: -6px; }

.pfp-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.count {
  flex: none;
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

.clear-label { color: var(--muted); font-size: 12px; }
.kind-ic.yt { color: #d03535; }
.kind-ic.rss { color: #d98324; }
.warn-ic { color: var(--warn); }

.panel { background: var(--inset); border-bottom: 0.5px solid var(--border); }

.notif {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px 8px 26px;
  border-top: 0.5px solid var(--border);
  font-size: 12.5px;
  cursor: pointer;
}

.notif:first-child { border-top: none; }
.notif:hover { background: var(--hover); }

.notif .r-ic { color: var(--text2); }
.notif .r-ic.like { color: var(--danger); }
.notif .r-ic.follow { color: #2f9e6e; }
.notif .r-ic.reply, .notif .r-ic.mention, .notif .r-ic.quote { color: var(--accent); }

.notif .body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif .body b { font-weight: 600; }
.dim { color: var(--text2); }
.notif .when { flex: none; color: var(--muted); font-size: 11px; }

.notif .dismiss {
  flex: none;
  display: flex;
  padding: 3px;
  border: none;
  border-radius: 5px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  visibility: hidden;
}

.notif:hover .dismiss { visibility: visible; }
.notif .dismiss:hover { color: var(--danger); background: var(--bg); }

.panel-foot {
  display: flex;
  gap: 14px;
  padding: 8px 14px 9px 26px;
  border-top: 0.5px solid var(--border);
  font-size: 12px;
}

.panel-foot .link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.panel-foot .link:hover { text-decoration: underline; }

.banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text2);
  border-bottom: 0.5px solid var(--border);
  background: var(--inset);
}

.section-label {
  padding: 9px 14px 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text2);
}

.empty .big { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

.note { padding: 6px 14px 8px 26px; font-size: 12px; color: var(--muted); }
.error-note { color: var(--warn); }

button.primary {
  border: none;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
}

button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.55; cursor: default; }

/* Settings */
.settings-section { padding: 4px 0 6px; border-bottom: 0.5px solid var(--border); }

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
}

.settings-row .grow {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-row .sub { color: var(--muted); font-size: 11px; }

.form { display: flex; flex-direction: column; gap: 7px; padding: 6px 14px 10px; }

.form input[type="text"],
.form input[type="password"],
.form input[type="url"] {
  width: 100%;
  padding: 7px 9px;
  border: 0.5px solid var(--border);
  border-radius: 7px;
  background: var(--inset);
  color: var(--text);
  font-size: 12.5px;
}

.form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.form .hint { font-size: 11px; color: var(--muted); }
.form .hint a { color: var(--accent); text-decoration: none; }
.form .err { font-size: 12px; color: var(--danger); }

.filters { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 4px 14px 10px; }

.filters label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text2);
  cursor: pointer;
}

.foot {
  padding: 9px 14px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* Pro upsell */
.upsell {
  margin: 6px 14px 12px;
  padding: 12px 14px;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upsell-title { font-weight: 700; font-size: 13.5px; }
.upsell-copy { font-size: 12.5px; color: var(--text2); }

.link-btn {
  border: none;
  background: none;
  padding: 2px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  align-self: center;
}

.link-btn:hover { color: var(--accent); text-decoration: underline; }

/* Web-app shell (clearat.app/app) */
body.web { width: min(430px, 100%); margin: 0 auto; }
body.web #app { max-height: none; }
