/* Pulse — light, bold, simple. */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --ink: #111114;
  --ink-2: #5c5c66;
  --ink-3: #9a9aa4;
  --line: #ececf0;
  --accent: #6C5CE7;
  --good: #00B894;
  --warn: #E17055;
  --radius: 20px;
  --radius-s: 12px;
  --maxw: 600px;
  --tabbar-h: 62px;
  font-size: 16px;
}
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-soft);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: var(--radius-s);
  padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); }
label { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); display: block; margin: 12px 0 4px; }

/* ---------- layout ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; min-height: 54px;
}
.brand { font-weight: 900; font-size: 1.35rem; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
#topbar-actions { display: flex; gap: 8px; align-items: center; }

.view {
  max-width: var(--maxw); margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  min-height: 70vh;
}

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center; gap: 4px;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; max-width: 110px; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); font-size: 0.68rem; font-weight: 700; position: relative;
}
.tab svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.tab.active { color: var(--ink); }
.tab-badge {
  position: absolute; top: 8px; right: calc(50% - 20px);
  background: var(--warn); color: #fff; font-size: 0.62rem; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- generic ---------- */
.card {
  background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--line); overflow: hidden; margin-bottom: 16px;
}
.section-title { font-size: 1.5rem; font-weight: 900; letter-spacing: -0.02em; margin: 8px 0 16px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 0.75rem; color: var(--ink-3); font-weight: 600; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border-radius: 999px; padding: 5px 12px;
  font-size: 0.78rem; font-weight: 700; color: var(--ink-2);
}
a.chip:active { transform: scale(0.97); }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
}
.pill.active { background: #e3f8f1; color: #00785f; }
.pill.idea { background: #f0edff; color: #5b4bd6; }
.pill.paused { background: #fff3e0; color: #b06000; }
.pill.shipped { background: #e3f2fd; color: #0b63b5; }
.pill.archived { background: #f0f0f3; color: var(--ink-2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink); color: #fff; font-weight: 800;
  border-radius: 999px; padding: 12px 22px; font-size: 0.92rem;
}
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--bg-soft); color: var(--ink); }
.btn.small { padding: 8px 14px; font-size: 0.8rem; }
.btn.danger { background: #fdecec; color: #c0392b; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); font-size: 1.1rem; font-weight: 800;
}
.empty {
  text-align: center; padding: 56px 24px; color: var(--ink-2);
}
.empty .big { font-size: 2.6rem; margin-bottom: 12px; }
.empty h3 { font-weight: 800; color: var(--ink); margin-bottom: 6px; }
.empty p { font-size: 0.9rem; max-width: 420px; margin: 0 auto; line-height: 1.5; }

/* ---------- markdown ---------- */
.md { line-height: 1.6; font-size: 0.95rem; }
.md p, .md ul, .md ol, .md blockquote, .md pre { margin-bottom: 10px; }
.md p:last-child, .md ul:last-child, .md pre:last-child { margin-bottom: 0; }
.md h3, .md h4, .md h5, .md h6 { margin: 14px 0 6px; font-weight: 800; letter-spacing: -0.01em; }
.md ul, .md ol { padding-left: 22px; }
.md code { background: var(--bg-soft); border-radius: 6px; padding: 2px 6px; font-size: 0.85em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.md pre { background: #16161c; color: #f2f2f7; border-radius: var(--radius-s); padding: 14px; overflow-x: auto; }
.md pre code { background: none; color: inherit; padding: 0; }
.md a { color: var(--accent); font-weight: 700; }
.md blockquote { border-left: 4px solid var(--line); padding-left: 12px; color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- feed ---------- */
.post-cover { position: relative; aspect-ratio: 16/9; display: block; }
.post-cover img, .post-cover svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-kind {
  position: absolute; top: 12px; left: 12px;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(6px);
  border-radius: 999px; padding: 4px 12px; font-size: 0.68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.post-body { padding: 16px; }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.post-head .who { flex: 1; min-width: 0; }
.post-head .who b { display: block; font-size: 0.88rem; font-weight: 800; }
.post-title { font-size: 1.22rem; font-weight: 900; letter-spacing: -0.02em; line-height: 1.25; margin-bottom: 8px; }
.post-tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.post-md.clamped { max-height: 132px; overflow: hidden; position: relative; }
.post-md.clamped::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px;
  background: linear-gradient(transparent, var(--bg));
}
.read-more { font-weight: 800; font-size: 0.85rem; color: var(--accent); margin-top: 6px; }
.course-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  font-weight: 800; font-size: 0.9rem;
}
.course-banner.on_track { background: #e3f8f1; color: #00785f; }
.course-banner.drifting { background: #fdeee7; color: #b3491f; }
.feed-loader { text-align: center; padding: 24px; color: var(--ink-3); font-weight: 700; }

/* ---------- projects ---------- */
.project-row {
  display: flex; align-items: center; gap: 14px; padding: 16px;
}
.project-row .avatar { width: 52px; height: 52px; border-radius: 16px; font-size: 1.6rem; }
.project-row .info { flex: 1; min-width: 0; }
.project-row .info b { font-size: 1.05rem; font-weight: 800; display: block; }
.project-row .info .tagline { display: block; font-size: 0.82rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { min-width: 20px; height: 20px; border-radius: 10px; background: var(--warn); color: #fff; font-size: 0.7rem; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 6px; }

.project-hero { padding: 24px 16px 16px; text-align: center; }
.project-hero .avatar { width: 84px; height: 84px; border-radius: 26px; font-size: 2.6rem; margin: 0 auto 12px; }
.project-hero h1 { font-size: 1.7rem; font-weight: 900; letter-spacing: -0.02em; }
.project-hero .tagline { color: var(--ink-2); margin-top: 4px; font-size: 0.95rem; }
.hero-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; justify-content: center; }
.detail-section { padding: 16px; border-top: 1px solid var(--line); }
.detail-section h4 {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin-bottom: 8px;
}
.direction-card {
  margin: 0 16px 16px; padding: 14px 16px; border-radius: var(--radius-s);
  background: linear-gradient(135deg, #f6f4ff, #eef7ff); border: 1px solid #e4defc;
}
.direction-card h4 { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: #5b4bd6; margin-bottom: 6px; }
.tech-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- chats ---------- */
.conv-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.conv-row .info { flex: 1; min-width: 0; }
.conv-row .info b { display: block; font-weight: 800; font-size: 0.95rem; }
.conv-row .last { display: block; font-size: 0.82rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread { display: flex; flex-direction: column; gap: 10px; padding-bottom: 90px; }
.bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 0.93rem; line-height: 1.5;
  background: var(--bg); border: 1px solid var(--line); align-self: flex-start;
}
.bubble.user { background: var(--ink); color: #fff; align-self: flex-end; border: 0; }
.bubble.user .md a, .bubble.user .md code { color: #fff; background: rgba(255,255,255,0.15); }
.bubble .sender { font-size: 0.68rem; font-weight: 800; color: var(--ink-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.04em; }
.bubble.bot { border-color: #cdeee6; background: #f2fbf8; }
.bubble time { display: block; font-size: 0.64rem; color: var(--ink-3); margin-top: 4px; }
.bubble.user time { color: rgba(255,255,255,0.6); }
.chat-input {
  position: fixed; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); left: 0; right: 0; z-index: 25;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.chat-input .inner { max-width: var(--maxw); margin: 0 auto; padding: 10px 16px; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { resize: none; max-height: 120px; border-radius: 18px; }
.chat-input .btn { flex: none; height: 44px; }
.async-note { text-align: center; font-size: 0.72rem; color: var(--ink-3); padding: 6px 16px 2px; font-weight: 600; }

/* ---------- today ---------- */
.plan-date { font-size: 0.8rem; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.focus-item { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }
.focus-item .num {
  width: 28px; height: 28px; border-radius: 50%; flex: none; margin-top: 2px;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
}
.focus-item .goal { font-weight: 800; font-size: 0.97rem; }
.focus-item .note { font-size: 0.83rem; color: var(--ink-2); margin-top: 2px; line-height: 1.45; }
.focus-item .chip { margin-top: 8px; }

/* ---------- sheet / modal / toast ---------- */
#sheet-backdrop, #modal-backdrop {
  position: fixed; inset: 0; background: rgba(17,17,20,0.4); z-index: 40;
}
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg); border-radius: 24px 24px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: var(--maxw); margin: 0 auto;
  animation: slideup 0.18s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 14px; }
.sheet-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 8px;
  font-weight: 800; font-size: 1rem; border-radius: var(--radius-s); text-align: left;
}
.sheet-item:active { background: var(--bg-soft); }
.sheet-item .ico { width: 40px; height: 40px; border-radius: 14px; background: var(--bg-soft); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
#modal {
  position: fixed; inset: 0; z-index: 41; display: flex; align-items: center; justify-content: center; padding: 20px;
  pointer-events: none;
}
.modal-card {
  background: var(--bg); border-radius: var(--radius); padding: 20px;
  width: 100%; max-width: 480px; max-height: 86vh; overflow-y: auto;
  pointer-events: auto; animation: slideup 0.18s ease;
}
.modal-card h3 { font-weight: 900; font-size: 1.2rem; margin-bottom: 4px; letter-spacing: -0.01em; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }
#toast {
  position: fixed; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 0.85rem;
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

/* ---------- connect page ---------- */
.code-box {
  background: #16161c; color: #e8e8f0; border-radius: var(--radius-s);
  padding: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem; overflow-x: auto; white-space: pre; position: relative; line-height: 1.5;
}
.copy-row { display: flex; gap: 8px; align-items: center; margin: 8px 0 16px; }
.copy-row .value {
  flex: 1; background: var(--bg-soft); border-radius: var(--radius-s); padding: 10px 12px;
  font-family: ui-monospace, Menlo, monospace; font-size: 0.78rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.token-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.token-row .info { flex: 1; min-width: 0; }
.token-row .info b { display: block; font-size: 0.9rem; font-weight: 800; }
.token-row .info span { font-size: 0.72rem; color: var(--ink-3); font-family: ui-monospace, Menlo, monospace; }

/* ---------- interests ---------- */
.interest-row { padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.interest-row .info { flex: 1; min-width: 0; }
.interest-row .info b { font-weight: 800; display: block; margin-bottom: 2px; }
.interest-row .info p { font-size: 0.83rem; color: var(--ink-2); line-height: 1.45; }
.switch { position: relative; width: 46px; height: 28px; flex: none; margin-top: 2px; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; z-index: 2; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.15s; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2); transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- auth screen ---------- */
body.auth-screen #tabbar, body.auth-screen #topbar { display: none; }
body.auth-screen .view { padding-top: 8vh; }
.auth-wrap { max-width: 400px; margin: 0 auto; }
.auth-hero { text-align: center; margin-bottom: 24px; }
.auth-hero h1 { font-size: 2.2rem; font-weight: 900; letter-spacing: -0.03em; margin-top: 10px; }
.auth-hero p { color: var(--ink-2); margin-top: 6px; line-height: 1.5; font-weight: 600; }
.auth-error {
  margin-top: 12px; background: #fdecec; color: #c0392b;
  border-radius: var(--radius-s); padding: 10px 12px; font-size: 0.85rem; font-weight: 700;
}
.auth-switch { display: block; width: 100%; text-align: center; margin-top: 14px; font-weight: 800; font-size: 0.85rem; color: var(--accent); }

@media (min-width: 720px) {
  :root { --maxw: 640px; }
  .view { padding-top: 24px; }
}
