:root {
  color-scheme: light; --ink:#231d35; --muted:#756f83; --violet:#7454e8;
  --line:#e9e5f2; --surface:rgba(255,255,255,.92);
  font-family:Inter,ui-rounded,"PingFang TC","Microsoft JhengHei",system-ui,sans-serif;
}
* { box-sizing:border-box; }
body {
  margin:0; min-height:100vh; min-height:100dvh; color:var(--ink);
  background:radial-gradient(circle at 12% 15%,rgba(255,184,212,.7),transparent 32%),radial-gradient(circle at 88% 85%,rgba(169,151,255,.65),transparent 36%),#f8f5ff;
}
button,input,textarea { font:inherit; }
button { cursor:pointer; border:0; border-radius:14px; padding:12px 18px; color:#fff; font-weight:800; background:var(--violet); }
button:hover { background:#5c3dd2; }
.shell { min-height:100vh; min-height:100dvh; display:grid; place-items:center; padding:20px; }
.login-card,.chat-card { width:min(100%,760px); background:var(--surface); border:1px solid rgba(255,255,255,.9); border-radius:28px; box-shadow:0 24px 70px rgba(60,38,110,.18); backdrop-filter:blur(18px); }
.login-card { max-width:430px; padding:38px; }
.logo { width:56px; height:56px; display:grid; place-items:center; border-radius:18px; color:#fff; font-size:30px; background:linear-gradient(135deg,#fb799f,#7555e8); box-shadow:0 12px 28px rgba(116,84,232,.25); }
.eyebrow { margin:20px 0 5px; color:var(--violet); font-size:11px; font-weight:800; letter-spacing:.15em; }
h1 { margin:0; font-size:clamp(24px,4vw,34px); letter-spacing:-.04em; }
.hint { color:var(--muted); margin:10px 0 25px; }
label { display:grid; gap:7px; margin-top:15px; font-size:14px; font-weight:700; }
input,textarea { width:100%; color:var(--ink); border:1px solid var(--line); border-radius:14px; outline:none; background:#fff; }
input { padding:13px 15px; }
input:focus,textarea:focus { border-color:var(--violet); box-shadow:0 0 0 3px rgba(116,84,232,.12); }
#loginForm>button { width:100%; margin-top:22px; }
.error { min-height:20px; margin:9px 0 0; color:#c32955; font-size:13px; }
.connection-test { display:flex; align-items:center; gap:8px; margin:18px 0 0; color:var(--muted); font-size:12px; }
.dot { width:8px; height:8px; border-radius:50%; background:#d29a27; }
.dot.online { background:#2eb67d; } .dot.offline { background:#db4567; }
.chat-card { height:min(850px,calc(100dvh - 40px)); display:grid; grid-template-rows:auto 1fr auto auto; overflow:hidden; }
header { display:flex; justify-content:space-between; align-items:center; padding:22px 25px; border-bottom:1px solid var(--line); }
header .eyebrow { margin-top:0; } header h1 { font-size:22px; }
.header-actions { display:flex; align-items:center; gap:10px; }
.badge { padding:6px 10px; color:#8b6313; background:#fff2c8; border-radius:999px; font-size:12px; font-weight:800; }
.badge.online { color:#147652; background:#dff8ed; } .badge.fallback { color:#755c17; background:#fff2c8; } .badge.offline { color:#a62546; background:#ffe2e9; }
.quiet { padding:7px 10px; color:var(--muted); background:transparent; }
.messages { overflow-y:auto; padding:22px; background:rgba(250,248,255,.72); }
.empty { text-align:center; color:var(--muted); margin-top:25%; }
.message-row { display:flex; margin:8px 0; } .message-row.mine { justify-content:flex-end; }
.message { max-width:min(76%,520px); }
.message-meta { margin:0 7px 4px; color:var(--muted); font-size:11px; } .mine .message-meta { text-align:right; }
.bubble { padding:10px 13px; border-radius:17px 17px 17px 5px; background:#fff; border:1px solid var(--line); white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.45; }
.mine .bubble { color:#fff; background:linear-gradient(135deg,#8b6bf0,#6847d7); border:0; border-radius:17px 17px 5px 17px; }
.composer { display:grid; grid-template-columns:1fr auto; gap:10px; padding:14px 18px calc(14px + env(safe-area-inset-bottom)); border-top:1px solid var(--line); background:#fff; }
textarea { min-height:46px; max-height:130px; resize:none; padding:12px 14px; line-height:1.4; }
.footer-error { margin:0; padding:0 20px 8px; background:#fff; } .hidden { display:none; }
@media(max-width:600px) {
  .shell{padding:0}.login-card{margin:18px;padding:28px 24px}.chat-card{width:100%;height:100dvh;border-radius:0;border:0}header{padding:16px}.messages{padding:15px}.badge{display:none}.message{max-width:84%}
}

/* Mail workspace */
:root { --mail-blue:#0f6cbd; --mail-blue-dark:#115ea3; --mail-bg:#f5f5f5; --mail-line:#e1dfdd; }
body { background:#f3f2f1; font-family:"Segoe UI","Microsoft JhengHei",system-ui,sans-serif; }
.shell { padding:0; }
.login-card { border-radius:2px; border:0; max-width:440px; padding:44px; box-shadow:0 2px 8px rgba(0,0,0,.18); backdrop-filter:none; }
.mail-logo { width:44px; height:44px; display:grid; place-items:center; background:var(--mail-blue); color:#fff; font-size:24px; font-weight:600; }
.login-card .eyebrow { color:var(--mail-blue); margin-top:24px; }
.login-card h1 { font-size:26px; letter-spacing:0; font-weight:600; }
.login-card input { border:0; border-bottom:1px solid #666; border-radius:0; padding:10px 0; }
.login-card input:focus { border-color:var(--mail-blue); box-shadow:none; }
.login-card button { margin-left:auto; width:auto!important; min-width:108px; border-radius:2px; background:var(--mail-blue); }

.mail-window {
  width:100vw; height:100vh; height:100dvh; display:grid; overflow:hidden; background:#fff;
  grid-template-columns:48px 220px 310px minmax(420px,1fr);
  grid-template-rows:48px 1fr;
  grid-template-areas:"top top top top" "rail folders list reading";
}
.mail-window.hidden { display:none; }
.titlebar { grid-area:top; display:flex; align-items:center; gap:14px; padding:0 12px; color:#fff; background:var(--mail-blue); }
.waffle { width:22px; font-size:13px; line-height:8px; letter-spacing:1px; transform:rotate(90deg); }
.brand { min-width:170px; font-size:16px; font-weight:600; }
.searchbox { width:min(540px,48vw); margin:auto; padding:7px 14px; color:#323130; background:rgba(255,255,255,.9); border-radius:4px; font-size:13px; }
.titlebar .badge { color:#fff; background:rgba(0,0,0,.15); white-space:nowrap; }
.titlebar .badge.online { color:#fff; background:#107c41; }
.titlebar .badge.fallback { color:#fff; background:#986f0b; }
.title-action { padding:7px 9px; border-radius:2px; color:#fff; background:transparent; font-weight:400; }
.title-action:hover { background:rgba(255,255,255,.12); }

.app-rail { grid-area:rail; display:flex; flex-direction:column; align-items:center; gap:4px; padding:8px 0; border-right:1px solid var(--mail-line); background:#f3f2f1; }
.rail-icon { width:40px; height:40px; display:grid; place-items:center; color:#605e5c; border-left:3px solid transparent; font-size:19px; }
.rail-icon.selected { color:var(--mail-blue); background:#fff; border-left-color:var(--mail-blue); }
.rail-spacer { flex:1; }

.folder-pane { grid-area:folders; padding:12px 8px; border-right:1px solid var(--mail-line); background:#faf9f8; }
.new-mail { width:100%; padding:9px 12px; text-align:left; border-radius:2px; background:var(--mail-blue); font-weight:600; }
.new-mail:hover,.send-button:hover { background:var(--mail-blue-dark); }
.folder-title { margin:22px 12px 8px; font-size:14px; font-weight:600; }
.folder { min-height:34px; display:flex; align-items:center; justify-content:space-between; padding:7px 12px; color:#323130; font-size:14px; }
.folder.active { background:#e5f1fb; color:#0f548c; font-weight:600; }

.mail-list { grid-area:list; overflow:auto; border-right:1px solid var(--mail-line); background:#fff; }
.list-heading { height:48px; display:flex; align-items:center; justify-content:space-between; padding:0 16px; border-bottom:1px solid var(--mail-line); }
.list-heading span { color:#605e5c; font-size:12px; }
.mail-item { display:flex; gap:10px; padding:13px 12px; border-bottom:1px solid #edebe9; }
.selected-mail { border-left:3px solid var(--mail-blue); background:#eaf3fb; }
.avatar { flex:0 0 36px; width:36px; height:36px; display:grid; place-items:center; border-radius:50%; color:#fff; background:#8764b8; font-weight:600; }
.mail-summary { min-width:0; flex:1; }
.mail-summary>div { display:flex; justify-content:space-between; gap:8px; }
.mail-summary time { color:#605e5c; font-size:11px; }
.mail-summary p { overflow:hidden; margin:2px 0; color:#605e5c; font-size:12px; text-overflow:ellipsis; white-space:nowrap; }
.mail-summary .summary-subject { color:#323130; font-weight:600; }

.reading-pane { grid-area:reading; min-width:0; display:grid; grid-template-rows:auto minmax(130px,1fr) auto auto; background:#fff; }
.message-header { display:flex; justify-content:space-between; align-items:center; padding:17px 22px; border-bottom:1px solid var(--mail-line); }
.subject { margin:0 0 5px; color:#201f1e; font-size:20px; font-weight:600; }
.recipient-line { margin:0; color:#605e5c; font-size:12px; }
.header-actions { display:flex; gap:18px; color:var(--mail-blue); font-size:13px; }
.messages { padding:20px 24px; background:#fff; }
.empty { margin-top:60px; color:#605e5c; }
.message-row,.message-row.mine { display:block; margin:0; border-bottom:1px solid #edebe9; }
.message { max-width:none; padding:14px 0; }
.message-meta,.mine .message-meta { margin:0 0 9px; color:#605e5c; text-align:left; font-size:12px; }
.bubble,.mine .bubble { padding:0; color:#201f1e; border:0; border-radius:0; background:transparent; line-height:1.55; }
.mine .message-meta::before { content:"寄件備份 · "; color:var(--mail-blue); }

.composer { margin:0 20px 18px; display:grid; grid-template-columns:1fr; gap:0; padding:0; border:1px solid #c8c6c4; background:#fff; box-shadow:0 2px 7px rgba(0,0,0,.08); }
.compose-toolbar { display:flex; align-items:center; gap:18px; min-height:46px; padding:6px 10px; border-bottom:1px solid var(--mail-line); color:#605e5c; }
.send-button { border-radius:2px; padding:8px 18px; background:var(--mail-blue); }
.address-row { display:flex; align-items:center; gap:12px; min-height:38px; padding:0 14px; border-bottom:1px solid var(--mail-line); font-size:13px; }
.address-row>span { width:58px; color:#605e5c; }
.address-row input { flex:1; padding:7px 0; border:0; border-radius:0; box-shadow:none; }
.composer textarea { min-height:128px; padding:15px; border:0; border-radius:0; resize:vertical; box-shadow:none; }
.formatbar { display:flex; gap:18px; align-items:center; min-height:38px; padding:0 14px; border-top:1px solid var(--mail-line); color:#605e5c; font-size:12px; }
.footer-error { padding:0 22px 6px; }

@media(max-width:950px) {
  .mail-window { grid-template-columns:48px 200px minmax(420px,1fr); grid-template-areas:"top top top top" "rail folders reading reading"; }
  .mail-list { display:none; }
  .brand { min-width:90px; }
}
@media(max-width:650px) {
  .mail-window { grid-template-columns:1fr; grid-template-rows:48px 1fr; grid-template-areas:"top" "reading"; }
  .app-rail,.folder-pane,.mail-list { display:none; }
  .brand { min-width:auto; }
  .waffle { display:none; }
  .searchbox { flex:1; width:auto; }
  .titlebar .badge { display:none; }
  .message-header { padding:14px 16px; }
  .messages { padding:15px 17px; }
  .composer { margin:0; border-width:1px 0 0; box-shadow:none; }
  .composer textarea { min-height:150px; }
  .formatbar { padding-bottom:env(safe-area-inset-bottom); }
}

/* Teams-like conversation pane */
.reading-pane { grid-template-rows:auto minmax(180px,1fr) auto auto; background:#fff; }
.teams-header { min-height:66px; display:flex; align-items:center; justify-content:space-between; padding:10px 18px; border-bottom:1px solid #e1dfdd; background:#fff; }
.teams-person { display:flex; align-items:center; gap:12px; }
.teams-person>strong { font-size:18px; color:#242424; }
.teams-avatar { position:relative; width:36px; height:36px; display:grid; place-items:center; border-radius:50%; color:#fff; background:linear-gradient(145deg,#d6aa82,#6b4d3d); font-weight:600; }
.teams-avatar>span { position:absolute; right:-2px; bottom:0; width:11px; height:11px; border:2px solid #fff; border-radius:50%; background:#c4314b; }
.teams-actions { display:flex; align-items:center; gap:15px; color:#424242; font-size:20px; }
.teams-actions i { width:1px; height:28px; background:#e1dfdd; }
.teams-actions span:last-child { font-size:16px; letter-spacing:1px; }

.reading-pane .messages { padding:14px 18px 20px; background:#fff; }
.reading-pane .empty { margin-top:90px; color:#616161; font-size:13px; }
.reading-pane .message-row,.reading-pane .message-row.mine { display:flex; margin:10px 0; border:0; }
.reading-pane .message-row.mine { justify-content:flex-end; }
.reading-pane .message { max-width:min(76%,520px); padding:0; }
.reading-pane .message-meta,.reading-pane .mine .message-meta { margin:0 5px 4px; color:#616161; text-align:left; font-size:11px; }
.reading-pane .mine .message-meta { text-align:right; }
.reading-pane .mine .message-meta::before { content:none; }
.reading-pane .bubble { padding:10px 14px; color:#242424; border:0; border-radius:0 0 7px 7px; background:#f5f5f5; line-height:1.5; }
.reading-pane .mine .bubble { padding:10px 14px; color:#242424; border:0; border-radius:7px 0 7px 7px; background:#e8ebfa; }

.reading-pane .composer { margin:0 18px 18px; display:block; border:1px solid #d1d1d1; border-bottom:2px solid #5b5fc7; border-radius:6px 6px 2px 2px; box-shadow:none; overflow:hidden; }
.reading-pane .composer textarea { min-height:72px; max-height:170px; padding:14px; border:0; border-radius:0; resize:vertical; font-family:"Segoe UI","Microsoft JhengHei",system-ui,sans-serif; font-size:14px; }
.teams-compose-tools { min-height:44px; display:flex; align-items:center; justify-content:space-between; padding:5px 10px 7px; color:#424242; }
.teams-compose-tools>div { display:flex; align-items:center; gap:20px; font-size:18px; }
.teams-compose-tools>div span:first-child { font-size:15px; }
.teams-send { padding:5px 8px; color:#424242; background:transparent; font-size:25px; font-weight:400; transform:rotate(-12deg); }
.teams-send:hover { color:#5b5fc7; background:#f0f0f0; }

@media(max-width:650px) {
  .teams-header { padding:8px 14px; }
  .reading-pane .messages { padding:12px 14px; }
  .reading-pane .message { max-width:86%; }
  .reading-pane .composer { margin:0 8px calc(8px + env(safe-area-inset-bottom)); border-width:1px 1px 2px; }
  .teams-compose-tools>div { gap:14px; }
}

/* Compact desktop chat window matching the supplied reference */
body { background:#f3f3f3; }
.shell { display:grid; place-items:center; padding:0; }
.mail-window {
  width:515px; height:510px; max-width:100vw; max-height:100dvh;
  display:grid; grid-template-columns:1fr; grid-template-rows:37px 1fr;
  grid-template-areas:"top" "reading";
  border:1px solid #7a7a7a; border-radius:7px; overflow:hidden;
  background:#fff; box-shadow:0 2px 8px rgba(0,0,0,.18); overscroll-behavior:none;
}
.mail-window.hidden { display:none; }
.mail-window .app-rail,.mail-window .folder-pane,.mail-window .mail-list { display:none; }
.titlebar {
  grid-area:top; height:37px; display:flex; align-items:center; gap:0; padding:0;
  color:#242424; background:#f0eff5; border-bottom:1px solid #d3d3d3;
  position:relative;
}
.window-contact { flex:1; padding-left:10px; font-size:13px; }
.titlebar .badge { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); }
.window-menu { width:54px; height:36px; padding:0; border-radius:0; color:#616161; background:transparent; letter-spacing:2px; }
.window-menu:hover { background:#e5e4e9; }
.window-controls { height:36px; display:flex; align-items:stretch; }
.window-controls span { width:50px; display:grid; place-items:center; color:#616161; font-size:16px; }
.window-controls span:last-child { font-size:22px; }

.reading-pane { grid-area:reading; min-width:0; min-height:0; display:grid; grid-template-rows:66px minmax(0,1fr) auto auto; overflow:hidden; background:#fff; }
.teams-header { min-height:66px; height:66px; padding:10px 18px 8px 29px; border-bottom:1px solid #e1dfdd; }
.teams-person { gap:13px; }
.teams-person>strong { font-size:20px; font-weight:650; }
.teams-avatar { width:34px; height:34px; font-size:14px; }
.teams-actions { gap:15px; font-size:19px; }

.reading-pane .messages { min-height:0; padding:0 18px 10px; overflow-y:auto; background:#fff; }
.day-divider { margin:156px 0 16px; color:#616161; text-align:center; font-size:12px; }
.reading-pane .empty { margin-top:145px; }
.reading-pane .message-row,.reading-pane .message-row.mine { margin:7px 0; }
.reading-pane .message { max-width:424px; }
.reading-pane .message-meta,.reading-pane .mine .message-meta { margin:0 4px 3px; }
.reading-pane .bubble { min-width:56px; padding:9px 17px; border-radius:0 0 7px 7px; background:#f5f5f5; }
.reading-pane .mine .bubble { min-width:48px; padding:9px 13px; border-radius:7px 0 7px 7px; background:#e8ebfa; text-align:center; }
.reading-pane .mine .message {
  position:relative;
  padding-right:20px;
}
.read-receipt {
  position:absolute;
  right:1px;
  bottom:2px;
  width:16px;
  height:16px;
  display:grid;
  place-items:center;
  background:#fff;
  border-radius:50%;
  box-shadow:none;
  pointer-events:none;
}
.read-receipt>span {
  position:relative;
  width:13px;
  height:13px;
  display:block;
  border:1.6px solid #5b5fc7;
  border-radius:50%;
  background:#fff;
}
.read-receipt>span::after {
  content:"";
  position:absolute;
  left:3px;
  top:3.6px;
  width:5.5px;
  height:3px;
  border-left:1.5px solid #5b5fc7;
  border-bottom:1.5px solid #5b5fc7;
  transform:rotate(-45deg);
}

.reading-pane .composer {
  height:98px; margin:0 17px 26px; display:grid; grid-template-rows:1fr 42px;
  border:1px solid #d1d1d1; border-bottom:2px solid #5b5fc7; border-radius:6px 6px 2px 2px;
  position:relative; z-index:3; overflow:hidden; background:#fff;
}
.reading-pane .composer textarea { min-height:0; height:54px; padding:13px 14px 4px; resize:none; font-size:14px; }
.teams-compose-tools { min-height:42px; height:42px; padding:2px 10px 5px; }
.teams-compose-tools>div { gap:19px; }
.teams-send { font-size:26px; }
.footer-error { position:absolute; bottom:3px; left:18px; padding:0; }

@media(max-width:530px), (max-height:520px) {
  .mail-window { width:100vw; height:100dvh; border:0; border-radius:0; }
  .window-controls span { width:42px; }
  .reading-pane .composer { margin:0 17px calc(16px + env(safe-area-inset-bottom)); }
  .day-divider { margin-top:80px; }
}

/* Freely resizable window with fluid contents */
.mail-window {
  width:min(92vw,1000px);
  height:min(90dvh,820px);
  min-width:360px;
  min-height:420px;
  max-width:calc(100vw - 16px);
  max-height:calc(100dvh - 16px);
  resize:both;
  container-type:size;
  grid-template-rows:clamp(34px,7cqh,46px) minmax(0,1fr);
}
.titlebar { height:100%; }
.window-contact { font-size:clamp(12px,1.5cqw,15px); }
.window-menu,.window-controls { height:100%; }
.window-controls span { width:clamp(40px,8cqw,52px); }
.reading-pane {
  grid-template-rows:clamp(58px,13cqh,92px) minmax(0,1fr) auto auto;
}
.teams-header { min-height:0; height:100%; padding-inline:clamp(16px,4cqw,34px); }
.teams-avatar { width:clamp(32px,6cqw,46px); height:clamp(32px,6cqw,46px); }
.teams-person>strong { font-size:clamp(18px,2.4cqw,24px); }
.teams-actions { font-size:clamp(17px,2.2cqw,22px); }
.reading-pane .messages { padding:clamp(10px,2.5cqw,28px); }
.day-divider { margin-top:clamp(50px,20cqh,156px); }
.reading-pane .message { max-width:min(78%,680px); }
.reading-pane .bubble,.reading-pane .mine .bubble {
  padding:clamp(8px,1.6cqw,14px) clamp(12px,2.4cqw,20px);
  font-size:clamp(14px,1.6cqw,18px);
}
.reading-pane .message-meta,.reading-pane .mine .message-meta {
  font-size:clamp(10px,1.2cqw,13px);
}
.reading-pane .composer {
  height:clamp(96px,22cqh,180px);
  margin:0 clamp(10px,3cqw,28px) clamp(10px,4cqh,28px);
  grid-template-rows:minmax(0,1fr) clamp(38px,7cqh,48px);
}
.reading-pane .composer textarea {
  width:100%; height:100%; min-height:0; padding:clamp(10px,2cqw,18px);
  font-size:clamp(14px,1.6cqw,18px);
}
.teams-compose-tools { min-height:0; height:100%; }
.teams-compose-tools>div { gap:clamp(12px,3cqw,24px); font-size:clamp(16px,2.2cqw,21px); }

@media(max-width:530px), (max-height:440px) {
  .mail-window {
    width:100vw; height:100dvh; min-width:0; min-height:0;
    max-width:none; max-height:none; resize:none; border:0; border-radius:0;
  }
}

/* The browser window is the chat window: always fill the viewport. */
html,body,.shell { width:100%; height:100%; overflow:hidden; }
.mail-window {
  width:100vw;
  height:100dvh;
  min-width:0;
  min-height:0;
  max-width:none;
  max-height:none;
  resize:none;
  border:0;
  border-radius:0;
  box-shadow:none;
}

/* Composer matched to the supplied Teams reference. */
.reading-pane .composer {
  height:clamp(98px,16cqh,128px);
  grid-template-rows:auto minmax(0,1fr) 42px;
  border:1px solid #d1d1d1;
  border-radius:6px;
  box-shadow:none;
}
.reply-preview {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  min-height:42px;
  margin:7px 9px 0;
  padding:7px 8px 7px 11px;
  border-left:3px solid #5b5fc7;
  border-radius:4px;
  color:#424242;
  background:#f7f7fb;
}
.reply-preview.hidden { display:none; }
.reply-preview strong {
  display:block;
  margin-bottom:1px;
  color:#242424;
  font-size:12px;
  font-weight:600;
}
.reply-preview p {
  overflow:hidden;
  max-width:min(64vw,620px);
  margin:0;
  color:#616161;
  font-size:12px;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#cancelReplyButton {
  flex:0 0 auto;
  width:26px;
  height:26px;
  display:grid;
  place-items:center;
  padding:0;
  border-radius:3px;
  color:#616161;
  background:transparent;
  font-size:18px;
  font-weight:400;
}
#cancelReplyButton:hover { color:#242424; background:#edebe9; }
.reading-pane .composer textarea {
  padding:13px 14px 4px;
  color:#242424;
  font-size:15px;
}
.reading-pane .composer textarea::placeholder { color:#616161; opacity:1; }
.teams-compose-tools {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  height:42px;
  padding:0 7px 7px;
}
.teams-tool-group { display:flex; align-items:center; justify-content:flex-end; gap:0; }
.compose-icon,.teams-send {
  width:36px;
  height:34px;
  display:grid;
  place-items:center;
  padding:5px;
  border:0;
  border-radius:3px;
  color:#424242;
  background:transparent;
  transform:none;
}
.compose-icon:hover,.teams-send:hover { color:#242424; background:#f3f2f1; }
.compose-icon svg,.teams-send svg {
  width:22px;
  height:22px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.5;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.compose-icon .icon-fill { fill:currentColor; stroke:none; }
.compose-separator { width:1px; height:26px; margin:0 5px; background:#d1d1d1; }
.teams-send { width:38px; }
.teams-send svg { width:24px; height:24px; }
.file-input {
  position:absolute;
  width:1px;
  height:1px;
  opacity:0;
  pointer-events:none;
}
.upload-toast {
  position:fixed;
  left:12px;
  right:12px;
  bottom:calc(112px + env(safe-area-inset-bottom));
  z-index:900;
  margin:0;
  padding:9px 12px;
  border:1px solid #d1d1d1;
  border-radius:6px;
  color:#242424;
  background:#fff;
  box-shadow:0 8px 24px rgba(0,0,0,.18);
  font-size:13px;
  text-align:center;
}

/* Header actions matched to the supplied Teams reference. */
.teams-actions {
  height:100%;
  display:flex;
  align-items:center;
  gap:0;
  color:#424242;
  position:relative;
}
.header-icon {
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  padding:6px;
  border:0;
  border-radius:3px;
  color:#424242;
  background:transparent;
}
.header-icon:hover { color:#242424; background:#f3f2f1; }
.header-chevron { width:22px; padding:5px 3px; }
.header-icon svg {
  width:20px;
  height:20px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.45;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.header-chevron svg { width:16px; height:16px; }
.header-icon .header-icon-fill { fill:currentColor; stroke:none; }
.header-separator { width:1px; height:28px; margin:0 7px; background:#e1dfdd; }
.teams-avatar.has-avatar,
.avatar.has-avatar {
  overflow:hidden;
  background:#d1d1d1;
}
.teams-avatar img,
.avatar img {
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}
.teams-avatar.has-avatar b,
.avatar.has-avatar b {
  display:none;
}
.teams-avatar.has-avatar>span {
  z-index:1;
}
.avatar-menu {
  position:absolute;
  top:calc(100% + 4px);
  right:0;
  z-index:20;
  min-width:142px;
  padding:4px;
  border:1px solid #d1d1d1;
  border-radius:4px;
  background:#fff;
  box-shadow:0 8px 22px rgba(0,0,0,.18);
}
.avatar-menu button {
  width:100%;
  padding:9px 10px;
  border-radius:3px;
  color:#242424;
  background:transparent;
  text-align:left;
  font-size:13px;
  font-weight:400;
}
.avatar-menu button:hover {
  background:#f3f2f1;
}
.title-avatar-menu {
  top:32px;
  right:104px;
}

@media(max-width:430px) {
  .teams-header { padding-inline:12px; }
  .teams-person { gap:8px; }
  .header-icon { width:30px; }
  .header-chevron { width:18px; }
  .header-separator { margin-inline:3px; }
}

/* Screenshot crop overlay */
.screenshot-overlay {
  position:fixed;
  inset:0;
  z-index:1000;
  display:grid;
  place-items:center;
  overflow:hidden;
  color:#fff;
  background:rgba(15,15,18,.96);
  user-select:none;
}
.screenshot-overlay.hidden { display:none; }
.screenshot-instructions {
  position:fixed;
  top:14px;
  left:50%;
  z-index:2;
  display:flex;
  align-items:center;
  gap:18px;
  padding:9px 14px;
  border:1px solid rgba(255,255,255,.22);
  border-radius:6px;
  background:rgba(0,0,0,.72);
  transform:translateX(-50%);
  white-space:nowrap;
  font-size:13px;
}
.screenshot-instructions span { color:#d6d6d6; }
#screenshotCanvas {
  display:block;
  max-width:100vw;
  max-height:100dvh;
  cursor:crosshair;
  touch-action:none;
}
.screenshot-status {
  position:fixed;
  bottom:16px;
  left:50%;
  z-index:2;
  min-height:20px;
  margin:0;
  padding:7px 12px;
  border-radius:4px;
  color:#fff;
  background:rgba(0,0,0,.72);
  transform:translateX(-50%);
  font-size:13px;
}
.screenshot-status:empty { display:none; }

/* Screenshot messages */
.reading-pane .image-bubble,.reading-pane .mine .image-bubble {
  padding:3px;
  overflow:hidden;
  background:#f5f5f5;
}
.message-image {
  display:block;
  width:auto;
  max-width:min(62vw,560px);
  max-height:min(48dvh,420px);
  border-radius:5px;
  object-fit:contain;
  cursor:zoom-in;
}
.message-image:focus {
  outline:2px solid #5b5fc7;
  outline-offset:2px;
}
.reply-quote {
  width:100%;
  display:block;
  margin:0 0 7px;
  padding:6px 8px;
  border-left:3px solid #5b5fc7;
  border-radius:4px;
  color:#424242;
  background:rgba(255,255,255,.72);
  text-align:left;
  font-weight:400;
}
.mine .reply-quote { background:rgba(255,255,255,.58); }
.reply-quote strong {
  display:block;
  margin-bottom:1px;
  color:#242424;
  font-size:11px;
  font-weight:600;
}
.reply-quote span {
  display:block;
  overflow:hidden;
  color:#616161;
  font-size:12px;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.expired-image {
  display:block;
  padding:18px 22px;
  color:#616161;
  font-size:13px;
  text-align:center;
}

/* Full-screen image preview */
.image-preview-overlay {
  position:fixed;
  inset:0;
  z-index:1100;
  display:grid;
  place-items:center;
  padding:54px 18px 24px;
  background:rgba(0,0,0,.92);
}
.image-preview-overlay.hidden { display:none; }
.image-preview-overlay img {
  display:block;
  max-width:100%;
  max-height:100%;
  border-radius:4px;
  object-fit:contain;
  box-shadow:0 18px 60px rgba(0,0,0,.45);
}
.image-preview-close {
  position:fixed;
  top:12px;
  right:14px;
  width:40px;
  height:40px;
  display:grid;
  place-items:center;
  padding:0;
  border-radius:50%;
  color:#fff;
  background:rgba(255,255,255,.14);
  font-size:30px;
  font-weight:300;
  line-height:1;
}
.image-preview-close:hover,
.image-preview-close:focus {
  background:rgba(255,255,255,.24);
  outline:none;
}
.image-preview-error {
  position:fixed;
  left:50%;
  bottom:18px;
  min-height:20px;
  margin:0;
  padding:7px 12px;
  border-radius:4px;
  color:#fff;
  background:rgba(0,0,0,.72);
  transform:translateX(-50%);
  font-size:13px;
}
.image-preview-error:empty { display:none; }
@media(max-width:530px) {
  .message-image { max-width:78vw; max-height:42dvh; }
  .screenshot-instructions { top:8px; gap:8px; font-size:11px; }
  .image-preview-overlay { padding:48px 10px 20px; }
  .image-preview-close { top:8px; right:8px; }
}

/* Mobile: lock the app to the visible screen so it behaves like a fixed full-screen chat. */
@media(max-width:650px), (pointer:coarse) {
  html,
  body,
  .shell {
    width:100%;
    height:var(--app-height, 100dvh);
    min-height:var(--app-height, 100dvh);
    max-height:var(--app-height, 100dvh);
    overflow:hidden;
    overscroll-behavior:none;
  }
  html {
    position:fixed;
    inset:0;
    touch-action:manipulation;
    -webkit-text-size-adjust:100%;
    text-size-adjust:100%;
  }
  body {
    position:fixed;
    inset:0;
  }
  .mail-window {
    position:fixed;
    top:var(--app-top, 0);
    right:0;
    bottom:auto;
    left:0;
    width:100vw;
    height:var(--app-height, 100dvh);
    min-height:var(--app-height, 100dvh);
    max-height:var(--app-height, 100dvh);
    grid-template-rows:37px minmax(0,1fr);
    overflow:hidden;
    transform:none;
  }
  .reading-pane {
    min-height:0;
    grid-template-rows:58px minmax(0,1fr) auto auto;
    overflow:hidden;
  }
  .teams-header {
    height:58px;
    min-height:58px;
    padding:8px 10px 8px 12px;
  }
  .teams-person>strong {
    max-width:38vw;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .reading-pane .messages {
    min-height:0;
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-y;
  }
  .reading-pane .composer {
    height:auto;
    min-height:104px;
    max-height:42vh;
    margin:0 8px calc(8px + env(safe-area-inset-bottom));
    flex:0 0 auto;
  }
  .reading-pane .composer textarea {
    min-height:58px;
    height:58px;
    font-size:16px;
    line-height:1.35;
  }
  .reply-preview {
    min-height:38px;
    margin:6px 7px 0;
    padding-block:6px;
  }
  .reply-preview p {
    max-width:68vw;
  }
  .teams-compose-tools {
    height:40px;
    padding-bottom:5px;
  }
  .compose-icon,
  .teams-send {
    width:34px;
    height:32px;
  }
  input,
  textarea,
  button {
    font-size:16px;
  }
  html.keyboard-open .mail-window {
    grid-template-rows:0 minmax(0,1fr);
  }
  html.keyboard-open .titlebar {
    display:none;
  }
  html.keyboard-open .reading-pane {
    grid-template-rows:44px minmax(72px,1fr) auto auto;
  }
  html.keyboard-open .teams-header {
    height:44px;
    min-height:44px;
    padding:5px 10px 5px 12px;
  }
  html.keyboard-open .teams-avatar {
    width:28px;
    height:28px;
    font-size:12px;
  }
  html.keyboard-open .teams-person>strong {
    font-size:16px;
    max-width:58vw;
  }
  html.keyboard-open .teams-actions {
    display:none;
  }
  html.keyboard-open .day-divider {
    margin-top:16px;
  }
  html.keyboard-open .reading-pane .messages {
    padding-top:8px;
    padding-bottom:8px;
  }
  html.keyboard-open .reading-pane .composer {
    min-height:90px;
    max-height:34vh;
    margin:0 8px calc(4px + env(safe-area-inset-bottom));
  }
  html.keyboard-open .reading-pane .composer textarea {
    min-height:50px;
    height:50px;
    padding-top:10px;
  }
  html.keyboard-open .teams-compose-tools {
    height:36px;
  }
}
