:root{
  --bg:#f6f8fc; --card:#fff; --ink:#202124; --muted:#5f6368; --line:#e3e6ea;
  --blue:#1a73e8; --blue2:#e8f0fe; --red:#ea4335; --yellow:#f9ab00; --green:#34a853;
  --r:16px; --side:256px;
}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:Inter,-apple-system,Roboto,Arial,sans-serif;background:var(--bg);color:var(--ink);line-height:1.5;-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}
button{font-family:inherit;cursor:pointer;border:0;background:none}

/* ===== layout ===== */
.app{display:grid;grid-template-columns:var(--side) 1fr;grid-template-rows:64px 1fr;height:100vh;overflow:hidden}
.topbar{grid-column:1/-1;display:flex;align-items:center;gap:14px;padding:8px 16px;background:var(--bg);border-bottom:1px solid transparent}
.iconbtn{width:44px;height:44px;border-radius:50%;display:grid;place-items:center;color:var(--muted);flex:none}
.iconbtn:hover{background:#e8eaed}
.logo{display:flex;align-items:center;gap:8px;font-size:22px;font-weight:800;color:var(--ink);width:var(--side);padding-inline-start:6px}
.logo .dot{width:26px;height:26px;border-radius:8px;background:linear-gradient(135deg,#ea4335,#f9ab00 45%,#34a853 75%,#1a73e8);flex:none}
.search{flex:1;max-width:720px;display:flex;align-items:center;gap:12px;background:#eaf1fb;border-radius:24px;padding:0 16px;height:48px}
.search input{flex:1;border:0;background:none;outline:none;font:inherit;font-size:15px;color:var(--ink)}
.search .sb{color:var(--muted)}
.search .funnel{color:var(--muted);border-inline-start:1px solid #cdd4dd;padding-inline-start:12px}
.topactions{margin-inline-start:auto;display:flex;align-items:center;gap:8px}
.avatar{width:36px;height:36px;border-radius:50%;background:linear-gradient(135deg,#1a73e8,#7b1fa2);color:#fff;font-weight:700;display:grid;place-items:center;font-size:14px;flex:none}

/* ===== sidebar ===== */
.sidebar{background:var(--bg);padding:8px 8px 8px 0;overflow-y:auto}
.sidebar::-webkit-scrollbar{width:8px}.sidebar::-webkit-scrollbar-thumb{background:#d6d9de;border-radius:8px}
.compose{margin:8px 0 12px 10px;display:inline-flex;align-items:center;gap:12px;background:var(--blue2);color:#001d35;border-radius:16px;padding:0 22px 0 16px;height:52px;font-weight:600;box-shadow:0 1px 2px rgba(0,0,0,.08)}
.compose:hover{background:#d7e6fb;box-shadow:0 2px 8px rgba(0,0,0,.12)}
.compose svg{width:22px;height:22px}
.nav a{display:flex;align-items:center;gap:16px;height:34px;padding:0 12px 0 14px;border-radius:0 18px 18px 0;font-size:14px;color:#202124;font-weight:500}
.nav a:hover{background:#e8eaed}
.nav a.on{background:#d3e3fd;font-weight:700;color:#001d35}
.nav a .cnt{margin-inline-start:auto;font-size:12px;font-weight:700}
.nav a svg{width:20px;height:20px;color:var(--muted)}
.nav a.on svg{color:#001d35}
.labelh{display:flex;justify-content:space-between;align-items:center;padding:16px 16px 6px;font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.4px}
.labels a{display:flex;align-items:center;gap:14px;height:32px;padding:0 12px 0 18px;border-radius:0 16px 16px 0;font-size:13.5px;color:#444}
.labels a:hover{background:#e8eaed}
.labels .sq{width:12px;height:12px;border-radius:3px;flex:none}
.labels .nm{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ===== main ===== */
.main{background:var(--card);border-radius:var(--r) 0 0 0;display:flex;flex-direction:column;overflow:hidden;min-width:0}
.toolbar{display:flex;align-items:center;gap:6px;padding:8px 14px;border-bottom:1px solid var(--line);flex-wrap:wrap}
.chk{width:18px;height:18px;border:2px solid #b9bfc6;border-radius:3px;flex:none;margin:0 8px}
.tabs{display:flex;gap:4px;margin-inline-start:6px}
.tabs button{padding:10px 16px;border-radius:8px 8px 0 0;font-size:14px;font-weight:600;color:var(--muted);border-bottom:3px solid transparent}
.tabs button:hover{background:#f1f3f4}
.tabs button.on{color:var(--blue);border-color:var(--blue)}
.count{margin-inline-start:auto;color:var(--muted);font-size:13px;padding-inline-end:6px}

/* ===== list ===== */
.list{overflow-y:auto;flex:1}
.list::-webkit-scrollbar{width:10px}.list::-webkit-scrollbar-thumb{background:#d6d9de;border-radius:8px}
.row{display:flex;align-items:center;gap:12px;padding:9px 16px;border-bottom:1px solid #f1f3f4;cursor:pointer;position:relative}
.row:hover{box-shadow:inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60,64,67,.3);z-index:2}
.row.unread{background:#fff;font-weight:700}
.row.unread .from{font-weight:800}
.row.starred .star{color:#f4b400}
.star{width:22px;color:#dadce0;flex:none;display:grid;place-items:center}
.star svg{width:18px;height:18px}
.star:hover{color:#c8ccd0}
.row .from{width:190px;flex:none;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .mid{flex:1;min-width:0;font-size:13.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row.unread .mid{color:#202124}
.row .mid .subj{color:#202124;font-weight:600}
.row.unread .mid .subj{font-weight:800}
.row .time{font-size:12px;color:var(--muted);flex:none}
.tag{font-size:10.5px;font-weight:800;border-radius:6px;padding:2px 7px;flex:none}
.tag.primary{background:#e6f4ea;color:#137333}
.tag.social{background:#e8f0fe;color:#1967d2}
.tag.promo{background:#fce8e6;color:#c5221f}
.badge{background:var(--blue);color:#fff;border-radius:10px;font-size:11px;font-weight:700;padding:1px 7px;flex:none}

/* ===== reader ===== */
.reader{position:fixed;inset:0;background:rgba(32,33,36,.5);display:none;align-items:flex-start;justify-content:center;z-index:60;padding:30px 16px}
.reader.open{display:flex}
.readcard{background:#fff;border-radius:16px;width:min(760px,100%);max-height:calc(100vh - 60px);display:flex;flex-direction:column;overflow:hidden;box-shadow:0 12px 40px rgba(0,0,0,.3)}
.rhead{display:flex;align-items:center;gap:10px;padding:14px 20px;border-bottom:1px solid var(--line)}
.rhead .subj{font-size:19px;font-weight:800;flex:1;min-width:0}
.rbody{padding:20px 24px;overflow-y:auto;font-size:14.5px;line-height:1.7;color:#3c4043;white-space:pre-wrap}
.rmeta{display:flex;gap:12px;align-items:center;padding:14px 24px 0}
.rmeta .av{width:42px;height:42px;border-radius:50%;background:linear-gradient(135deg,#1a73e8,#7b1fa2);color:#fff;display:grid;place-items:center;font-weight:700;flex:none}
.rmeta .who b{display:block;font-size:14px}
.rmeta .who span{font-size:12.5px;color:var(--muted)}
.ractions{display:flex;gap:8px;padding:14px 20px;border-top:1px solid var(--line)}
.ractions button{display:inline-flex;align-items:center;gap:8px;border:1px solid var(--line);border-radius:20px;padding:8px 16px;font-size:13.5px;font-weight:600;color:#3c4043}
.ractions button:hover{background:#f1f3f4}
.ractions button.pri{background:var(--blue);color:#fff;border-color:var(--blue)}

/* empty */
.empty{padding:60px 20px;text-align:center;color:var(--muted)}
.empty .e{font-size:52px;margin-bottom:10px}

/* compose */
.sheet{position:fixed;bottom:0;inset-inline-end:24px;width:min(520px,92vw);background:#fff;border-radius:14px 14px 0 0;box-shadow:0 -2px 20px rgba(0,0,0,.25);z-index:70;display:none;flex-direction:column;overflow:hidden}
.sheet.open{display:flex}
.sheet .sh{background:#f2f6fc;padding:12px 16px;font-weight:700;display:flex;justify-content:space-between;align-items:center}
.sheet input,.sheet textarea{border:0;border-bottom:1px solid var(--line);padding:12px 16px;font:inherit;font-size:14px;outline:none;width:100%}
.sheet textarea{border:0;min-height:180px;resize:vertical}
.sheet .sf{display:flex;align-items:center;gap:10px;padding:12px 16px}
.sheet .send{background:var(--blue);color:#fff;border-radius:20px;padding:9px 22px;font-weight:700;font-size:14px}

/* mobile */
.mobnav{display:none}
.hamb{display:none}
@media(max-width:820px){
  .app{grid-template-columns:1fr;grid-template-rows:56px 1fr}
  .logo{width:auto}.logo .txt{display:none}
  .sidebar{display:none}
  .main{border-radius:0}
  .topbar{gap:8px;padding:6px 10px;height:56px}
  .search{height:42px;padding:0 12px;min-width:0}
  .search .funnel{display:none}
  .search input{font-size:14px}
  .topactions{gap:4px}
  .toolbar{padding:6px 8px;gap:2px}
  .tabs button{padding:8px 10px;font-size:13px}
  .count{display:none}
  .row{padding:10px 12px;gap:8px}
  .row .from{width:92px;font-size:13.5px}
  .row .mid{font-size:12.5px}
  .row .mid .subj{font-size:13px}
  .row .time{font-size:11.5px}
  .tag{display:none}
  .hamb{display:grid}
  .readcard{border-radius:12px;max-height:calc(100vh - 24px)}
  .reader{padding:12px}
  .rhead .subj{font-size:16px}
  .rbody{padding:16px 18px;font-size:14px}
  .ractions{flex-wrap:wrap;gap:6px;padding:10px 14px}
  .ractions button{padding:8px 12px;font-size:13px}
  .sheet{inset-inline:8px;bottom:0;width:auto;border-radius:14px}
}
@media(max-width:430px){
  .row .from{width:78px}
  .row .mid{font-size:12px}
  .logo .dot{width:24px;height:24px}
}

/* ================= MOBILE APP-LIKE (SorialBox) ================= */
:root{ --navH:58px; }
.app{ height:100vh; height:100dvh; }
.topbar{ padding-top:calc(6px + env(safe-area-inset-top)); height:calc(56px + env(safe-area-inset-top)); }
.scrim{ position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:85; display:none; }
.scrim.open{ display:block; }
.fabwrap{ display:none; }
.bottomnav{ display:none; }
@media(max-width:820px){
  body{ overscroll-behavior-y:contain; }
  .logo{ display:none; }
  .sidebar{
    position:fixed; top:0; bottom:0; inset-inline-start:0; width:min(84vw,304px);
    z-index:90; display:block; background:#fff; padding:calc(14px + env(safe-area-inset-top)) 0 24px;
    border-radius:0 20px 20px 0; box-shadow:10px 0 34px rgba(0,0,0,.22);
    transform:translateX(-108%); transition:transform .22s cubic-bezier(.2,.7,.3,1);
  }
  .sidebar.open{ transform:translateX(0); }
  .sidebar .compose{ margin:2px 12px 14px; }
  .main{ border-radius:0; padding-bottom:calc(var(--navH) + env(safe-area-inset-bottom)); }
  .row{ padding:11px 12px; gap:9px; }
  .row .from{ width:auto; max-width:46%; font-size:13.5px; flex:0 0 auto; }
  .row .mid{ font-size:12.5px; }
  .row .time{ font-size:11px; }
  .row .star{ width:18px; }
  .reader{ padding:0; align-items:stretch; }
  .readcard{ width:100%; max-height:100dvh; height:100dvh; border-radius:0; }
  .rbody{ flex:1; }
  .ractions{ padding-bottom:calc(12px + env(safe-area-inset-bottom)); }
  .sheet{ inset-inline:0; bottom:calc(var(--navH) + env(safe-area-inset-bottom)); width:100%; border-radius:16px 16px 0 0; }
  .sheet textarea{ min-height:38vh; }
  .bottomnav{
    display:flex; position:fixed; inset-inline:0; bottom:0; height:calc(var(--navH) + env(safe-area-inset-bottom));
    padding-bottom:env(safe-area-inset-bottom); background:rgba(255,255,255,.98); backdrop-filter:blur(8px);
    border-top:1px solid var(--line); z-index:88;
  }
  .bottomnav button{ flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
    font-size:10.5px; font-weight:600; color:var(--muted); padding-top:6px; }
  .bottomnav button.on{ color:var(--blue); }
  .bottomnav button:active{ background:#eef3fb; }
  .bottomnav svg{ width:22px; height:22px; }
  .bottomnav .fab{ background:var(--blue); color:#fff; border-radius:16px; flex:0 0 54px; height:44px; margin:auto 10px; box-shadow:0 6px 16px rgba(26,115,232,.35); flex-direction:row; gap:6px; font-size:12px; }
  .bottomnav .fab svg{ width:18px; height:18px; }
  .fabwrap{ display:block; }
}
@media(max-width:430px){
  .row .from{ max-width:40%; }
}
