*{box-sizing:border-box}
:root{--bg:#f6f8fc;--surface:#fff;--surface-2:#f1f5f9;--text:#0f172a;--muted:#64748b;--border:#e2e8f0;--primary:#2563eb;--primary-dark:#1d4ed8;--primary-soft:#eff6ff;--danger:#ef4444;--mine:#2563eb;--theirs:#fff;--shadow:0 8px 30px rgba(15,23,42,.07);--radius:16px}
html,body{margin:0;min-height:100%;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;color:var(--text);background:var(--bg)}
body{overflow-x:hidden}
button,input,textarea{font:inherit}
button{cursor:pointer;border:0}
button:disabled{opacity:.55;cursor:not-allowed}
.hidden{display:none!important}
.muted{color:var(--muted)}
.small{font-size:.82rem}
.message{min-height:20px;margin:8px 0 0;font-size:.9rem}
.message.error{color:var(--danger)}
.message.ok{color:#059669}
.eyebrow{font-size:.72rem;letter-spacing:.12em;font-weight:800;color:var(--primary);margin:0 0 5px}
.primary-btn,.secondary-btn{border-radius:11px;padding:11px 16px;font-weight:750}
.primary-btn{background:var(--primary);color:#fff}
.primary-btn:hover{background:var(--primary-dark)}
.secondary-btn{background:var(--surface-2);color:var(--text);border:1px solid var(--border)}
.secondary-btn:hover{background:#e8eef6}
.primary-btn.full,.secondary-btn.full{width:100%}
.text-btn{display:block;margin:14px auto 0;background:transparent;color:var(--primary);font-weight:700;padding:4px}
.form-title{font-weight:800;margin:0}
.icon-btn{width:40px;height:40px;border-radius:50%;background:transparent;color:var(--text);font-size:20px;display:grid;place-items:center}
.icon-btn:hover{background:var(--surface-2)}

.auth-shell{min-height:100dvh;display:grid;place-items:center;padding:24px}
.auth-card{width:min(430px,100%);background:var(--surface);border:1px solid var(--border);border-radius:24px;padding:32px;box-shadow:var(--shadow)}
.brand-mark{width:52px;height:52px;border-radius:16px;display:grid;place-items:center;background:var(--primary);color:#fff;font-weight:900;font-size:24px;margin-bottom:18px}
.auth-card h1{margin:0 0 8px}
.auth-card>p{margin:0 0 22px}
.tabs{display:flex;background:var(--surface-2);padding:4px;border-radius:12px;margin-bottom:18px}
.tab{flex:1;padding:9px;border-radius:9px;background:transparent;color:var(--muted);font-weight:700}
.tab.active{background:#fff;color:var(--text);box-shadow:0 1px 4px rgba(15,23,42,.08)}
.stack-form{display:flex;flex-direction:column;gap:13px}
.stack-form input,.stack-form textarea,.search-box input,.chat-composer input{width:100%;border:1px solid var(--border);background:#fff;color:var(--text);border-radius:11px;padding:12px 14px;outline:0}
.stack-form input:focus,.stack-form textarea:focus,.search-box input:focus,.chat-composer input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,.12)}
.stack-form textarea{min-height:110px;resize:vertical}
.stack-form label{font-size:.86rem;font-weight:700;color:var(--text);display:flex;flex-direction:column;gap:7px}

.app-shell{min-height:100dvh}
.mobile-topbar{display:none}
.desktop-sidebar{position:fixed;inset:0 auto 0 0;width:250px;background:#fff;border-right:1px solid var(--border);padding:28px 18px;z-index:30}
.desktop-brand{font-size:23px;font-weight:900;color:var(--primary);padding:0 12px 30px}
.side-nav{display:flex;flex-direction:column;gap:5px}
.side-nav-item{width:100%;height:48px;border-radius:12px;background:transparent;color:var(--muted);display:flex;align-items:center;gap:14px;padding:0 14px;text-align:left}
.side-nav-item>span:first-child{font-size:22px;width:25px;text-align:center}
.side-nav-item:hover{background:var(--primary-soft);color:var(--primary)}
.side-nav-item.active{background:var(--primary);color:#fff}
.create-symbol{font-weight:900}
.nav-with-badge{position:relative!important}
.badge{position:absolute;top:-7px;right:-9px;min-width:17px;height:17px;padding:0 4px;border-radius:999px;background:var(--danger);color:#fff;font-size:9px;display:grid;place-items:center}
.logout-link{position:absolute;left:18px;right:18px;bottom:28px;height:44px;border-radius:12px;background:var(--surface-2);font-weight:700;color:var(--muted)}
.logout-link:hover{color:var(--danger)}
.main-area{margin-left:250px;min-height:100dvh;width:calc(100% - 250px);padding:32px 30px 60px}
.content-column{width:min(780px,100%);margin:0 auto}
.narrow-column{width:min(720px,100%)}
.view{width:100%}
.home-heading,.page-heading{display:flex;justify-content:space-between;align-items:flex-end;gap:20px;margin-bottom:24px}
.home-heading h1,.page-heading h1{margin:0;font-size:28px;letter-spacing:-.03em}
.page-heading{display:block}
.composer-card{background:#fff;border:1px solid var(--border);border-radius:18px;padding:13px;display:flex;align-items:center;gap:11px;margin-bottom:30px;box-shadow:0 2px 10px rgba(15,23,42,.035)}
.composer-avatar,.profile-avatar{border-radius:50%;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;font-weight:800;flex:0 0 auto;overflow:hidden}
.composer-avatar{width:42px;height:42px}
.composer-avatar img,.profile-avatar img{width:100%;height:100%;object-fit:cover}
.composer-trigger{flex:1;text-align:left;border-radius:12px;background:var(--surface-2);padding:12px 14px;color:var(--muted)}
.composer-image-btn{width:42px;height:42px;border-radius:11px;background:var(--primary-soft);color:var(--primary);font-size:20px}
.feed-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
.feed-heading h2{font-size:18px;margin:0}
.feed-list{display:flex;flex-direction:column;gap:18px}
.post-card{background:#fff;border:1px solid var(--border);border-radius:18px;overflow:hidden}
.post-head{padding:15px 16px;display:flex;align-items:center;gap:11px}
.post-avatar{width:42px;height:42px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;overflow:hidden;flex:0 0 auto}
.post-avatar img{width:100%;height:100%;object-fit:cover}
.post-meta{min-width:0;flex:1}
.post-meta strong{display:block}
.post-body{padding:0 16px 14px}
.post-body p{white-space:pre-wrap;overflow-wrap:anywhere;margin:0 0 12px}
.post-image{display:block;width:100%;max-height:620px;object-fit:cover;background:var(--surface-2)}
.post-actions{display:flex;align-items:center;gap:8px;padding:10px 16px;border-top:1px solid var(--border)}
.action-btn{background:transparent;border-radius:10px;padding:7px 9px;color:var(--muted);font-weight:700}
.action-btn:hover{background:var(--surface-2);color:var(--text)}
.action-btn.liked{color:var(--danger)}
.post-comments{padding:0 16px 12px}
.comment{font-size:.9rem;padding:4px 0}
.comment strong{margin-right:4px}
.comment-form{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--border)}
.comment-form input{flex:1;min-width:0;border:1px solid var(--border);border-radius:10px;padding:9px 11px}
.comment-form button{border-radius:10px;background:var(--primary);color:#fff;padding:0 14px;font-weight:700}
.post-owner-actions{margin-left:auto;display:flex;gap:5px}
.mini-btn{padding:6px 9px;border-radius:8px;background:var(--surface-2);font-size:.75rem;font-weight:700}
.mini-btn.danger{color:var(--danger)}
.loading-state,.empty-state{padding:34px 16px;text-align:center;color:var(--muted)}

.search-box{height:52px;background:#fff;border:1px solid var(--border);border-radius:14px;display:flex;align-items:center;padding:0 15px;gap:9px;box-shadow:0 2px 10px rgba(15,23,42,.035)}
.search-box>span{font-size:22px;color:var(--muted)}
.search-results{margin-top:16px;background:#fff;border:1px solid var(--border);border-radius:16px;overflow:hidden}
.search-user{display:flex;align-items:center;gap:12px;padding:15px;border-bottom:1px solid var(--border)}
.search-user:last-child{border-bottom:0}
.search-avatar{width:46px;height:46px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;overflow:hidden}
.search-avatar img{width:100%;height:100%;object-fit:cover}
.search-user-info{flex:1;min-width:0}
.search-user-info p{margin:2px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.profile-card{background:#fff;border:1px solid var(--border);border-radius:20px;padding:24px}
.profile-hero{display:flex;align-items:center;gap:16px;margin-bottom:24px}
.profile-avatar{width:72px;height:72px;font-size:26px}
.profile-hero h2{margin:0}
.profile-hero p{margin:3px 0 0}
.settings-divider{height:1px;background:var(--border);margin:28px 0}
.settings-section h3{margin:0 0 4px}

.messages-shell{width:min(1250px,100%);height:calc(100dvh - 64px);min-height:560px;margin:0 auto;background:#fff;border:1px solid var(--border);border-radius:20px;overflow:hidden;display:grid;grid-template-columns:320px minmax(0,1fr);box-shadow:var(--shadow)}
.conversation-panel{border-right:1px solid var(--border);min-width:0;display:flex;flex-direction:column;background:#fff}
.messages-title{padding:22px 18px 15px;display:flex;align-items:center;justify-content:space-between;flex:0 0 auto}
.messages-title h1{margin:0;font-size:23px}
.conversation-list{overflow-y:auto;min-height:0;overscroll-behavior:contain}
.conversation-item{width:100%;border:0;border-bottom:1px solid var(--border);background:#fff;padding:13px 15px;display:flex;align-items:center;gap:11px;text-align:left}
.conversation-item:hover{background:var(--surface-2)}
.conversation-item.active{background:var(--primary-soft)}
.conversation-avatar{width:46px;height:46px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;overflow:hidden;flex:0 0 46px}
.conversation-avatar img{width:100%;height:100%;object-fit:cover}
.conversation-content{flex:1;min-width:0}
.conversation-content strong{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conversation-content p{margin:2px 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conversation-time{text-align:right;min-width:42px}
.chat-panel{min-width:0;min-height:0;background:#f8fafc;position:relative}
.chat-empty-state{height:100%;display:grid;place-items:center;align-content:center;text-align:center;padding:32px;color:var(--muted)}
.chat-empty-state h2{margin:14px 0 5px;color:var(--text)}
.chat-empty-state p{max-width:420px;margin:0 0 18px;line-height:1.5}
.chat-empty-icon{width:64px;height:64px;border-radius:20px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;font-size:30px}
.chat-active{height:100%;min-height:0;display:flex;flex-direction:column;position:relative}
.chat-header{height:72px;flex:0 0 72px;background:#fff;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:11px;padding:0 16px}
.chat-back{display:none;width:38px;height:38px;border-radius:50%;background:var(--surface-2);font-size:21px}
.chat-avatar{width:42px;height:42px;border-radius:50%;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;overflow:hidden;flex:0 0 42px}
.chat-avatar img{width:100%;height:100%;object-fit:cover}
.chat-person{min-width:0;display:flex;flex-direction:column}
.chat-person strong{font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-more{margin-left:auto}
.chat-messages{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:20px 18px;display:flex;flex-direction:column;gap:12px;scrollbar-gutter:stable}
.chat-message{max-width:min(72%,520px);display:flex;flex-direction:column;gap:3px}
.chat-message.mine{align-self:flex-end;align-items:flex-end}
.chat-message.theirs{align-self:flex-start;align-items:flex-start}
.chat-bubble{padding:10px 13px;border-radius:17px;line-height:1.45;overflow-wrap:anywhere;white-space:pre-wrap}
.mine .chat-bubble{background:var(--mine);color:#fff;border-bottom-right-radius:5px}
.theirs .chat-bubble{background:#fff;border:1px solid var(--border);border-bottom-left-radius:5px}
.sender-label,.chat-time{font-size:10px;color:var(--muted);padding:0 4px}
.chat-composer{flex:0 0 auto;display:flex;gap:8px;background:#fff;border-top:1px solid var(--border);padding:11px}
.chat-composer input{height:44px}
.chat-composer button{width:46px;flex:0 0 46px;border-radius:11px;background:var(--primary);color:#fff;font-size:17px}
.chat-active>.message{background:#fff;margin:0;padding:0 11px 5px}
.new-message-notice{position:absolute;bottom:73px;left:50%;transform:translateX(-50%);background:var(--primary);color:#fff;padding:7px 12px;border-radius:999px;font-size:12px;font-weight:800;box-shadow:var(--shadow);cursor:pointer;z-index:3}

.mobile-nav{display:none}
.modal{position:fixed;inset:0;z-index:1000}
.modal-backdrop{position:absolute;inset:0;background:rgba(15,23,42,.45);backdrop-filter:blur(3px)}
.modal-sheet{position:absolute;left:50%;bottom:22px;transform:translateX(-50%);width:min(600px,calc(100% - 32px));background:#fff;border-radius:22px;padding:22px;box-shadow:0 20px 60px rgba(15,23,42,.25)}
.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}
.modal-header h2{margin:0}
.upload-box{border:1px dashed #cbd5e1;border-radius:12px;padding:12px;cursor:pointer;background:var(--surface-2);font-weight:700;color:var(--muted)}
.upload-box input{display:none}
.image-preview{border-radius:13px;overflow:hidden;background:var(--surface-2)}
.image-preview img{width:100%;max-height:260px;object-fit:cover;display:block}

@media(max-width:900px){
  .desktop-sidebar{width:220px}
  .main-area{margin-left:220px;width:calc(100% - 220px);padding:24px}
  .messages-shell{grid-template-columns:280px minmax(0,1fr)}
}
@media(max-width:768px){
  html,body{min-height:100%;background:#fff}
  body{padding-bottom:calc(64px + env(safe-area-inset-bottom))}
  body.chat-open{overflow:hidden}
  .mobile-topbar{position:fixed;top:0;left:0;right:0;z-index:90;height:58px;background:rgba(255,255,255,.96);backdrop-filter:blur(14px);border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:0 14px}
  .brand-button{background:transparent;color:var(--primary);font-size:21px;font-weight:900}
  .top-actions{display:flex;gap:2px}
  .desktop-sidebar{display:none}
  .main-area{margin:0;width:100%;padding:74px 12px calc(18px + env(safe-area-inset-bottom))}
  .content-column,.narrow-column{width:100%}
  .home-heading{align-items:flex-start;margin-bottom:17px}
  .home-heading h1,.page-heading h1{font-size:24px}
  .create-desktop{display:none}
  .composer-card{margin-bottom:22px}
  .feed-list{gap:10px}
  .post-card{border-left:0;border-right:0;border-radius:0;margin-left:-12px;margin-right:-12px}
  .post-head{padding:13px 14px}
  .post-body{padding:0 14px 12px}
  .post-image{max-height:70vh}
  .post-actions{padding:9px 14px}
  .post-comments{padding:0 14px 10px}
  .comment-form{padding:10px 14px}
  .page-heading{margin-bottom:18px}
  .search-results{border-left:0;border-right:0;border-radius:0;margin-left:-12px;margin-right:-12px}
  .profile-card{border-left:0;border-right:0;border-radius:0;margin-left:-12px;margin-right:-12px;padding:18px 14px}
  .mobile-nav{position:fixed;display:flex;left:0;right:0;bottom:0;z-index:100;height:calc(64px + env(safe-area-inset-bottom));padding-bottom:env(safe-area-inset-bottom);background:rgba(255,255,255,.97);backdrop-filter:blur(16px);border-top:1px solid var(--border);justify-content:space-around}
  .mobile-nav-item{flex:1;max-width:100px;background:transparent;color:var(--muted);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}
  .mobile-nav-item>span{font-size:21px;line-height:1}
  .mobile-nav-item small{font-size:10px;font-weight:650}
  .mobile-nav-item.active{color:var(--primary)}
  .mobile-nav-item.create>span{width:32px;height:32px;background:var(--primary);color:#fff;border-radius:11px;display:grid;place-items:center;font-size:21px}

  .messages-shell{position:relative;width:auto;height:calc(100dvh - 58px - 64px - env(safe-area-inset-bottom));min-height:0;margin:-16px -12px -18px;border:0;border-radius:0;display:block;background:#fff;overflow:hidden}
  .conversation-panel{height:100%;border:0}
  .messages-title{padding:18px 14px 12px}
  .conversation-list{height:calc(100% - 75px)}
  .chat-panel{position:fixed;inset:58px 0 calc(64px + env(safe-area-inset-bottom)) 0;z-index:80;background:#f8fafc;height:auto;min-height:0}
  .chat-empty-state{display:none}
  .chat-active{height:100%}
  .chat-panel:not(.mobile-visible){display:none}
  .chat-panel.mobile-visible{display:block}
  .chat-active .chat-header{height:64px;flex-basis:64px;padding:0 10px}
  .chat-back{display:grid;place-items:center}
  .chat-messages{padding:16px 12px 18px;gap:10px}
  .chat-message{max-width:82%}
  .chat-composer{padding:9px 10px}
  .chat-composer input{height:46px}
  .chat-composer button{height:46px;width:46px;flex-basis:46px}
  .new-message-notice{bottom:68px}
  .chat-active>.message{padding:0 10px 5px}

  .modal-sheet{bottom:0;width:100%;max-height:88dvh;border-radius:22px 22px 0 0;padding:18px 16px calc(18px + env(safe-area-inset-bottom));overflow:auto}
  .modal-backdrop{backdrop-filter:none}
}
@media(min-width:769px){.mobile-topbar,.mobile-nav{display:none!important}}


/* Authentication follow-up actions */
.auth-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.auth-actions.hidden {
  display: none;
}
.auth-actions button:disabled {
  opacity: .65;
  cursor: wait;
}



/* =========================
   LEGAL FOOTER
========================= */

.legal-footer {
  text-align: center;
  padding: 18px 16px 100px;
  font-size: 13px;
  color: #8a8f98;
}

.legal-footer a {
  color: #5b6ee1;
  text-decoration: none;
}

.legal-footer a:hover {
  text-decoration: underline;
}

.legal-footer span {
  margin: 0 8px;
  color: #b0b4bb;
}
