/* comms.css — Mail + Messages + Notes + Calculator + TextEdit */

/* ---- Mail ---- */
.mail-app { height: 100%; }
.mail-list { flex: 0 0 330px; padding: 8px 8px; }
.mail-list-empty { text-align: center; color: var(--text-tertiary); padding: 30px 0; font-size: 13px; }
.mail-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
}
.mail-row:hover { background: var(--list-hover); }
.mail-row.sel { background: var(--accent); color: #fff; }
.mail-row.sel .mail-preview, .mail-row.sel .mail-date { color: rgba(255, 255, 255, 0.75); }
.mail-avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%;
  color: #fff;
  font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.mail-avatar.big { width: 40px; height: 40px; font-size: 14px; }
.mail-row-main { flex: 1; min-width: 0; }
.mail-row-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-from { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row:not(.unread) .mail-from { font-weight: 500; }
.mail-date { font-size: 11px; color: var(--text-secondary); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.mail-subject { font-size: 12.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.mail-row:not(.unread) .mail-subject { color: var(--text-secondary); }
.mail-row.sel .mail-subject { color: #fff; }
.mail-flag-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--sys-orange); flex: 0 0 8px; }
.mail-preview { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.mail-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: 0 0 9px; }
.mail-row.sel .mail-unread-dot { background: #fff; }

.mail-reader { flex: 1; min-width: 0; padding: 18px 24px; }
.mail-reader-head { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 14px; border-bottom: 0.5px solid var(--sep); margin-bottom: 16px; }
.mail-reader-subject { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.mail-reader-meta { display: flex; gap: 10px; align-items: center; }
.mail-reader-from { font-size: 13px; font-weight: 600; }
.mail-reader-email { font-weight: 400; color: var(--text-secondary); }
.mail-reader-to { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.mail-reader-body { white-space: pre-wrap; font-size: 13px; line-height: 1.55; color: var(--text); }

.mail-compose { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.mail-compose-to, .mail-compose-subject { width: 100%; }
.mail-compose-body { width: 100%; min-height: 140px; resize: none; border: 0.5px solid var(--field-border); border-radius: 6px; padding: 8px 10px; background: var(--window-bg); color: var(--text); font-size: 13px; outline: none; }
.mail-compose-body:focus { border-color: var(--accent); }

/* ---- Messages ---- */
.msg-app { height: 100%; }
.msg-list { flex: 0 0 280px; border-right: 0.5px solid var(--sep); padding: 8px; background: var(--sidebar-bg); }
.msg-convo { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; }
.msg-convo:hover { background: var(--sidebar-item-hover); }
.msg-convo.sel { background: var(--accent); color: #fff; }
.msg-convo.sel .msg-convo-preview, .msg-convo.sel .msg-convo-time { color: rgba(255, 255, 255, 0.75); }
.msg-avatar {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 50%;
  color: #fff;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.msg-convo-main { flex: 1; min-width: 0; }
.msg-convo-top { display: flex; justify-content: space-between; gap: 8px; }
.msg-convo-name { font-size: 13px; font-weight: 600; }
.msg-convo-time { font-size: 11px; color: var(--text-secondary); }
.msg-convo-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.msg-unread-badge {
  background: var(--sys-blue);
  color: #fff;
  font-size: 11px; font-weight: 600;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.msg-chat { display: flex; flex-direction: column; height: 100%; }
.msg-chat-head {
  flex: 0 0 52px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 0.5px solid var(--sep);
}
.msg-chat-head .msg-avatar { width: 34px; height: 34px; font-size: 12px; flex-basis: 34px; }
.msg-chat-title { font-size: 14px; font-weight: 600; }
.msg-thread { flex: 1; min-height: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.msg-day { text-align: center; font-size: 11px; color: var(--text-secondary); padding: 8px 0 6px; }
.msg-bubble { display: flex; }
.msg-bubble-text {
  max-width: 70%;
  padding: 7px 12px;
  font-size: 13.5px;
  line-height: 1.35;
  border-radius: 17px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-bubble.in { justify-content: flex-start; }
.msg-bubble.in .msg-bubble-text {
  background: var(--fill);
  color: var(--text);
  border-bottom-left-radius: 6px;
}
.msg-bubble.out { justify-content: flex-end; }
.msg-bubble.out .msg-bubble-text {
  background: linear-gradient(#2ea1ff, #0a7cff);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg-delivered { text-align: right; font-size: 10.5px; color: var(--text-secondary); padding: 2px 8px 0; }
.msg-bubble.typing { justify-content: flex-start; }
.msg-bubble.typing .msg-bubble-text { display: flex; gap: 4px; align-items: center; padding: 11px 13px; }
.tdot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); animation: tdot-bounce 1.2s infinite; }
.tdot:nth-child(2) { animation-delay: 0.15s; }
.tdot:nth-child(3) { animation-delay: 0.3s; }
@keyframes tdot-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.msg-composer {
  flex: 0 0 56px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  border-top: 0.5px solid var(--sep);
}
.msg-input {
  flex: 1;
  border: 1px solid var(--field-border);
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 13px;
  background: var(--field-bg);
  color: var(--text);
  outline: none;
}
.msg-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.msg-input::placeholder { color: var(--text-tertiary); }
.msg-send {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--sys-green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.msg-send:active { filter: brightness(0.85); }

/* ---- Notes ---- */
.notes-app { height: 100%; }
.notes-app .app-sidebar .si-icon { color: var(--sys-yellow); }
.notes-pane { flex-basis: 250px; width: 250px; border-right: 0.5px solid var(--sep); }
.notes-empty { text-align: center; color: var(--text-tertiary); font-size: 13px; padding: 30px 0; }
.notes-row { padding: 8px 12px; border-radius: 8px; }
.notes-row:hover { background: var(--list-hover); }
.notes-row.sel { background: #ffd60a; color: #1d1d1f; }
.notes-row.sel .notes-row-date, .notes-row.sel .notes-row-snippet { color: rgba(29, 29, 31, 0.6); }
.notes-row-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-row-sub { display: flex; gap: 6px; align-items: baseline; margin-top: 1px; }
.notes-row-date { font-size: 11px; color: var(--text-secondary); flex: 0 0 auto; }
.notes-row-snippet { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-editor-wrap { flex: 1; min-width: 0; background: var(--window-bg); }
.notes-editor {
  flex: 1;
  height: 100%;
  padding: 22px 26px;
  font-size: 13.5px;
  line-height: 1.6;
  outline: none;
  overflow-y: auto;
  white-space: pre-wrap;
}
.notes-editor:empty::before { content: attr(data-placeholder); color: var(--text-tertiary); }

/* ---- Calculator ---- */
.calc-body { background: #2d2d30; }
.calc-root { display: flex; flex-direction: column; height: 100%; padding: 4px; }
.calc-display {
  flex: 0 0 84px;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end;
  padding: 8px 12px 6px;
}
.calc-history { font-size: 12px; color: rgba(255, 255, 255, 0.45); min-height: 18px; font-variant-numeric: tabular-nums; }
.calc-main {
  font-size: 44px;
  font-weight: 200;
  color: #fff;
  line-height: 1.1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.calc-main.small { font-size: 30px; }
.calc-pad {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 6px;
  padding: 4px 2px 2px;
}
.calc-key {
  border-radius: 8px;
  font-size: 19px;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.06s ease, transform 0.06s ease;
}
.calc-key:active { filter: brightness(1.35); transform: scale(0.97); }
.k-d { background: #5b5b5f; }
.k-d:nth-child(1n):hover { background: #67676c; }
.k-fn { background: #404045; font-size: 17px; }
.k-op { background: #ff9f0a; font-size: 23px; }
.k-op.held { background: #fff; color: #ff9f0a; }
.k-d.wide { grid-column: span 2; }

/* ---- TextEdit ---- */
.te-body { background: var(--window-bg); }
.te-editor {
  flex: 1;
  width: 100%;
  border: none; outline: none; resize: none;
  padding: 14px 18px;
  background: var(--window-bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  font-family: var(--font-sans);
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
