/* MSN Messenger 7.x / Windows XP Luna skin (msn-reskin-plan.md §2).
   vendor/xp.css supplies scrollbars + form-control polish; the window
   chrome, MSN band, and all app surfaces live here. All hex values are the
   researched Luna / pixel-sampled MSN 7.5 palette — see the plan. */

* { box-sizing: border-box; }
:root { color-scheme: light; }
[hidden] { display: none !important; }

/* xp.css gives every <button> a dialog-button min-width (75px); our compact
   controls (menus, caps, tool strips, contact rows) must opt back out. */
.xpwin button, #taskbar button, .toast button { min-width: 0; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 11px Tahoma, "Segoe UI", sans-serif;
  color: #000;
  background: radial-gradient(ellipse at 30% 20%, #6FA1D9 0%, #4A82BE 45%, #3A6EA5 100%);
}

#desktop {
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  padding: 24px 16px 56px;
}

/* ---------------- XP window chrome ---------------- */

.xpwin {
  background: #D7E4F5;
  border-radius: 8px 8px 6px 6px;
  box-shadow:
    inset 0 0 0 1px #0831D9,
    inset 0 0 0 2px #166AEE,
    inset 0 0 0 3px #0855DD,
    2px 3px 8px rgba(0, 0, 0, 0.55);
  padding: 3px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}
.xpwin.minimized { display: none; }

.titlebar {
  min-height: 28px;
  flex: none;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg,
    #0997FF 0%, #0053EE 8%, #0050EE 40%, #0066FF 88%,
    #0066FF 93%, #005BFF 95%, #003DD7 96%, #003DD7 100%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 8px;
  color: #fff;
  font: bold 13px "Trebuchet MS", Tahoma, sans-serif;
  text-shadow: 1px 1px #0F1089;
  user-select: none;
}
.titlebar .ticon { width: 16px; height: 16px; flex: none; }
.titlebar .ttext { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.caps { display: flex; gap: 2px; }
.cap {
  width: 21px; height: 21px; flex: none;
  border-radius: 3px;
  border: 1px solid #fff;
  background: linear-gradient(180deg, #7EB1F7 0%, #2E6FE5 30%, #1D50CE 85%, #3E80F0 100%);
  color: #fff;
  font: bold 11px Tahoma, sans-serif;
  line-height: 17px;
  text-align: center;
  text-shadow: none;
  cursor: pointer;
  padding: 0;
}
.cap.close { background: linear-gradient(180deg, #F1A489 0%, #E56B3F 30%, #C6371B 85%, #E8734A 100%); }

/* the glossy blue-white MSN 7.5 band */
.band {
  background: linear-gradient(180deg,
    #F2F6FF 0%, #EFFAFF 10%, #EBF0F4 25%, #CBDCF8 42%,
    #B9C6E6 52%, #B2C5E3 58%, #CAD9EE 72%, #E8ECF7 88%, #F5F8FD 100%);
  border-top: 1px solid #fff;
  border-bottom: 1px solid #A8B7CF;
}

/* XP buttons & fields (mirrors XP.css values; ours win inside .xpwin) */
.xbtn {
  font: 11px Tahoma, sans-serif;
  color: #1a2b4a;
  border: 1px solid #003C74;
  border-radius: 3px;
  background: linear-gradient(180deg, #FFFFFF 0%, #ECEBE5 86%, #D8D0C4 100%);
  padding: 3px 10px;
  cursor: pointer;
}
.xbtn:hover { box-shadow: inset 0 0 0 1px #FFF0CF, inset 0 0 0 2px #FDD889, inset 0 0 0 3px #FBC761; }
.xbtn:active { background: linear-gradient(180deg, #CDCAC3 0%, #E3E3DB 8%, #E5E5DE 94%, #F2F2F1 100%); }
.xbtn:focus-visible { outline: none; box-shadow: inset 0 0 0 1px #CEE7FF, inset 0 0 0 2px #98B8EA, inset 0 0 0 3px #89ADE4; }
.xfield {
  border: 1px solid #7F9DB9;
  background: #fff;
  font: 11px Tahoma, sans-serif;
  padding: 3px 5px;
  border-radius: 0;
}
.linkish {
  background: none; border: none; padding: 2px 0;
  color: #1B5CC4; font: 11px Tahoma, sans-serif; cursor: pointer;
}
.linkish:hover { text-decoration: underline; }
.err { color: #C6371B; font-size: 11px; min-height: 1.2em; margin: 2px 0; }
.dim { color: #7C7C7C; }
.fieldLabel { display: block; color: #1a2b4a; margin: 6px 0 2px; }
.checkRow { display: flex; align-items: center; gap: 5px; margin: 4px 0; cursor: pointer; }
.checkRow.sub { margin-left: 16px; }
.row { display: flex; gap: 6px; align-items: center; }
.row .xfield { flex: 1; min-width: 0; }

/* ---------------- menus ---------------- */

.menubar { display: flex; flex-wrap: wrap; overflow: hidden; gap: 2px; padding: 2px 4px; flex: none; }
.menu { position: relative; }
.menuTop {
  background: none; border: none; padding: 3px 7px;
  font: 11px Tahoma, sans-serif; color: #1a2b4a;
  border-radius: 2px; cursor: pointer;
}
.menuTop:hover, .menu.open .menuTop { background: #316AC5; color: #fff; }
.menuDrop {
  display: none;
  position: absolute; top: 100%; left: 0; z-index: 40;
  min-width: 180px;
  background: #fff;
  border: 1px solid #ACA899;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  padding: 2px;
}
.menu.open .menuDrop { display: block; }
.menuDrop button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: 4px 18px;
  font: 11px Tahoma, sans-serif; cursor: pointer;
}
.menuDrop button:hover { background: #316AC5; color: #fff; }
.menuDrop hr { border: none; border-top: 1px solid #ACA899; margin: 2px 6px; }

/* ---------------- status buddies + display pictures ---------------- */

.buddy-slot { display: inline-flex; width: 15px; height: 15px; vertical-align: -3px; flex: none; }
.buddy-slot svg { width: 100%; height: 100%; }
.dp {
  background: linear-gradient(180deg, #EAF2FF, #C6D9F5);
  border: 1px solid #8AA6C9;
  border-radius: 3px;
  box-shadow: 1px 1px 0 #fff inset;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.dp img { width: 100%; height: 100%; object-fit: cover; }
.dpSmall { width: 48px; height: 48px; flex: none; }
.dpSmall .dpPlaceholder, .dpPane .dpPlaceholder { width: 60%; height: 60%; }

/* ---------------- sign-in window ---------------- */

.signinWin { width: 300px; margin: auto; align-self: center; }
#authView[hidden] { display: none; }
.signinBody { padding: 14px 22px 18px; display: flex; flex-direction: column; gap: 4px; }
.signinLogo { font-size: 44px; text-align: center; padding: 6px 0 2px;
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.3)); }
.signinBody form { display: flex; flex-direction: column; }
.signinBtn { margin-top: 10px; align-self: center; padding: 4px 26px; }
#signinBusy { display: flex; align-items: center; gap: 8px; padding: 8px 0 0; color: #1a2b4a; }
#signinBusy[hidden] { display: none; }
.spinBuddy { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinBuddy { animation: none; } }

/* When authed, the sign-in overlay covers everything until hidden */
#authView { position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 50; }

/* ---------------- contact list window ---------------- */

.rosterWin { width: 272px; height: calc(100dvh - 104px); max-height: 720px; }
.idBlock { display: flex; gap: 8px; padding: 8px 10px; align-items: center; flex: none; }
.idText { min-width: 0; flex: 1; }
.idName { font-weight: bold; font-size: 12px; padding: 1px 4px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idName .arrow { color: #44618E; font-size: 9px; }
.statusMenu .menuDrop { min-width: 150px; }
.psm { color: #7C7C7C; font-style: italic; margin: 2px 0 0 4px; cursor: text;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emailLine { color: #35507C; padding: 3px 10px; flex: none; }
.emailLine.offline { color: #A33; }

.roster { background: #fff; border-top: 1px solid #A8B7CF; padding: 4px 0 8px;
  flex: 1; overflow-y: auto; }
.rgroup { font-weight: bold; color: #1a2b4a; padding: 6px 8px 3px; user-select: none; }
.rgroup .tri { color: #44618E; font-size: 8px; }
.contact {
  display: flex; align-items: center; gap: 6px;
  width: 100%; text-align: left;
  background: none; border: none;
  font: 11px Tahoma, sans-serif;
  padding: 3px 8px 3px 22px;
  cursor: pointer;
  white-space: nowrap; overflow: hidden;
}
.contact:hover { background: #DFE9F5; }
.contact.active { background: #316AC5; color: #fff; }
.contact.active .cps, .contact.active .suffix { color: #D6E4F7; }
.contact .cname { overflow: hidden; text-overflow: ellipsis; }
.contact .cps { color: #7C7C7C; font-style: italic; overflow: hidden; text-overflow: ellipsis; }
.contact .suffix { color: #555; }
.contact.off { color: #7C7C7C; }
.rosterNew { margin: 2px 0 6px 22px; }

.adSlot { padding: 6px; flex: none; border-radius: 0 0 4px 4px; border-top: 1px solid #A8B7CF; }
.ad {
  padding: 7px; text-align: center; color: #6B4A00;
  background: linear-gradient(180deg, #FFF6DE, #FFE1A8);
  border: 1px solid #D9A94F; border-radius: 3px;
}
.ad b { display: block; font-size: 12px; }
.ad span { font-size: 10px; }

/* ---------------- conversation window ---------------- */

.convoWin { flex: 1; max-width: 620px; height: calc(100dvh - 104px); max-height: 720px; }
.toolbar { display: flex; gap: 2px; padding: 4px 8px; flex: none; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font: 10px Tahoma, sans-serif; color: #1a2b4a;
  padding: 3px 8px; border-radius: 3px; border: 1px solid transparent;
  cursor: pointer; background: none;
}
.tool:hover { background: rgba(255, 255, 255, 0.65); border-color: #A8B7CF; }
.tool .tico { font-size: 16px; line-height: 1; }
.toLine {
  padding: 4px 10px; color: #1a2b4a; flex: none;
  border-bottom: 1px solid #C3D2E8; background: #EAF1FB;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.convoBody { display: flex; gap: 6px; padding: 6px 8px; flex: 1; min-height: 0; }
#log {
  flex: 1;
  background: #fff;
  border: 1px solid #586170;
  border-radius: 6px;
  padding: 8px 10px;
  overflow-y: auto;
  line-height: 1.45;
  min-width: 0;
  overflow-wrap: break-word;
}
.dpCol { display: flex; flex-direction: column; justify-content: space-between; flex: none; }
.dpPane { display: flex; align-items: flex-start; gap: 2px; }
.dpPane .dp { width: 86px; height: 86px; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.18); border-radius: 4px; }
.dpPane.collapsed .dp { display: none; }
.chev { background: none; border: none; color: #44618E; cursor: pointer; font-size: 9px; padding: 2px; }

/* the classic warning line, always first in the log */
.pwWarn { color: #7C7C7C; margin-bottom: 8px; }

/* says:-style rows */
.mrow { margin-top: 7px; }
.mrow .says { color: #4E5F7D; }
.mrow .says .stamp { float: right; color: #9AA6B8; font-size: 10px; }
.mrow.noStamp .stamp { display: none; }
.mrow .msg { padding: 1px 0 0 14px; white-space: pre-wrap; }
.mrow.grouped .says { display: none; }
.mrow.grouped { margin-top: 2px; }
.mrow.pendingRow { opacity: 0.5; }
.mrow.sys { color: #7C7C7C; font-style: italic; }
.mrow.sys .msg { padding-left: 0; }
img.emo { width: 19px; height: 19px; vertical-align: -5px; }

/* name-code effect classes (namecodes.js closed set) */
.nc-b { font-weight: bold; }
.nc-i { font-style: italic; }
.nc-u { text-decoration: underline; }
.nc-s { text-decoration: line-through; }
.nc-u.nc-s { text-decoration: underline line-through; }

/* per-message fmt (WP-FMT closed set) */
.fmt-b { font-weight: bold; }
.fmt-i { font-style: italic; }
.fmt-u { text-decoration: underline; }

.inputArea { padding: 2px 8px 6px; flex: none; }
.fmtStrip { display: flex; gap: 6px; padding: 3px 2px; align-items: center; position: relative; }
.fmtBtn { cursor: pointer; border: 1px solid transparent; border-radius: 2px;
  padding: 1px 4px; background: none; font-size: 13px; }
.fmtBtn:hover { border-color: #A8B7CF; background: rgba(255, 255, 255, 0.7); }
.fmtBtn.disabled { opacity: 0.4; cursor: default; }
#sendForm { display: flex; gap: 6px; }
#sendForm .xfield {
  flex: 1; min-width: 0; height: 40px;
  background: #FBFBFB; border-color: #93989C;
  box-shadow: inset 1px 1px 2px #C0C9E0;
}
.sendBtn { padding: 0 16px; }

.statusBar {
  background: #FDFDFF;
  border-top: 1px solid #505E67;
  border-radius: 0 0 4px 4px;
  padding: 3px 8px;
  font: bold 10px Verdana, Tahoma, sans-serif;
  color: #4E5F7D;
  min-height: 19px;
  flex: none;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* emoticon picker */
#emoPickerHolder { position: absolute; bottom: 100%; left: 0; z-index: 30; }
#emoPickerHolder[hidden] { display: none; }
.emoPicker {
  display: grid; grid-template-columns: repeat(8, 26px); gap: 2px;
  background: #fff; border: 1px solid #ACA899; padding: 6px;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.35);
}
.emoPick { background: none; border: 1px solid transparent; border-radius: 2px;
  padding: 2px; cursor: pointer; }
.emoPick:hover { border-color: #316AC5; background: #DFE9F5; }

/* nudge shake — precomputed jitter, transform-only */
@keyframes nudgeshake {
  0% { transform: translate(0, 0); } 8% { transform: translate(-5px, 3px); }
  16% { transform: translate(4px, -4px); } 24% { transform: translate(-3px, -5px); }
  32% { transform: translate(5px, 4px); } 40% { transform: translate(-4px, 2px); }
  48% { transform: translate(3px, -5px); } 56% { transform: translate(-5px, -2px); }
  64% { transform: translate(4px, 5px); } 72% { transform: translate(-2px, -4px); }
  80% { transform: translate(5px, -3px); } 88% { transform: translate(-4px, 4px); }
  100% { transform: translate(0, 0); }
}
.shaking { animation: nudgeshake 1.4s linear; }
@media (prefers-reduced-motion: reduce) { .shaking { animation: none; } }

/* ---------------- dialogs ---------------- */

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35);
  display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal[hidden] { display: none; }
.dialog { width: min(360px, 94vw); max-height: 86dvh; }
.optionsDialog { width: min(420px, 94vw); }
.dialogBody { padding: 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.dialogActions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 8px; }
.memberRow { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.memberRow .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memberRow .uname { color: #7C7C7C; }
.memberRow .xbtn { padding: 2px 7px; font-size: 11px; }

.tabRow { display: flex; gap: 0; border-bottom: 1px solid #ACA899; margin-bottom: 6px; }
.tabBtn {
  font: 11px Tahoma, sans-serif;
  border: 1px solid #ACA899; border-bottom: none;
  border-radius: 3px 3px 0 0;
  background: #ECE9D8; padding: 3px 10px; cursor: pointer;
  position: relative; top: 1px;
}
.tabBtn.active { background: #fff; font-weight: bold; border-bottom: 1px solid #fff; }
.tabPage { display: flex; flex-direction: column; gap: 2px; }
.tabPage[hidden] { display: none; }
.namePreview { padding: 4px 0; }
fieldset { border: 1px solid #ACA899; border-radius: 3px; margin: 6px 0; }
legend { color: #1a2b4a; }
.awayMin { width: 44px; flex: none; }

/* ---------------- toasts ---------------- */

#toasts { position: fixed; right: 12px; bottom: 44px; z-index: 70;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.toast {
  width: 210px;
  background: linear-gradient(180deg, #FDFEFF, #D7E4F5);
  border: 1px solid #5A7EB5;
  border-radius: 6px;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4);
  padding: 8px 10px;
  display: flex; gap: 8px; align-items: flex-start;
  cursor: pointer;
  transform: translateY(140%);
  transition: transform 0.25s ease;
}
.toast.shown { transform: translateY(0); }
.toast .tbody { flex: 1; min-width: 0; overflow: hidden; }
.toast .tx { color: #44618E; background: none; border: none; cursor: pointer; padding: 0 2px; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------------- taskbar ---------------- */

#taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 32px;
  background: linear-gradient(#1F2F86 0, #3165C4 3%, #3682E5 6%, #4490E6 10%, #2B71E0 15%, #2258D5 23%, #2157D6 38%, #245DDB 54%, #2562DF 86%, #2158D4 92%, #1D4EC0 95%, #1941A5 98%);
  display: flex; align-items: stretch;
  z-index: 20;
}
.startBtn {
  display: flex; align-items: center; gap: 5px;
  padding: 0 16px 0 10px;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(180deg, #6ECF5A 0%, #4AB830 18%, #3AAA20 35%, #2D9618 55%, #267D10 75%, #1F6A0C 100%);
  border-right: 1px solid #1A5C08;
  color: #fff;
  font: bold italic 15px "Trebuchet MS", Tahoma, sans-serif;
  text-shadow: 1px 1px #000;
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.4);
  user-select: none;
}
.startLogo { font-size: 16px; font-style: normal; }
.taskBtns { display: flex; gap: 3px; padding: 3px 6px; flex: 1; overflow: hidden; }
.taskBtn {
  display: flex; align-items: center; gap: 5px;
  min-width: 0; max-width: 180px; flex: 1;
  padding: 0 8px;
  border: none; border-radius: 3px;
  background: linear-gradient(180deg, #4E8DF0, #3068D8);
  box-shadow: inset 0 1px 0 #7FB0F7;
  color: #fff; font: 11px Tahoma, sans-serif;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.taskBtn.flash { animation: taskflash 0.9s steps(2) infinite; }
@keyframes taskflash {
  0% { background: linear-gradient(180deg, #4E8DF0, #3068D8); }
  100% { background: linear-gradient(180deg, #F5A951, #E08324); }
}
.tray {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px 0 14px;
  background: linear-gradient(#0C59B9 1%, #139EE9 6%, #18B5F2 10%, #1290E8 19%, #0D8DEA 63%, #0D9FF1 81%, #1392E2 94%, #095BC9 100%);
  border-left: 1px solid #1042AF;
  box-shadow: inset 1px 0 0 #18BBFF;
  color: #fff;
}

.mobileOnly { display: none; }
#backdrop { display: none; }
.joke { cursor: help; }

/* timestamps toggle (Options → Messages) */
#log.noStamps .stamp { display: none; }

/* before auth, only the sign-in window exists */
body:not(.authed) #rosterWin,
body:not(.authed) #convoWin,
body:not(.authed) #taskbar { display: none; }

/* ---------------- phone layout: windows go full-screen ---------------- */

@media (max-width: 700px) {
  #desktop { padding: 0; gap: 0; display: block; }
  #taskbar { display: none; }
  .mobileOnly { display: inline-block; }

  .convoWin {
    max-width: none; width: 100%;
    height: 100dvh; max-height: none;
    border-radius: 0;
  }
  .convoWin .titlebar { padding-top: calc(env(safe-area-inset-top)); border-radius: 0; min-height: calc(28px + env(safe-area-inset-top)); }
  .convoWin .caps { display: none; }
  .toolbar { display: none; }
  .dpCol { display: none; }
  .inputArea { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .statusBar { display: none; }

  .rosterWin {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 25;
    width: min(300px, 85vw); height: 100dvh; max-height: none;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .rosterWin .titlebar { padding-top: calc(env(safe-area-inset-top)); border-radius: 0; min-height: calc(28px + env(safe-area-inset-top)); }
  .rosterWin .caps { display: none; }
  body.sidebar-open .rosterWin { transform: translateX(0); box-shadow: 0 0 24px rgba(0, 0, 0, 0.6); }
  body.sidebar-open #backdrop { display: block; position: fixed; inset: 0; z-index: 24;
    background: rgba(0, 0, 0, 0.5); }

  #authView { width: min(300px, 92vw); }
  .signinWin .titlebar { padding-top: calc(env(safe-area-inset-top)); }
  #toasts { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .rosterWin { transition: none; } }
