:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  color-scheme: light dark;
  --serif: ui-serif, 'New York', 'Iowan Old Style', Charter, Georgia, serif;
  --radius: 12px;
  --text: #1c1c1e; --page: #fcfcfc; --surface: #fff; --subtle: #f6f6f7; --hover: #f1f1f2; --selected: #edf4fe;
  --muted: #5f6063; --line: #e8e8ea; --border: #cfcfd3; --primary: #1f6fe5; --primary-hover: #185fcc; --on-primary: #fff;
  --teal: #0aa5ab; --danger: #b3261e; --danger-bg: #fdf2f1; --ok-bg: #eef7f1; --ok: #2f6b45; --focus: #4f94f5;
  --shadow: 0 1px 2px rgb(20 20 20 / .04), 0 8px 24px rgb(20 20 20 / .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #ececee; --page: #121214; --surface: #1b1b1e; --subtle: #202024; --hover: #26262b; --selected: #1c2c47;
    --muted: #a3a3a9; --line: #2c2c31; --border: #44444b; --primary: #4b8ff0; --primary-hover: #6aa3f4; --on-primary: #0b1220;
    --danger: #f2877f; --danger-bg: #3a1e1c; --ok-bg: #1b2e22; --ok: #8fd0a6; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.loading { padding: 4rem 1rem; text-align: center; color: var(--muted); }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100dvh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; text-decoration: none; color: inherit; }
.brand img { width: 26px; height: 23px; }
.brand small { font-family: Inter, -apple-system, sans-serif; font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .5rem; }
.top .spacer { flex: 1; }
.who { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

.bell-wrap { position: relative; }
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.bell:hover { background: var(--hover); }
.bell-icon { width: 1.4rem; height: 1.4rem; background: currentColor; -webkit-mask: url(/bell.svg) center / contain no-repeat; mask: url(/bell.svg) center / contain no-repeat; }
.bell .badge { position: absolute; top: .2rem; right: .1rem; border: 2px solid var(--surface); }
.notif-panel { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20; width: min(22rem, calc(100vw - 1.6rem)); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 16px 40px rgb(0 0 0 / .18); padding: .9rem; }
.notif-panel h2 { margin: 0 0 .5rem; }
.notif { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem .6rem; padding: .6rem .4rem; border-radius: 8px; text-decoration: none; color: inherit; }
.notif:hover { background: var(--hover); }
.notif span { grid-column: 1; color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif time { grid-column: 2; grid-row: 1; color: var(--muted); font-size: .78rem; }
.notif-panel .empty { padding: 1.2rem .5rem; }
.notif-foot { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--line); }
.notif-foot p { margin: 0; }
.nav { padding: 1rem .75rem; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: .2rem; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: .55rem .75rem; border-radius: 8px; text-decoration: none; color: inherit; font-size: .95rem; }
.nav a:hover { background: var(--hover); }
.nav a[aria-current="page"] { background: var(--selected); font-weight: 600; }
.nav .compose { margin-bottom: .7rem; justify-content: center; }
.badge { background: var(--primary); color: var(--on-primary); border-radius: 999px; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; min-width: 1.4rem; text-align: center; }
.nav .foot { margin-top: auto; padding: .75rem; font-size: .78rem; line-height: 1.45; color: var(--muted); }

main { padding: 1.4rem clamp(1rem, 3vw, 2.2rem) 3rem; min-width: 0; max-width: 980px; width: 100%; }
h1 { font-family: var(--serif); font-size: 1.55rem; margin: 0 0 1rem; font-weight: 600; }
h2 { font-size: 1rem; margin: 1.6rem 0 .6rem; }
.head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head h1 { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: .5rem .9rem; cursor: pointer; font-size: .92rem; text-decoration: none; color: inherit; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.link { border: 0; background: none; padding: .2rem .3rem; color: var(--primary); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: minmax(0, 13rem) minmax(0, 1fr) auto; gap: .9rem; align-items: baseline; padding: .8rem 1rem; text-decoration: none; color: inherit; }
.row:hover { background: var(--hover); }
.row .from, .row .line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .line span { color: var(--muted); }
.row time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.row.unread .from, .row.unread .line b { font-weight: 700; }
.row:not(.unread) .line b { font-weight: 500; }
.row.unread { box-shadow: inset 3px 0 0 var(--primary); }
.count { color: var(--muted); font-size: .8rem; margin-left: .3rem; }
.empty { padding: 2.6rem 1rem; text-align: center; color: var(--muted); }
.more { display: flex; justify-content: center; padding: 1rem; }

.message { padding: 1.1rem 1.2rem; }
.message + .message { border-top: 1px solid var(--line); }
.message header { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.message header b { font-size: .98rem; }
.message header time { margin-left: auto; color: var(--muted); font-size: .8rem; }
.message .to { color: var(--muted); font-size: .82rem; margin: .15rem 0 .7rem; overflow-wrap: anywhere; }
.message .body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.reply { padding: 1rem 1.2rem; border-top: 1px solid var(--line); background: var(--subtle); border-radius: 0 0 var(--radius) var(--radius); }

label { display: block; font-size: .82rem; font-weight: 600; margin: 1rem 0 .35rem; }
input[type="text"], input[type="search"], textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; background: var(--surface); }
textarea { min-height: 9rem; resize: vertical; line-height: 1.5; }
.form { padding: .4rem 1.2rem 1.2rem; }
.actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.picker { position: relative; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; border: 1px solid var(--border); border-radius: 8px; padding: .35rem; background: var(--surface); }
.chips:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.chips input { flex: 1; min-width: 10rem; border: 0; padding: .3rem .35rem; background: none; outline: none; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--selected); border-radius: 999px; padding: .2rem .3rem .2rem .65rem; font-size: .86rem; }
.chip.group { background: var(--ok-bg); color: var(--ok); }
.chip button { border: 0; background: none; cursor: pointer; border-radius: 50%; width: 1.3rem; height: 1.3rem; line-height: 1; color: inherit; }
.options { position: absolute; z-index: 4; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgb(0 0 0 / .14); list-style: none; margin: 0; padding: .3rem; max-height: 17rem; overflow: auto; }
.options li { padding: .45rem .6rem; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.options li[aria-selected="true"], .options li:hover { background: var(--selected); }
.options small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notice { border-radius: 10px; padding: .7rem .9rem; margin: 0 0 1rem; font-size: .9rem; background: var(--subtle); border: 1px solid var(--line); }
.notice.error { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.tag { font-size: .72rem; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; color: var(--muted); white-space: nowrap; }
.item { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; }
.item .grow { flex: 1; min-width: 0; }
.item .grow div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.item { text-decoration: none; color: inherit; }
a.item:hover { background: var(--hover); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stat { padding: .9rem 1rem; }
.stat b { display: block; font-size: 1.5rem; font-family: var(--serif); }

.signin { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(180deg, #a9d3ff33 0%, transparent 60%); }
.signin .card { max-width: 26rem; width: 100%; padding: 2.2rem 2rem; text-align: center; }
.signin img { width: 44px; height: 39px; }
.signin h1 { margin: .9rem 0 .4rem; font-size: 1.7rem; }
.signin p { color: var(--muted); line-height: 1.55; margin: 0 0 1.4rem; }
.signin .btn { width: 100%; padding: .7rem; }
.signin .lock { font-size: .78rem; margin: 1.2rem 0 0; }

.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); background: #2b2b2b; color: #fff; padding: .65rem 1rem; border-radius: 10px; font-size: .9rem; z-index: 20; max-width: calc(100vw - 2rem); }
[hidden] { display: none !important; }

.menu-btn, .fab, .scrim, .nav-user, .nav .signout { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .top { gap: .35rem; padding: .4rem .8rem .4rem .35rem; padding-top: calc(.4rem + env(safe-area-inset-top)); }
  .brand small, .who, .top .signout-top { display: none; }
  .menu-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; position: relative; width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; }
  .menu-btn:hover { background: var(--hover); }
  .menu-btn .bar { display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; }
  .menu-btn .dot { position: absolute; top: .45rem; right: .4rem; width: .65rem; height: .65rem; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 29; border: 0; padding: 0; background: rgb(0 0 0 / .42); }
  .nav { position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: min(19rem, 84vw); overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); box-shadow: 0 0 40px rgb(0 0 0 / .18); padding: calc(1rem + env(safe-area-inset-top)) .8rem calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-104%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
  .nav.open { transform: none; visibility: visible; }
  .nav a { min-height: 3rem; font-size: 1rem; }
  .nav-user { display: flex; flex-direction: column; gap: .1rem; padding: .2rem .75rem 1rem; margin-bottom: .7rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  .nav .signout { display: flex; margin-top: 1rem; }
  .fab { display: inline-flex; position: fixed; right: 1rem; bottom: calc(1.1rem + env(safe-area-inset-bottom)); z-index: 6; min-height: 3.1rem; padding: .8rem 1.2rem; border-radius: 999px; font-size: .95rem; box-shadow: 0 6px 20px rgb(31 111 229 / .35); }
  main { padding: 1rem .8rem 6rem; }
  h1 { font-size: 1.3rem; }
  .head h1 { flex: 1 1 100%; order: 5; }
  .row { grid-template-columns: minmax(0, 1fr) auto; row-gap: .15rem; padding: .85rem .9rem; }
  .row .line { grid-column: 1 / -1; grid-row: 2; }
  .message, .reply, .form { padding-left: .9rem; padding-right: .9rem; }
  .btn { min-height: 2.75rem; }
  .item { flex-wrap: wrap; }
  .toast { bottom: calc(5rem + env(safe-area-inset-bottom)); }
  .signin .card { padding: 1.8rem 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { .nav { transition: none; } }
.gap { margin-top: .8rem; }
.attach { margin-top: .7rem; }
.files { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.file { display: inline-flex; align-items: center; gap: .5rem; max-width: 100%; border: 1px solid var(--line); background: var(--subtle); border-radius: 8px; padding: .35rem .6rem; font-size: .86rem; overflow-wrap: anywhere; }
.file button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 1rem; line-height: 1; padding: .1rem .3rem; }
.message .files { margin-top: .9rem; }
