/* The demo apps and the shared text editor. */

/* ---------- editor (textarea + mirror) ---------- */
.editor { position: relative; flex: 1; min-height: 0; display: flex; }
.editor-input, .editor-mirror {
  margin: 0;
  border: 0;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  padding: var(--pad, 14px 18px);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
  scrollbar-gutter: stable;
}
.editor-input {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  resize: none;
  outline: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  overflow-y: auto;
  user-select: text;
  -webkit-user-select: text;
}
.editor-input::selection { background: rgba(10, 132, 255, 0.45); }
.editor-mirror {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
}
.editor-mark { color: transparent; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.editor-mark.is-wave {
  background:
    linear-gradient(100deg, transparent 0 20%, rgba(255, 201, 74, 0.55) 35%, rgba(154, 162, 240, 0.55) 50%, transparent 65%) no-repeat,
    rgba(255, 201, 74, 0.18);
  background-size: 300% 100%, 100% 100%;
  animation: wave 1.5s ease-out forwards;
}
@keyframes wave {
  0% { background-position: 120% 0, 0 0; opacity: 1; }
  70% { background-position: -40% 0, 0 0; opacity: 1; }
  100% { background-position: -40% 0, 0 0; opacity: 0; }
}

/* ---------- Mail ---------- */
.app-mail .win-titlebar { background: var(--win-bg-2); border-bottom: 1px solid var(--sep); }
.mail-toolbar-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail { flex: 1; min-height: 0; display: flex; flex-direction: column; font-size: 14px; line-height: 1.5; }
.mail-field {
  display: flex; align-items: center; gap: 8px; min-height: 36px; margin: 0 18px;
  border-bottom: 1px solid var(--sep); color: var(--text);
}
.mail-label { color: var(--text-3); }
.mail-token { padding: 1px 9px; border-radius: 11px; background: rgba(10, 132, 255, 0.22); color: #8cc2ff; }
.mail .editor { --pad: 14px 18px; }
.win.is-sending { animation: send 0.45s ease-in forwards; }
@keyframes send { to { transform: translate(40vw, -60vh) scale(0.3); opacity: 0; } }

/* ---------- Notes ---------- */
.app-notes .win-titlebar { background: var(--win-sidebar); }
.notes { flex: 1; min-height: 0; display: flex; }
.notes-list {
  width: 210px; flex: none; padding: 6px 10px; overflow: auto;
  background: var(--win-sidebar); border-right: 1px solid var(--sep);
}
.notes-list-head { padding: 4px 6px 8px; font-weight: 700; font-size: 15px; }
.notes-item { padding: 8px 10px; border-radius: 9px; }
.notes-item.is-selected { background: #a07c19; }
.notes-item-title { font-weight: 700; }
.notes-item-meta { font-size: 12px; color: rgba(255, 255, 255, 0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-main { flex: 1; min-width: 0; display: flex; background: #1c1c1e; }
.notes-body { font-size: 15px; line-height: 1.55; --pad: 18px 24px; }

/* ---------- Messages ---------- */
.app-messages .win-titlebar { background: var(--win-bg-2); border-bottom: 1px solid var(--sep); }
.chat-peer { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.chat-avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(#a1a7b8, #6c7385); color: #fff; font-weight: 600; font-size: 13px;
}
.chat { flex: 1; min-height: 0; display: flex; }
.chat-list { width: 190px; flex: none; padding: 8px; background: var(--win-sidebar); border-right: 1px solid var(--sep); }
.chat-search { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); color: var(--text-3); margin-bottom: 8px; }
.chat-row { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 9px; }
.chat-row .chat-avatar { width: 34px; height: 34px; font-size: 15px; }
.chat-row.is-selected { background: var(--accent); }
.chat-row-text { display: grid; min-width: 0; }
.chat-row-text span { font-size: 12px; color: rgba(255, 255, 255, 0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #1c1c1e; }
.chat-thread { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 5px; }
.chat-time { align-self: center; font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.bubble { max-width: 76%; padding: 7px 12px; border-radius: 18px; font-size: 14px; line-height: 1.4; }
.bubble.is-in { align-self: flex-start; background: #3a3a3c; }
.bubble.is-out { align-self: flex-end; background: #0a84ff; color: #fff; }
.bubble.is-new { animation: bubble 0.3s ease-out; }
@keyframes bubble { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.chat-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; }
.chat-input {
  flex: 1; max-height: 110px; min-height: 34px; border-radius: 17px;
  border: 1px solid rgba(255, 255, 255, 0.16); font-size: 14px; line-height: 1.4; --pad: 7px 12px;
}
.chat-input .editor-input { overflow-y: auto; height: 80px; }
.chat-send { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; margin-bottom: 2px; cursor: pointer; }

/* ---------- Terminal ---------- */
.app-terminal { background: rgba(22, 22, 24, 0.94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.app-terminal .win-titlebar { height: 34px; }
.app-terminal .win-title { font-weight: 500; font-size: 12.5px; }
.term-screen {
  flex: 1; overflow: auto; padding: 6px 12px 12px;
  font: 13px/1.45 var(--mono); color: #e6e6e6; outline: none;
  user-select: text; -webkit-user-select: text; white-space: pre-wrap;
}
.term-sel { color: #fff; }
.term-screen ::selection { background: rgba(10, 132, 255, 0.5); }
.term-cursor { display: inline-block; width: 8px; height: 1.15em; vertical-align: -0.2em; background: rgba(230, 230, 230, 0.4); }
.term-screen:focus .term-cursor { background: #e6e6e6; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
