.hidden { display: none !important; }

:root {
  --office-topbar-height: calc(112px + env(safe-area-inset-top));
  --keyboard-inset: 0px;
  --visible-height: var(--app-height);
}

.status-brand {
  top: calc(env(safe-area-inset-top) + 4px);
  height: 24px;
  padding: 0 7px;
  gap: 6px;
  color: rgba(239, 246, 255, .92);
  font-size: 10px;
  font-weight: 780;
}
.status-brand img { width: 17px; height: 17px; border-radius: 5px; }
.topbar {
  height: var(--office-topbar-height);
  padding: calc(env(safe-area-inset-top) + 36px) 18px 12px;
}
.content { height: calc(var(--app-height) - var(--office-topbar-height) - 96px); }

.app[data-loading="true"] .content,
.app[data-loading="true"] .topbar,
.app[data-loading="true"] .bottom-nav { visibility: hidden; }

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #09111f;
  transition: opacity .45s ease, visibility .45s ease;
}

.boot-screen.done { opacity: 0; visibility: hidden; }

.boot-lockup { display: grid; justify-items: center; gap: 16px; text-align: center; }
.boot-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(85, 242, 211, .24);
  border-radius: 8px;
  background: #101d2d;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .32);
  animation: boot-breathe 1.8s ease-in-out infinite;
}
.boot-mark svg { width: 60px; height: 60px; }
.boot-wordmark { margin: 0; color: #f5f8ff; font-size: 22px; font-weight: 790; }
.boot-copy { margin: -8px 0 0; color: #8998ae; font-size: 11px; }
.boot-line { width: 116px; height: 2px; overflow: hidden; background: rgba(255,255,255,.08); }
.boot-line::after { content: ""; display: block; width: 42%; height: 100%; background: #55f2d3; animation: boot-line 1.25s ease-in-out infinite; }
.boot-retry {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(85, 242, 211, .34);
  border-radius: 7px;
  color: #dffcf5;
  background: rgba(85, 242, 211, .08);
  font: 760 10px/1 inherit;
  cursor: pointer;
}
.boot-retry:active { transform: translateY(1px); }

@keyframes boot-breathe { 50% { transform: translateY(-3px); border-color: rgba(129,120,255,.45); } }
@keyframes boot-line { from { transform: translateX(-120%); } to { transform: translateX(340%); } }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 980;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #09111f;
}
.auth-panel { width: min(100%, 390px); }
.auth-kicker { margin: 0 0 10px; color: #55f2d3; font-size: 10px; font-weight: 830; text-transform: uppercase; letter-spacing: 1px; }
.auth-panel h1 { margin: 0 0 9px; color: white; font-size: 31px; line-height: 1.03; }
.auth-panel > p { margin: 0 0 26px; color: #9aa8bf; font-size: 13px; line-height: 1.5; }

.office-form { display: grid; gap: 13px; }
.field { display: grid; gap: 7px; }
.field > span { color: #aeb9cc; font-size: 10px; font-weight: 720; }
.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid rgba(176, 200, 239, .18);
  border-radius: 7px;
  outline: none;
  color: #f5f8ff;
  background: #151f32;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: rgba(85,242,211,.6); box-shadow: 0 0 0 3px rgba(85,242,211,.08); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row > * { min-width: 0; }

.event-time-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(176, 200, 239, .16);
  border-radius: 8px;
  background: rgba(255,255,255,.025);
}
.event-time-card > strong {
  display: block;
  margin-bottom: 9px;
  color: #f1f5fc;
  font-size: 11px;
}
.event-time-fields { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px; }
.event-time-fields .field { min-width: 0; }
.event-time-fields .field > span { font-size: 9px; }
.event-time-fields input { min-width: 0; height: 46px; padding: 8px 10px; color-scheme: dark; }

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  padding: 0 15px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
}
.primary-button { color: #071721; background: #55f2d3; }
.secondary-button { color: #eaf0fa; border-color: rgba(176,200,239,.18); background: rgba(255,255,255,.04); }
.danger-button { color: #ff9aaa; border-color: rgba(255,125,142,.24); background: rgba(255,125,142,.08); }
.primary-button:disabled,
.secondary-button:disabled { cursor: wait; opacity: .55; }

.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
}
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, 254px);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255,255,255,.025);
}
.segment {
  min-height: 31px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 740;
}
.segment.active { color: white; background: rgba(110,182,255,.16); }
.calendar-nav { display: flex; align-items: center; gap: 5px; }
.calendar-nav button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted-strong);
  background: rgba(255,255,255,.035);
  cursor: pointer;
}
.calendar-nav svg { width: 15px; height: 15px; }
.calendar-period { margin: 0 0 14px; font-size: 17px; font-weight: 780; }
.home-week-scope { color: var(--muted); font-size: 8px; font-weight: 720; text-transform: uppercase; }
.home-day { cursor: pointer; }
.home-day.today:not(.selected) { border-color: rgba(85,242,211,.28); }
.home-day.has-event::after { width: 5px; height: 5px; bottom: 3px; box-shadow: 0 0 8px rgba(110,182,255,.52); }
.home-day.selected.has-event::after { box-shadow: none; }

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.month-weekday { min-height: 29px; display: grid; place-items: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 8px; font-weight: 770; text-transform: uppercase; }
.month-day {
  min-height: 62px;
  padding: 7px 5px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted-strong);
  background: rgba(16,25,43,.42);
  text-align: left;
  cursor: pointer;
}
.month-day.outside { color: #58667c; background: rgba(8,15,27,.38); }
.month-day.selected { color: white; background: rgba(85,242,211,.09); box-shadow: inset 0 0 0 1px rgba(85,242,211,.32); }
.month-day.today .month-number { color: #071721; background: var(--mint); }
.month-number { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; font-size: 10px; font-weight: 780; }
.month-dots { display: flex; gap: 2px; margin: 6px 0 0 2px; }
.month-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }
.month-dots i:nth-child(2) { background: var(--amber); }
.month-dots i:nth-child(3) { background: var(--mint); }

.week-surface { touch-action: pan-y; }
.week-strip.dynamic { margin-bottom: 16px; }
.week-strip.dynamic .day { min-width: 0; }
.week-strip.dynamic .day span:nth-child(2) { font-size: 15px; font-weight: 780; }
.week-strip.dynamic .day i {
  width: 4px;
  height: 4px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 8px rgba(110,182,255,.44);
}
.week-strip.dynamic .day.active i { background: #10202a; box-shadow: none; }
.week-strip.dynamic.swipe-left { animation: week-left .22s ease; }
.week-strip.dynamic.swipe-right { animation: week-right .22s ease; }
@keyframes week-left { from { opacity: .45; transform: translateX(16px); } }
@keyframes week-right { from { opacity: .45; transform: translateX(-16px); } }

.agenda-date { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 11px; }
.agenda-date h3 { margin: 0; font-size: 14px; }
.agenda-list { display: grid; gap: 8px; }
.agenda-event {
  display: grid;
  grid-template-columns: 54px 3px minmax(0, 1fr);
  gap: 11px;
  min-height: 64px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(24,34,55,.66);
}
.agenda-event-time { color: var(--muted-strong); font-size: 9px; font-weight: 740; }
.agenda-event-mark { border-radius: 2px; background: var(--blue); }
.agenda-event:nth-child(3n+2) .agenda-event-mark { background: var(--amber); }
.agenda-event:nth-child(3n+3) .agenda-event-mark { background: var(--mint); }
.agenda-event h4 { margin: 0 0 4px; font-size: 12px; }
.agenda-event p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.35; }

.empty-state {
  min-height: 170px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}
.empty-state strong { color: var(--text); font-size: 13px; }
.empty-state p { max-width: 270px; margin: 0; font-size: 10px; line-height: 1.5; }
.empty-state .primary-button { margin-top: 7px; }

.page-heading h2 { display: none; }
.page-heading { margin-bottom: 14px !important; }

.integration-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  margin: 0 0 13px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.018);
}
.integration-strip-main { min-width: 0; display: flex; align-items: center; gap: 10px; }
.integration-strip-icon { width: 34px; height: 34px; flex: 0 0 auto; object-fit: contain; }
.integration-copy { min-width: 0; }
.integration-copy strong { display: block; overflow: hidden; color: white; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.integration-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.integration-action { min-height: 32px; flex: 0 0 auto; padding: 0 11px; border: 1px solid rgba(85,242,211,.24); border-radius: 6px; color: var(--mint); background: rgba(85,242,211,.07); cursor: pointer; font-size: 9px; font-weight: 760; }
.integration-action.connected { color: #071721; background: var(--mint); }
.push-strip { border-color: rgba(85,242,211,.16); background: rgba(85,242,211,.035); }
.push-strip .integration-copy strong { color: var(--mint); }

.mail-actions { display: flex; gap: 7px; margin: 0 0 13px; overflow-x: auto; scrollbar-width: none; }
.mail-actions::-webkit-scrollbar { display: none; }
.mail-action { min-height: 35px; flex: 0 0 auto; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted-strong); background: rgba(255,255,255,.03); cursor: pointer; font-size: 9px; font-weight: 720; }
.mail-action.primary { border-color: rgba(85,242,211,.2); color: var(--mint); }
.mail-row-priority { margin-left: 6px; color: #f4cb73; font-size: 7px; font-weight: 800; text-transform: uppercase; }

.digest { border-left: 0; border: 1px solid rgba(129,120,255,.2); border-radius: 8px; background: rgba(18,29,51,.72); }
.digest-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.digest-head > span:first-child { min-width: 0; display: grid; gap: 3px; }
.digest-head strong { color: #f2f5fb; font-size: 13px; }
.digest-label { margin: 0; }
.digest-count { min-width: 28px; height: 28px; padding: 0 7px; border-radius: 6px; display: grid; place-items: center; color: #d9d6ff; background: rgba(129,120,255,.12); font-size: 10px; font-weight: 800; }
.digest-overview { margin: 10px 0 0 !important; color: #b7c2d3 !important; font-size: 10px !important; line-height: 1.5 !important; }
.digest-items { margin-top: 12px; display: grid; gap: 7px; }
.digest-item { width: 100%; padding: 11px 12px; border: 1px solid rgba(176,200,239,.14); border-radius: 7px; display: grid; gap: 4px; color: #eef4fd; background: rgba(255,255,255,.025); text-align: left; cursor: pointer; }
.digest-item.urgent { border-color: rgba(255,125,142,.3); background: rgba(255,125,142,.055); }
.digest-item.reply { border-color: rgba(110,182,255,.25); }
.digest-item.task { border-color: rgba(244,203,115,.25); }
.digest-item-top { display: flex; justify-content: space-between; gap: 10px; }
.digest-kind { color: #a9b6ca; font-size: 8px; font-weight: 820; text-transform: uppercase; }
.digest-item.urgent .digest-kind { color: #ff9dab; }
.digest-item.reply .digest-kind { color: #8dcbff; }
.digest-item.task .digest-kind { color: #f4cb73; }
.digest-open { color: var(--mint); font-size: 8px; font-weight: 760; }
.digest-item > strong { margin-top: 1px; overflow-wrap: anywhere; font-size: 11px; line-height: 1.35; }
.digest-sender { color: #8795ac; font-size: 9px; }
.digest-detail { margin-top: 3px; color: #c0cad8; font-size: 10px; line-height: 1.45; }
.digest-action { margin-top: 4px; padding-top: 7px; border-top: 1px solid rgba(176,200,239,.1); color: #dfe8f4; font-size: 9px; font-weight: 700; }

.modal-layer { position: fixed; inset: 0; z-index: 900; display: grid; align-items: end; visibility: hidden; }
html.keyboard-open .modal-layer { bottom: var(--keyboard-inset); }
.modal-layer.open { visibility: visible; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,8,15,.72); opacity: 0; transition: opacity .25s ease; }
.modal-layer.open .modal-backdrop { opacity: 1; }
.modal-panel {
  position: relative;
  width: min(100%, 520px);
  max-height: min(86vh, 760px);
  margin: 0 auto;
  overflow: auto;
  padding: 11px 20px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #101a2b;
  box-shadow: 0 -20px 60px rgba(0,0,0,.35);
  transform: translateY(100%);
  transition: transform .34s cubic-bezier(.22,.75,.25,1);
}
.modal-layer.open .modal-panel { transform: translateY(0); }
.modal-handle { width: 42px; height: 4px; margin: 0 auto 17px; border-radius: 2px; background: rgba(255,255,255,.18); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { margin: 0 0 5px; font-size: 18px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.modal-close { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.03); cursor: pointer; }
.modal-close svg { width: 16px; height: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions > * { flex: 1; }

.chat-pin-toggle {
  min-height: 54px;
  padding: 0 13px;
  border: 1px solid rgba(176,200,239,.18);
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
}
.chat-pin-toggle > input { position: absolute; opacity: 0; pointer-events: none; }
.chat-pin-toggle strong { font-size: 11px; }
.toggle-track { width: 36px; height: 21px; padding: 2px; flex: 0 0 auto; border: 1px solid rgba(176,200,239,.2); border-radius: 11px; background: #111b2c; transition: background .2s ease, border-color .2s ease; }
.toggle-track span { width: 15px; height: 15px; display: block; border-radius: 50%; background: #8390a5; transition: transform .2s ease, background .2s ease; }
.chat-pin-toggle > input:checked + .toggle-track { border-color: rgba(85,242,211,.5); background: rgba(85,242,211,.16); }
.chat-pin-toggle > input:checked + .toggle-track span { transform: translateX(15px); background: #55f2d3; }
.chat-pin-toggle > input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px rgba(85,242,211,.1); }
.label-selector { display: flex; flex-wrap: wrap; gap: 7px; }
.label-option { cursor: pointer; }
.label-option input { position: absolute; opacity: 0; pointer-events: none; }
.label-option .chat-label { min-height: 27px; max-width: 150px; padding: 4px 9px; border: 1px solid transparent; opacity: .48; font-size: 9px; transition: opacity .18s ease, border-color .18s ease; }
.label-option input:checked + .chat-label { border-color: currentColor; opacity: 1; }
.label-option input:focus-visible + .chat-label { box-shadow: 0 0 0 3px rgba(85,242,211,.09); }

.integration-list { display: grid; gap: 1px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.integration-row { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 68px; border-bottom: 1px solid var(--line); }
.integration-row:last-child { border-bottom: 0; }
.integration-logo { width: 34px; height: 34px; display: grid; place-items: center; overflow: hidden; border-radius: 8px; color: #0c1421; background: rgba(255,255,255,.04); font-size: 11px; font-weight: 840; }
.integration-logo img { width: 100%; height: 100%; display: block; object-fit: contain; }
.integration-row strong { display: block; font-size: 11px; }
.integration-row p { margin: 3px 0 0; color: var(--muted); font-size: 9px; line-height: 1.35; }
.integration-status { color: var(--muted); font-size: 9px; }

.sheet-panel {
  width: min(100%, 600px);
  height: min(78vh, 680px);
  min-height: 0 !important;
  max-height: calc(var(--visible-height) - 8px) !important;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
}
html.keyboard-open .sheet-panel {
  bottom: var(--keyboard-inset);
  height: calc(var(--visible-height) - 8px);
  max-height: calc(var(--visible-height) - 8px) !important;
  padding-bottom: 10px;
  border-radius: 18px 18px 0 0;
  transition-duration: 180ms;
}
.conversation.live { min-height: 170px; max-height: none; flex: 1; align-content: start; overflow-y: auto; padding-right: 3px; }
.bubble { white-space: pre-wrap; }
.bubble.pending { border-color: rgba(244,203,115,.28); background: rgba(244,203,115,.07); }
.typing { display: inline-flex; gap: 4px; align-items: center; min-width: 46px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typing 1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .13s; }
.typing i:nth-child(3) { animation-delay: .26s; }
@keyframes typing { 50% { transform: translateY(-3px); opacity: .45; } }
.pending-card { margin: 12px 0; padding: 12px; border: 1px solid rgba(244,203,115,.25); border-radius: 7px; background: rgba(244,203,115,.06); }
.pending-card strong { display: block; margin-bottom: 6px; color: var(--amber); font-size: 10px; text-transform: uppercase; }
.pending-card p { margin: 4px 0; color: var(--muted-strong); font-size: 10px; line-height: 1.45; }
.pending-actions { display: flex; gap: 7px; margin-top: 11px; }
.pending-actions button { min-height: 34px; padding: 0 11px; border-radius: 6px; cursor: pointer; font-size: 9px; font-weight: 760; }
.pending-confirm { border: 0; color: #071721; background: var(--mint); }
.pending-cancel { border: 1px solid rgba(255,125,142,.22); color: #ff9aaa; background: transparent; }
.attachment-tray {
  margin-top: 9px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 1px 3px;
  scrollbar-width: none;
}
.attachment-tray::-webkit-scrollbar { display: none; }
.attachment-chip {
  min-width: 0;
  max-width: 210px;
  height: 34px;
  padding: 0 6px 0 10px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(110,182,255,.2);
  border-radius: 7px;
  color: #dbe8f8;
  background: rgba(110,182,255,.08);
  font-size: 9px;
}
.attachment-chip.uploading { color: var(--muted); }
.attachment-chip.failed { border-color: rgba(255,125,142,.3); color: #ffc3cd; background: rgba(255,125,142,.08); }
.attachment-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip-state { color: var(--muted); font-size: 8px; }
.attachment-remove {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 0;
  display: grid;
  place-items: center;
  color: currentColor;
  background: transparent;
  cursor: pointer;
}
.attachment-remove svg { width: 13px; height: 13px; }
.message-attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.message-attachment { padding: 4px 7px; border-radius: 5px; color: #cce4fa; background: rgba(110,182,255,.1); font-size: 8px; }

.composer.live { flex: 0 0 auto; grid-template-columns: auto minmax(0,1fr) 42px; align-items: end; gap: 7px; margin-top: 9px; padding-top: 10px; border-top: 1px solid rgba(176,200,239,.1); }
.composer-tools { display: flex; gap: 5px; align-items: flex-end; }
.composer.live .composer-button { width: 34px; height: 42px; border-radius: 17px; }
.composer.live .composer-input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 196px;
  height: 42px;
  padding: 10px 13px;
  resize: none;
  overflow-y: auto;
  line-height: 1.35;
  font-family: inherit;
  font-weight: 500;
  font-size: 16px;
  box-sizing: border-box;
  display: block;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.composer.live .send-button { flex: 0 0 auto; }
html.keyboard-open .composer.live .composer-input { max-height: 112px; }
.mic-button.recording { color: #071721; background: var(--coral); animation: record-pulse 1.1s ease-in-out infinite; }
@keyframes record-pulse { 50% { box-shadow: 0 0 0 7px rgba(255,125,142,.12); } }

.thread-panel .modal-panel { min-height: 68vh; }
.thread-panel .modal-panel { height: min(78vh, 720px); overflow: hidden; }
.thread-panel #modalContent { height: calc(100% - 21px); display: flex; flex-direction: column; min-height: 0; }
.thread-messages { flex: 1; display: grid; align-content: start; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 2px 14px; }
.thread-message { max-width: 82%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; display: grid; gap: 7px; color: var(--muted-strong); background: rgba(255,255,255,.035); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.thread-message.out { justify-self: end; border-color: rgba(85,242,211,.2); color: #dffaf4; background: rgba(85,242,211,.08); }
.thread-message-copy { white-space: pre-wrap; }
.thread-file-list { display: grid; gap: 5px; }
.thread-file {
  min-width: 170px;
  max-width: 260px;
  padding: 7px 8px;
  border: 1px solid rgba(110,182,255,.16);
  border-radius: 6px;
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  gap: 2px 7px;
  color: #dbe9f8;
  background: rgba(110,182,255,.07);
  text-decoration: none;
}
.thread-file-kind { grid-row: 1 / 3; align-self: center; color: #7fc5ff; font-size: 7px; font-weight: 820; }
.thread-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.thread-file-size { color: var(--muted); font-size: 7px; }
.thread-media {
  min-width: 190px;
  max-width: min(290px, 72vw);
  overflow: hidden;
  border: 1px solid rgba(110,182,255,.16);
  border-radius: 7px;
  display: grid;
  gap: 6px;
  color: #9fd3ff;
  background: rgba(7,15,28,.55);
  text-decoration: none;
}
.thread-media img,
.thread-media video { width: 100%; max-height: 260px; display: block; object-fit: contain; background: #07101d; }
.thread-media > span,
.thread-media > a { padding: 0 8px 7px; overflow: hidden; color: #b9dfff; text-overflow: ellipsis; white-space: nowrap; font-size: 8px; text-decoration: none; }
.thread-audio { padding: 8px; }
.thread-audio audio { width: 100%; height: 34px; }
.thread-audio > a { padding: 0; }
.thread-message-meta { min-height: 13px; display: flex; align-items: center; justify-content: flex-end; gap: 7px; color: #728197; font-size: 7px; line-height: 1; }
.thread-read-state { display: inline-flex; align-items: center; gap: 3px; color: #8f9eb2; }
.thread-read-state svg { width: 13px; height: 9px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.thread-read-state:not(.read) .second-check { display: none; }
.thread-read-state.read { color: var(--mint); }
.thread-attachment-tray {
  min-height: 0;
  margin: 4px 0 8px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}
.thread-attachment-tray::-webkit-scrollbar { display: none; }
.thread-attachment-card {
  width: 190px;
  min-height: 46px;
  padding: 5px 4px 5px 5px;
  flex: 0 0 auto;
  border: 1px solid rgba(110,182,255,.18);
  border-radius: 7px;
  display: grid;
  grid-template-columns: 36px minmax(0,1fr) 24px;
  align-items: center;
  gap: 7px;
  color: #dbe9f8;
  background: rgba(110,182,255,.06);
}
.thread-attachment-card.uploading { opacity: .7; }
.thread-attachment-card.failed { border-color: rgba(255,125,142,.34); color: #ffcbd3; background: rgba(255,125,142,.07); }
.thread-attachment-preview,
.thread-attachment-icon { width: 36px; height: 36px; border-radius: 5px; }
.thread-attachment-preview { display: block; object-fit: cover; background: #0c1524; }
.thread-attachment-icon { display: grid; place-items: center; color: #8bcaff; background: rgba(110,182,255,.11); font-size: 7px; font-weight: 850; }
.thread-attachment-copy { min-width: 0; display: grid; gap: 3px; }
.thread-attachment-copy > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.thread-attachment-copy small { color: var(--muted); font-size: 7px; }
.thread-composer { flex: 0 0 auto; }
.mail-panel .modal-panel { height: min(88vh, 800px); min-height: 0; overflow: hidden; }
.mail-panel #modalContent { height: calc(100% - 21px); min-height: 0; }
.mail-detail-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.mail-detail-shell .modal-head { flex: 0 0 auto; margin-bottom: 13px; }
.mail-detail-shell .modal-head h2 { overflow-wrap: anywhere; font-size: 17px; line-height: 1.22; }
.mail-detail-sender { flex: 0 0 auto; display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.mail-sender-avatar { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; color: #071721; background: linear-gradient(145deg,var(--mint),#8fcaff); font-size: 11px; font-weight: 850; }
.mail-detail-sender > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.mail-detail-sender strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.mail-detail-sender > span:nth-child(2) > span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.mail-priority { padding: 4px 7px; border-radius: 5px; color: #f4cb73; background: rgba(244,203,115,.1); font-size: 8px; font-weight: 780; }
.mail-detail-routing { flex: 0 0 auto; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.mail-detail-routing summary { cursor: pointer; list-style: none; }
.mail-detail-routing summary::-webkit-details-marker { display: none; }
.mail-detail-routing p { margin: 7px 0 0; overflow-wrap: anywhere; }
.mail-detail-body { flex: 1; min-height: 0; margin: 0 -4px; padding: 15px 4px 20px; overflow-y: auto; overscroll-behavior: contain; color: #d7deea; font-size: 12px; line-height: 1.62; overflow-wrap: anywhere; }
.mail-detail-body a { display: inline-flex; max-width: 100%; margin: 4px 0; padding: 5px 8px; border: 1px solid rgba(110,182,255,.22); border-radius: 5px; color: #8dcbff; background: rgba(110,182,255,.06); text-decoration: none; overflow-wrap: anywhere; }
.mail-empty-body { color: var(--muted); }
.mail-detail-actions { flex: 0 0 auto; margin-top: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.mail-reply { flex: 0 0 auto; padding-top: 12px; border-top: 1px solid var(--line); }
.mail-reply textarea { min-height: 108px; max-height: 30vh; }
.mail-reply-actions { margin-top: 9px; display: flex; gap: 8px; }
.mail-reply-actions > * { flex: 1; }
html.keyboard-open .mail-panel .modal-panel { height: calc(var(--visible-height) - 8px); max-height: calc(var(--visible-height) - 8px); }

.toast-stack { position: fixed; z-index: 1200; top: max(18px, env(safe-area-inset-top)); left: 50%; width: min(calc(100% - 32px), 440px); transform: translateX(-50%); pointer-events: none; }
.toast { margin-bottom: 7px; padding: 11px 13px; border: 1px solid rgba(85,242,211,.22); border-radius: 7px; color: #eafaf6; background: rgba(14,28,43,.96); box-shadow: 0 14px 40px rgba(0,0,0,.3); font-size: 10px; animation: toast-in .25s ease both; }
.toast.error { border-color: rgba(255,125,142,.3); color: #ffd6dc; }
.owner-diagnostic {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,125,142,.2);
  color: #ffd9df;
  font-size: 9px;
}
.owner-diagnostic summary { cursor: pointer; font-weight: 780; }
.owner-diagnostic pre {
  max-height: 210px;
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #f3cbd2;
  font: 9px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.skeleton { position: relative; overflow: hidden; color: transparent !important; background: rgba(255,255,255,.045) !important; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); transform: translateX(-100%); animation: skeleton 1.3s infinite; }
@keyframes skeleton { to { transform: translateX(100%); } }

@media (min-width: 760px) {
  .app { max-width: 1160px; }
  .content { padding-left: max(28px, calc((100% - 880px) / 2)); padding-right: max(28px, calc((100% - 880px) / 2)); }
  .bottom-nav { max-width: 620px; left: 50%; transform: translateX(-50%); }
  .sheet-panel, .modal-panel { max-width: 600px; border-radius: 8px 8px 0 0; }
  .month-day { min-height: 88px; }
}

@media (max-width: 520px) {
  .event-time-row { grid-template-columns: 1fr; }
  .bottom-nav {
    left: 12px;
    right: 12px;
    bottom: max(18px, env(safe-area-inset-bottom));
    height: 72px;
    padding: 5px 4px;
    grid-template-columns: 1fr 1fr 64px 1fr 1fr;
    border-radius: 24px;
    border-color: rgba(176,200,239,.14);
    background: rgba(8,17,31,.93);
    box-shadow: 0 16px 42px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.025);
  }
  .nav-item { gap: 4px; border-radius: 15px; }
  .nav-item.active { color: #eef5ff; background: transparent; }
  .nav-item.active::after {
    content: "";
    position: absolute;
    bottom: 2px;
    width: 16px;
    height: 2px;
    border-radius: 1px;
    background: var(--mint);
    box-shadow: 0 0 12px rgba(85,242,211,.5);
  }
  .nav-icon svg { width: 20px; height: 20px; }
  .nav-label { font-size: 8px; font-weight: 700; }
  .bot-button {
    width: 62px;
    height: 62px;
    transform: translateY(-7px);
    border-radius: 20px;
    box-shadow: 0 12px 30px rgba(72,215,208,.2), inset 0 1px rgba(255,255,255,.34);
  }
  .bot-button::before { inset: 8px; border-radius: 15px; }
  .bot-face { width: 31px; height: 31px; }
  .bot-face svg { width: 21px; height: 21px; }
  .modal-panel { max-height: calc(var(--visible-height) - 12px); padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 370px) {
  .field-row { grid-template-columns: 1fr; }
  .event-time-fields { grid-template-columns: minmax(0, 1fr) 96px; }
  .composer.live .composer-button { width: 31px; }
  .composer-tools { gap: 3px; }
  .segmented { width: 220px; }
  .month-day { min-height: 54px; padding: 5px 3px; }
}
