:root{--bg:#f5f7fb;--panel:#fff;--panel2:#f8fafc;--text:#0f172a;--muted:#64748b;--line:#e2e8f0;--brand:#2563eb;--brand2:#7c3aed;--good:#16a34a;--danger:#dc2626;--warn:#d97706;--shadow:0 20px 60px rgba(15,23,42,.12);--radius:22px}
[data-theme=dark]{--bg:#07111f;--panel:#0f1b2d;--panel2:#111f35;--text:#f8fafc;--muted:#a5b4c8;--line:#23344d;--brand:#60a5fa;--brand2:#a78bfa;--shadow:0 22px 70px rgba(0,0,0,.42)}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;background:var(--bg);color:var(--text)}a{color:inherit;text-decoration:none}button,input,textarea,select{font:inherit}.app{display:grid;grid-template-columns:280px minmax(0,1fr) 330px;min-height:100vh}.sidebar{position:sticky;top:0;height:100vh;padding:20px;background:linear-gradient(180deg,var(--panel),var(--panel2));border-right:1px solid var(--line);overflow:auto}.brand{display:flex;align-items:center;gap:12px;margin-bottom:22px}.brand img{width:44px;height:44px;object-fit:contain;border-radius:12px}.brand h1{font-size:18px;line-height:1.05;margin:0;font-weight:950;letter-spacing:-.04em}.brand span{display:block;color:var(--muted);font-size:12px;font-weight:800;margin-top:3px}.nav{display:grid;gap:8px}.nav a{display:flex;align-items:center;justify-content:space-between;padding:13px 14px;border-radius:16px;color:var(--muted);font-weight:850}.nav a.active,.nav a:hover{background:linear-gradient(135deg,rgba(37,99,235,.14),rgba(124,58,237,.12));color:var(--text)}.pill{font-size:11px;padding:4px 8px;border-radius:999px;background:rgba(37,99,235,.13);color:var(--brand);font-weight:900}.main{min-width:0;padding:22px 24px 34px}.topbar{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:18px}.search{flex:1;max-width:620px;display:flex;align-items:center;gap:10px;background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:12px 14px;box-shadow:0 8px 24px rgba(15,23,42,.04)}.search input{border:0;outline:0;background:transparent;color:var(--text);width:100%}.user-chip{display:flex;align-items:center;gap:10px;background:var(--panel);border:1px solid var(--line);padding:8px 12px;border-radius:18px}.avatar{width:42px;height:42px;border-radius:15px;background:linear-gradient(135deg,var(--brand),var(--brand2));display:grid;place-items:center;color:#fff;font-weight:950;overflow:hidden;flex:none}.avatar img{width:100%;height:100%;object-fit:cover}.hero{padding:24px;border-radius:28px;background:linear-gradient(135deg,#1e3a8a,#7c3aed);color:#fff;box-shadow:var(--shadow);margin-bottom:18px;position:relative;overflow:hidden}.hero:after{content:"";position:absolute;right:-100px;top:-100px;width:280px;height:280px;border-radius:999px;background:rgba(255,255,255,.14)}.hero h2{margin:0;font-size:30px;letter-spacing:-.05em}.hero p{margin:8px 0 0;color:rgba(255,255,255,.82);max-width:760px;line-height:1.6}.grid{display:grid;gap:18px}.grid.two{grid-template-columns:1fr 1fr}.grid.three{grid-template-columns:repeat(3,1fr)}.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 34px rgba(15,23,42,.06);padding:18px}.card h3{margin:0 0 12px;font-size:17px;letter-spacing:-.03em}.muted{color:var(--muted)}.stat{display:flex;align-items:center;justify-content:space-between}.stat strong{font-size:28px;letter-spacing:-.06em}.composer textarea{width:100%;min-height:100px;resize:vertical;border:1px solid var(--line);background:var(--panel2);color:var(--text);border-radius:18px;padding:14px;outline:none}.row{display:flex;align-items:center;gap:10px}.between{justify-content:space-between}.btn{border:0;border-radius:14px;padding:11px 15px;font-weight:950;cursor:pointer;background:var(--panel2);color:var(--text);border:1px solid var(--line);display:inline-flex;align-items:center;gap:8px}.btn.primary{background:linear-gradient(135deg,var(--brand),var(--brand2));color:#fff;border-color:transparent}.btn.danger{background:rgba(220,38,38,.12);color:var(--danger);border-color:rgba(220,38,38,.22)}.btn.good{background:rgba(22,163,74,.13);color:var(--good);border-color:rgba(22,163,74,.22)}.input,textarea,select{width:100%;border:1px solid var(--line);background:var(--panel2);color:var(--text);border-radius:15px;padding:12px 13px;outline:none}.input:focus,textarea:focus,select:focus{border-color:var(--brand);box-shadow:0 0 0 4px rgba(37,99,235,.12)}label{display:block;font-size:13px;font-weight:900;color:var(--muted);margin:12px 0 7px}.post{display:grid;gap:12px}.post-head{display:flex;gap:12px;align-items:center}.post-head strong{display:block}.post-content{white-space:pre-wrap;line-height:1.6}.post-media{max-width:100%;border-radius:18px;border:1px solid var(--line)}.rightbar{position:sticky;top:0;height:100vh;overflow:auto;border-left:1px solid var(--line);background:var(--panel2);padding:20px}.list{display:grid;gap:10px}.item{display:flex;gap:11px;align-items:center;padding:12px;border:1px solid var(--line);background:var(--panel);border-radius:18px}.item-body{min-width:0;flex:1}.item-body strong{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.item-body span{font-size:13px;color:var(--muted)}.chat-layout{display:grid;grid-template-columns:320px 1fr;gap:18px}.chat-box{height:calc(100vh - 170px);display:flex;flex-direction:column}.messages{flex:1;overflow:auto;padding:16px;background:var(--panel2);border-radius:18px;border:1px solid var(--line)}.bubble{max-width:72%;padding:11px 13px;margin:8px 0;border-radius:17px;background:var(--panel);border:1px solid var(--line);line-height:1.5}.bubble.me{margin-left:auto;background:linear-gradient(135deg,var(--brand),var(--brand2));color:#fff;border-color:transparent}.chat-form{display:flex;gap:10px;margin-top:12px}.auth{min-height:100vh;display:grid;grid-template-columns:minmax(380px,520px) 1fr}.auth-panel{display:flex;align-items:center;justify-content:center;padding:34px;background:var(--panel)}.auth-card{width:100%;max-width:430px}.auth-art{display:grid;place-items:center;padding:40px;background:linear-gradient(135deg,#0f172a,#1e3a8a 55%,#7c3aed);color:#fff}.auth-art h1{font-size:52px;line-height:1;letter-spacing:-.07em;margin:0}.auth-art p{font-size:18px;max-width:620px;color:rgba(255,255,255,.82);line-height:1.7}.alert{padding:12px 14px;border-radius:15px;margin:12px 0;font-weight:750}.alert.error{background:#fef2f2;color:#991b1b;border:1px solid #fecaca}.alert.success{background:#ecfdf5;color:#166534;border:1px solid #bbf7d0}.table{width:100%;border-collapse:separate;border-spacing:0 10px}.table th{text-align:left;color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.08em}.table td{background:var(--panel2);padding:13px;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}.table td:first-child{border-left:1px solid var(--line);border-radius:14px 0 0 14px}.table td:last-child{border-right:1px solid var(--line);border-radius:0 14px 14px 0}.mobile-menu{display:none}@media(max-width:1120px){.app{grid-template-columns:240px minmax(0,1fr)}.rightbar{display:none}.grid.three{grid-template-columns:1fr}.grid.two{grid-template-columns:1fr}}@media(max-width:760px){.auth{grid-template-columns:1fr}.auth-art{display:none}.app{display:block}.sidebar{position:relative;height:auto}.main{padding:16px}.chat-layout{grid-template-columns:1fr}.bubble{max-width:88%}.topbar{align-items:flex-start;flex-direction:column}.search{max-width:none;width:100%}}
.wrap{flex-wrap:wrap}.profile-head{display:flex;gap:16px;align-items:center}.avatar.large{width:84px;height:84px;border-radius:28px;font-size:24px}.sponsored{border-color:rgba(245,158,11,.35);background:linear-gradient(180deg,var(--panel),rgba(245,158,11,.06))}.sponsored-side{margin-top:18px}.ad-mini{display:grid;gap:6px;padding:13px;border-radius:18px;border:1px solid rgba(245,158,11,.28);background:rgba(245,158,11,.06)}.ad-mini strong{font-size:14px}.ad-mini span:last-child{color:var(--muted);font-size:13px}.file-card,.attachment{display:inline-flex;align-items:center;gap:8px;padding:10px 12px;border:1px solid var(--line);border-radius:14px;background:var(--panel2);font-weight:850;margin:8px 0}.call-grid{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:18px}.call-stage{position:relative;min-height:520px;background:#020617;overflow:hidden;padding:0}.call-stage video#remoteVideo{width:100%;height:100%;min-height:520px;object-fit:cover;background:#020617}.call-stage video#localVideo{position:absolute;right:18px;bottom:18px;width:220px;height:140px;object-fit:cover;border-radius:18px;border:2px solid rgba(255,255,255,.65);background:#111827;box-shadow:0 18px 40px rgba(0,0,0,.35)}code{display:block;padding:12px;border-radius:14px;background:var(--panel2);border:1px solid var(--line);white-space:pre-wrap}.chat-form input[type=file]{padding:9px}@media(max-width:900px){.call-grid{grid-template-columns:1fr}.call-stage{min-height:360px}.call-stage video#remoteVideo{min-height:360px}.call-stage video#localVideo{width:140px;height:96px}.chat-form{flex-wrap:wrap}.chat-form .input{min-width:180px}}
/* ================================
   RINCM PWA + Mobile + Tablet Responsive
   Corrected for current classes:
   .app, .sidebar, .nav, .main, .rightbar
================================ */

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .rightbar {
    display: none;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .call-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 80;
    width: 100%;
    height: auto;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 10px 12px;
  }

  .brand {
    margin-bottom: 10px;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand span {
    font-size: 11px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

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

  .nav a {
    white-space: nowrap;
    min-width: max-content;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
  }

  .main {
    padding: 14px;
    width: 100%;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }

  .search {
    max-width: none;
    width: 100%;
  }

  .user-chip {
    width: 100%;
    justify-content: flex-start;
  }

  .hero {
    border-radius: 22px;
    padding: 22px;
  }

  .hero h2 {
    font-size: 24px;
    line-height: 1.2;
  }

  .hero p {
    font-size: 14px;
  }

  .card {
    border-radius: 20px;
    padding: 16px;
  }

  .composer textarea {
    min-height: 110px;
  }

  .row,
  .row.wrap,
  .row.between,
  .post .row {
    flex-wrap: wrap;
  }

  .between {
    align-items: stretch;
  }

  input,
  select,
  textarea,
  button,
  .btn {
    font-size: 16px;
  }

  .btn,
  button {
    min-height: 44px;
  }

  .post-media {
    width: 100%;
    max-height: 460px;
    object-fit: contain;
    border-radius: 18px;
  }

  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  .file-card,
  .attachment,
  .item {
    width: 100%;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-box {
    height: calc(100vh - 230px);
    min-height: 520px;
  }

  .messages {
    min-height: 360px;
  }

  .chat-form {
    flex-wrap: wrap;
  }

  .chat-form .input,
  .chat-form input[type="file"],
  .chat-form button {
    width: 100%;
  }

  .bubble {
    max-width: 88%;
  }

  .call-stage {
    min-height: 360px;
  }

  .call-stage video#remoteVideo {
    min-height: 360px;
  }

  .call-stage video#localVideo {
    width: 140px;
    height: 96px;
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 540px) {
  .main {
    padding: 10px;
  }

  .sidebar {
    padding: 10px;
  }

  .brand {
    transform: scale(0.95);
    transform-origin: left center;
  }

  .hero {
    padding: 18px;
  }

  .hero h2 {
    font-size: 21px;
  }

  .grid,
  .grid.two,
  .grid.three {
    gap: 12px;
  }

  .card {
    padding: 14px;
  }

  .stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .stat strong {
    font-size: 24px;
  }

  .post-head {
    align-items: flex-start;
  }

  .avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  .composer input[type="file"] {
    max-width: 100% !important;
  }

  .composer .row,
  .composer .row.wrap,
  .composer .row.between {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .composer select,
  .composer input[type="file"],
  .composer button {
    width: 100%;
  }

  .post-media {
    max-height: 390px;
  }

  .auth-panel {
    padding: 20px;
  }

  .auth-card {
    max-width: 100%;
  }
}

/* Dark mode mobile header transparency */
[data-theme="dark"] .sidebar {
  background: rgba(15, 27, 45, 0.94);
}

/* PWA / iOS safe-area support */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .sidebar {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
}