body { overflow: hidden; }
.wm { display: grid; grid-template-rows: 64px minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; background: var(--bg); }

/* header */
.wm-head { display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.wm-brand { display: flex; align-items: center; gap: 10px; width: 222px; flex: none; }
.wm-brand .logo { width: 38px; height: 38px; border-radius: 12px; }
.wm-brand .logo.img { width: auto; height: auto; }
.wm-brand .logo.img img { height: 32px; max-width: 140px; object-fit: contain; }
.wm-brand .logo svg { width: 20px; height: 20px; }
.wm-brand b { font-size: 18px; font-weight: 800; color: var(--text); }
.wm-brand small { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.wm-search { flex: 1; min-width: 0; max-width: 720px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 16px; box-shadow: var(--shadow); }
.wm-search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 8px 0; min-width: 0; }
.wm-search:focus-within { border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(var(--brand-rgb),.15); }
.wm-head .sp { flex: 1; }
.wm-head .me { cursor: pointer; border: 2px solid transparent; border-radius: 50%; padding: 2px; background: none; }
.wm-head .me:hover { border-color: var(--primary-2); }
.menu-toggle { display: none; }

/* body grid */
.wm-body { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 0; }
.wm-side { padding: 6px 12px 12px; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; }
.compose-btn { display: inline-flex; align-items: center; gap: 12px; padding: 14px 22px; margin: 4px 0 14px; border: 0; border-radius: 18px; background: var(--grad); color: #ffffff; font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: 0 8px 22px rgba(var(--brand-rgb),.28); transition: .15s; align-self: flex-start; }
.compose-btn:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 12px 28px rgba(var(--brand-rgb),.36); }
.compose-btn svg { width: 20px; height: 20px; }
.fitem { display: flex; align-items: center; gap: 14px; padding: 9px 14px; border-radius: 0 999px 999px 0; margin-left: -12px; padding-left: 26px; cursor: pointer; color: var(--text-2); font-weight: 600; user-select: none; }
.fitem svg { width: 19px; height: 19px; flex: none; }
.fitem:hover { background: var(--surface-2); color: var(--text); }
.fitem.active { background: var(--grad-soft); color: var(--primary); font-weight: 800; }

.fitem .n { margin-left: auto; font-size: 12.5px; font-weight: 800; }
.fitem .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 16px 14px 6px; display: flex; align-items: center; }
.side-label button { margin-left: auto; width: 26px; height: 26px; }
.storage { margin-top: auto; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.storage .progress { margin: 8px 0 6px; }

/* main pane */
.wm-main { background: var(--surface); border-radius: 20px 20px 0 0; margin-right: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--border); border-bottom: 0; }
.list-bar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); min-height: 54px; }
.list-bar .sp { flex: 1; }
.list-bar .pager { color: var(--text-3); font-size: 13px; font-weight: 600; margin-right: 6px; white-space: nowrap; }
.cbx { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; margin: 0 8px; }
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.tab { padding: 12px 18px; font-weight: 700; color: var(--text-3); border-bottom: 3px solid transparent; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.tab.active { color: var(--primary); border-color: var(--primary); }

.list { overflow-y: auto; flex: 1; }
.row { display: grid; grid-template-columns: auto auto 210px 1fr auto auto; align-items: center; gap: 4px; padding: 0 16px 0 4px; height: 52px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; transition: background .1s; }
.row:hover { box-shadow: inset 0 -1px 0 var(--border), 0 2px 8px rgba(0,0,0,.06); z-index: 1; background: var(--surface-2); }
.row.unread { background: color-mix(in srgb, var(--surface) 70%, var(--surface-2)); }
.row.unread .from, .row.unread .subj { font-weight: 800; color: var(--text); }
.row.selected { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.row .star { color: var(--text-3); border: 0; background: none; cursor: pointer; padding: 6px; display: grid; place-items: center; border-radius: 50%; }
.row .star svg { width: 18px; height: 18px; }
.row .star.on svg { fill: #f59e0b; color: #f59e0b; }
.row .from { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; color: var(--text-2); }
.row .from span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); padding-left: 10px; }
.row .subj { color: var(--text-2); font-weight: 600; }
.row .att svg { width: 16px; height: 16px; color: var(--text-3); }
.row .date { font-size: 12.5px; font-weight: 700; color: var(--text-3); text-align: right; min-width: 64px; }
.row.unread .date { color: var(--text); }
.row .hover-acts { display: none; position: absolute; right: 12px; background: inherit; gap: 2px; }
.row:hover .hover-acts { display: flex; }
.row:hover .date { visibility: hidden; }
.hover-acts .icon-btn { width: 34px; height: 34px; }
.hover-acts .icon-btn svg { width: 18px; height: 18px; }

/* reading view */
.reader { overflow-y: auto; flex: 1; padding: 8px 28px 40px; }
.reader h1 { font-size: 22px; font-weight: 700; margin: 12px 0 18px 52px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.reader .msg-head { display: flex; gap: 14px; align-items: flex-start; }
.reader .who { flex: 1; min-width: 0; }
.reader .who b { font-size: 15px; }
.reader .who .addr { color: var(--text-3); font-size: 13px; }
.reader .who .to { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.reader .when { color: var(--text-3); font-size: 12.5px; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.reader .body { margin: 18px 0 0 52px; }
.reader iframe { width: 100%; border: 0; min-height: 120px; background: #fff; border-radius: 12px; display: block; }
.reader .plain { white-space: pre-wrap; word-wrap: break-word; font-family: inherit; line-height: 1.6; margin: 0; }
.att-list { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 0 52px; }
.att-card { width: 190px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; text-decoration: none; color: var(--text); transition: .15s; background: var(--surface); }
.att-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.att-card .pv { height: 96px; display: grid; place-items: center; background: var(--grad-soft); font-weight: 800; font-size: 18px; color: var(--primary); }
.att-card .pv img { width: 100%; height: 100%; object-fit: cover; }
.att-card .meta { padding: 10px 12px; font-size: 12.5px; }
.att-card .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-card .meta span { color: var(--text-3); }
.reply-bar { display: flex; gap: 10px; margin: 28px 0 0 52px; flex-wrap: wrap; }
.reply-bar .btn { padding: 10px 22px; }
.chip-folder { font-size: 12px; background: var(--surface-2); color: var(--text-2); padding: 3px 10px; border-radius: 6px; font-weight: 700; }

/* compose */
.compose { position: fixed; right: 24px; bottom: 0; width: 560px; max-width: 100vw; height: 580px; max-height: calc(100vh - 40px); background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; z-index: 60; border: 1px solid var(--border); animation: pop .18s; }
.compose.min { height: 48px; overflow: hidden; }
.compose.max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1000px, 92vw); height: min(780px, 90vh); border-radius: 16px; }
.compose-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 18px; background: var(--grad); color: #ffffff; border-radius: 16px 16px 0 0; cursor: pointer; flex: none; }
.compose.max .compose-head { border-radius: 16px 16px 0 0; }
.compose-head b { flex: 1; font-size: 14px; font-weight: 700; }
.compose-head .icon-btn { color: #ffffff; width: 32px; height: 32px; }
.compose-head .icon-btn:hover { background: rgba(255,255,255,.2); }
.compose-head .icon-btn svg { width: 17px; height: 17px; }
.cfield { display: flex; align-items: center; border-bottom: 1px solid var(--border); padding: 0 16px; flex: none; }
.cfield label { color: var(--text-3); font-weight: 600; width: 70px; flex: none; }
.cfield input { flex: 1; border: 0; outline: 0; padding: 11px 0; background: transparent; min-width: 0; }
.cfield .cc-toggle { color: var(--text-3); font-weight: 600; cursor: pointer; padding: 4px 6px; border: 0; background: none; }
.cfield .cc-toggle:hover { color: var(--primary); }
.editor { flex: 1; overflow-y: auto; padding: 14px 16px; outline: 0; line-height: 1.6; min-height: 80px; }
.editor:empty::before { content: attr(data-ph); color: var(--text-3); }
.editor blockquote { margin: 0 0 0 .8ex; border-left: 2px solid var(--border); padding-left: 1ex; color: var(--text-2); }
.editor img { max-width: 100%; }
.fmt { display: flex; gap: 2px; padding: 4px 10px; border-top: 1px solid var(--border); flex: none; }
.fmt .icon-btn { width: 32px; height: 32px; }
.fmt .icon-btn svg { width: 16px; height: 16px; }
.c-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; flex: none; max-height: 90px; overflow-y: auto; }
.c-att { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 5px 6px 5px 10px; font-size: 12.5px; font-weight: 600; max-width: 240px; }
.c-att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-att button { border: 0; background: none; cursor: pointer; color: var(--text-3); display: grid; place-items: center; padding: 2px; }
.c-att button svg { width: 14px; height: 14px; }
.compose-foot { display: flex; align-items: center; gap: 6px; padding: 10px 14px 14px; flex: none; }
.compose-foot .sp { flex: 1; }
.compose-foot .send { padding: 10px 26px; }
.compose-foot .status { color: var(--text-3); font-size: 12px; }
.suggest { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 70; min-width: 260px; overflow: hidden; }
.suggest div { padding: 9px 14px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.suggest div:hover, .suggest div.on { background: var(--surface-2); }
.suggest small { color: var(--text-3); display: block; }

/* popover menu */
.pop { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 90; min-width: 220px; padding: 6px; animation: pop .12s; }
.pop .it { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.pop .it:hover { background: var(--surface-2); color: var(--text); }
.pop .it svg { width: 18px; height: 18px; }
.pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.pop .head { padding: 14px 12px; display: flex; gap: 12px; align-items: center; }
.pop .head small { color: var(--text-3); display: block; }

/* profile */
.profile-top { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 16px; text-align: center; }
.profile-top .pic { position: relative; }
.profile-top .pic .cam { position: absolute; right: 0; bottom: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; border: 3px solid var(--surface); cursor: pointer; }
.profile-top .pic .cam svg { width: 16px; height: 16px; }
.profile-top b { font-size: 18px; }
.profile-sec { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }

.loading-bar { height: 3px; background: var(--grad); background-size: 200% 100%; animation: lb 1s linear infinite; position: fixed; top: 0; left: 0; right: 0; z-index: 300; }
@keyframes lb { from { background-position: 0 0; } to { background-position: 200% 0; } }

@media (max-width: 1100px) {
  .row { grid-template-columns: auto auto 150px 1fr auto auto; }
}
@media (max-width: 860px) {
  .wm-brand { width: auto; }
  .wm-brand > div:last-child { display: none; }
  .menu-toggle { display: inline-grid; }
  .wm-body { grid-template-columns: minmax(0, 1fr); }
  .wm-head { gap: 6px; padding: 0 10px; }
  .wm-head .sp { display: none; }
  .wm-side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 55; background: var(--surface); transform: translateX(-100%); transition: .2s; box-shadow: var(--shadow-lg); padding-top: 16px; }
  .wm-side.open { transform: none; }
  .wm-main { margin: 0; border-radius: 16px 16px 0 0; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; height: auto; padding: 10px 14px; gap: 2px 10px; }
  .row .cbx, .row .star { display: none; }
  .row .from { grid-column: 1; }
  .row .from .avatar { display: none; }
  .row .line { grid-column: 1 / 3; padding-left: 0; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; }
  .row .att { display: none; }
  .row .date { grid-row: 1; grid-column: 2; }
  .row:hover .hover-acts { display: none; }
  .row:hover .date { visibility: visible; }
  .reader { padding: 8px 14px 40px; }
  .reader h1, .reader .body, .att-list, .reply-bar { margin-left: 0; }
  .compose, .compose.max { right: 0; left: 0; bottom: 0; top: 0; width: 100%; height: 100%; max-height: none; transform: none; border-radius: 0; }
  .compose-head { border-radius: 0; }
  .list-bar .pager { display: none; }
  .wm-search { padding-left: 12px; }
}
.wm-brand .logo.img, .wm-brand .logo.img img { width: auto; height: 34px; border-radius: 0; }
