/* ==========================================================================
   Nudge Messenger — Luna. Period-correct XP/MSN chrome, hand-tuned.
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-ui: Tahoma, "Segoe UI", "Trebuchet MS", Geneva, Verdana, sans-serif;
  --font-brand: "Trebuchet MS", Tahoma, sans-serif;
  --taskbar-h: 34px;
}

/* --- Themes ---------------------------------------------------------------- */

body[data-theme="blue"] {
  --title-grad: linear-gradient(180deg, #2964d8 0%, #175ce4 8%, #3a81f3 40%, #1855c8 88%, #1348a8 100%);
  --title-inactive-grad: linear-gradient(180deg, #8db3ec, #7396d8 45%, #6584c6);
  --title-text: #fff;
  --win-border: #0831d9;
  --win-border-inactive: #6582c6;
  --face: #ece9d8;
  --face-dark: #d4d0c8;
  --face-line: #aca899;
  --text: #1a1a1a;
  --text-dim: #5a5a58;
  --accent: #316ac5;
  --accent-soft: #c1d2ee;
  --content-bg: #ffffff;
  --banner-grad: linear-gradient(180deg, #eaf3fd 0%, #cde3fa 55%, #bcd8f7 100%);
  --banner-line: #9dbde4;
  --field-border: #7f9db9;
  --btn-grad: linear-gradient(180deg, #ffffff, #f1f0ea 45%, #e3e2da 90%, #d6d4c9);
  --btn-border: #003c74;
  --taskbar-grad: linear-gradient(180deg, #3f8cf3 0%, #2861d6 6%, #2157c8 50%, #1c4ab0 95%, #15398c 100%);
  --taskbtn-grad: linear-gradient(180deg, #4f91e8, #3a76d6 50%, #2f65be);
  --taskbtn-active: linear-gradient(180deg, #1d4494, #1a3f8a 50%, #23509f);
  --tray-grad: linear-gradient(180deg, #2b9bf0, #1173d8 50%, #0f5fc0);
  --desktop-a: #4f9ce8; --desktop-b: #2a70cf; --desktop-c: #6db35c;
  --sel-bg: #316ac5; --sel-text: #fff;
  --msg-me: #eef4fb;
  --chat-bg: #ffffff;
  --scroll-track: #f2f1ea; --scroll-thumb: #c9d5ef; --scroll-thumb-border: #99b1dd;
}

body[data-theme="silver"] {
  --title-grad: linear-gradient(180deg, #e8e8ee 0%, #cfd0dc 10%, #a8aabc 45%, #9294a8 90%, #7f8197 100%);
  --title-inactive-grad: linear-gradient(180deg, #e9e9ec, #d6d6dc 50%, #c6c6ce);
  --title-text: #1e2430;
  --win-border: #7d7f94;
  --win-border-inactive: #b5b6c1;
  --face: #eeeef3;
  --face-dark: #d8d8e0;
  --face-line: #b4b4c0;
  --text: #17171c;
  --text-dim: #5c5c66;
  --accent: #5b607e;
  --accent-soft: #d3d5e2;
  --content-bg: #ffffff;
  --banner-grad: linear-gradient(180deg, #f6f6fa 0%, #e2e3ec 60%, #d3d4e1 100%);
  --banner-line: #b7b9c9;
  --field-border: #9497ad;
  --btn-grad: linear-gradient(180deg, #ffffff, #f2f2f5 45%, #e4e4ea 90%, #d5d5de);
  --btn-border: #4c4e63;
  --taskbar-grad: linear-gradient(180deg, #d3d5e0 0%, #b0b2c3 8%, #9698ad 55%, #83859b 100%);
  --taskbtn-grad: linear-gradient(180deg, #c3c5d4, #adafc2 50%, #9b9db2);
  --taskbtn-active: linear-gradient(180deg, #75778d, #6c6e84 50%, #7d7f95);
  --tray-grad: linear-gradient(180deg, #c8cad8, #a3a5ba 50%, #8f91a8);
  --desktop-a: #a8b6cf; --desktop-b: #7c8bad; --desktop-c: #8ba58a;
  --sel-bg: #5b607e; --sel-text: #fff;
  --msg-me: #f1f1f6;
  --chat-bg: #ffffff;
  --scroll-track: #ededf1; --scroll-thumb: #cdcdd9; --scroll-thumb-border: #a9a9ba;
}

body[data-theme="midnight"] {
  --title-grad: linear-gradient(180deg, #2f3d63 0%, #22304f 10%, #31436e 45%, #1b2745 90%, #141d36 100%);
  --title-inactive-grad: linear-gradient(180deg, #3a415a, #2e3449 50%, #262b3d);
  --title-text: #dfe6f5;
  --win-border: #10182e;
  --win-border-inactive: #2c3350;
  --face: #232838;
  --face-dark: #1a1e2c;
  --face-line: #3c445c;
  --text: #e6e9f2;
  --text-dim: #9aa2b8;
  --accent: #6f8fd8;
  --accent-soft: #33405f;
  --content-bg: #1a1f2e;
  --banner-grad: linear-gradient(180deg, #2b3450 0%, #24304c 60%, #1e2941 100%);
  --banner-line: #38466b;
  --field-border: #4a557a;
  --btn-grad: linear-gradient(180deg, #3d465f, #333b52 45%, #2b3248 90%, #242a3d);
  --btn-border: #0e1526;
  --taskbar-grad: linear-gradient(180deg, #2c3756 0%, #1f2a47 8%, #1a2440 55%, #131b31 100%);
  --taskbtn-grad: linear-gradient(180deg, #33405f, #2a3550 50%, #232d45);
  --taskbtn-active: linear-gradient(180deg, #10182c, #0e1526 50%, #16203a);
  --tray-grad: linear-gradient(180deg, #263354, #1b2743 50%, #16203a);
  --desktop-a: #1c2949; --desktop-b: #101a33; --desktop-c: #23345c;
  --sel-bg: #3a5ba0; --sel-text: #fff;
  --msg-me: #222c44;
  --chat-bg: #1a1f2e;
  --scroll-track: #20263a; --scroll-thumb: #39435f; --scroll-thumb-border: #4a557a;
}

/* --- Base -------------------------------------------------------------------- */

html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text);
  background: var(--desktop-b);
  -webkit-font-smoothing: subpixel-antialiased;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

button { font-family: var(--font-ui); font-size: 11px; color: var(--text); }
input, textarea, select { font-family: var(--font-ui); font-size: 11px; color: var(--text); }

:focus-visible { outline: 2px solid #ff9c2a; outline-offset: 1px; }

::-webkit-scrollbar { width: 15px; height: 15px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 1px solid var(--scroll-thumb-border);
  border-radius: 2px;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.55);
}

/* --- Desktop ------------------------------------------------------------------ */

#desktop {
  position: fixed; inset: 0 0 var(--taskbar-h) 0;
  overflow: hidden;
}
#wallpaper {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(255,255,255,.35), rgba(255,255,255,0) 55%),
    linear-gradient(180deg, var(--desktop-a) 0%, var(--desktop-b) 62%, var(--desktop-c) 100%);
}
#wallpaper::after {
  /* rolling hills */
  content: "";
  position: absolute; inset: auto 0 0 0; height: 34%;
  background:
    radial-gradient(140% 120% at 18% 108%, color-mix(in srgb, var(--desktop-c) 88%, #ffffff 12%) 48%, transparent 49%),
    radial-gradient(160% 130% at 82% 118%, color-mix(in srgb, var(--desktop-c) 70%, #000 8%) 52%, transparent 53%);
  opacity: .9;
}
#wallpaper.custom-wallpaper::after { display: none; }
.cloud {
  position: absolute; border-radius: 50px; background: rgba(255,255,255,.75);
  filter: blur(1px);
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: inherit; border-radius: 50%;
}
.cloud::before { width: 55%; height: 160%; left: 12%; top: -78%; }
.cloud::after  { width: 42%; height: 120%; right: 14%; top: -48%; }

#desktop-icons {
  position: absolute; top: 14px; left: 14px;
  display: flex; flex-direction: column; gap: 14px; z-index: 1;
}
.desk-icon {
  width: 84px; background: none; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; padding: 5px 2px;
}
.desk-icon :is(svg, img) { width: 36px; height: 36px; filter: drop-shadow(1px 2px 2px rgba(0,0,20,.4)); }
.desk-icon span {
  color: #fff; text-shadow: 1px 1px 2px rgba(0,0,30,.85);
  text-align: center; line-height: 1.25;
}
.desk-icon:hover span { text-decoration: underline; }
.desk-icon:active { border: 1px dotted rgba(255,255,255,.7); background: rgba(30,80,180,.25); }

/* --- Windows -------------------------------------------------------------------- */

.win {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 200px; min-height: 120px;
  background: var(--face);
  border: 1px solid var(--win-border);
  border-radius: 8px 8px 3px 3px;
  box-shadow: 2px 4px 14px rgba(0, 10, 40, .45), 0 0 0 1px rgba(255,255,255,.12) inset;
}
.win.inactive { border-color: var(--win-border-inactive); }
.win.maximized { border-radius: 0; }

.win-title {
  flex: 0 0 auto;
  height: 26px;
  display: flex; align-items: center; gap: 5px;
  padding: 0 4px 0 7px;
  border-radius: 7px 7px 0 0;
  background: var(--title-grad);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 -1px 0 rgba(0,0,60,.25);
  cursor: default;
  user-select: none;
  touch-action: none;
}
.win.inactive .win-title { background: var(--title-inactive-grad); }
.win-title .win-icon { width: 16px; height: 16px; flex: 0 0 auto; }
.win-title .win-icon :is(svg, img) { width: 16px; height: 16px; display: block; }
.win-title h2 {
  flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-family: var(--font-brand);
  font-size: 12px; font-weight: 700; color: var(--title-text);
  text-shadow: 1px 1px 1px rgba(0,0,60,.55);
}
body[data-theme="silver"] .win-title h2 { text-shadow: 1px 1px 1px rgba(255,255,255,.6); }

.win-btns { display: flex; gap: 2px; }
.win-btn {
  width: 21px; height: 21px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 1px 1px rgba(0,0,40,.35);
  background: linear-gradient(180deg, #6b9bee, #3a70d8 45%, #2857b8);
  color: #fff; font-size: 10px; line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
}
.win-btn :is(svg, img) { width: 11px; height: 11px; display: block; }
.win-btn:hover { filter: brightness(1.15); }
.win-btn:active { filter: brightness(.9); }
.win-btn.close { background: linear-gradient(180deg, #f5a06a, #e0603a 40%, #c33d1d 85%, #a92c10); }
body[data-theme="silver"] .win-btn { background: linear-gradient(180deg, #c4c6d4, #9a9cb2 45%, #83859b); }
body[data-theme="silver"] .win-btn.close { background: linear-gradient(180deg, #f5a06a, #e0603a 40%, #c33d1d 85%, #a92c10); }
body[data-theme="midnight"] .win-btn { background: linear-gradient(180deg, #45527a, #333f61 45%, #262f4c); border-color: rgba(180,195,235,.4); }

.win-menubar {
  flex: 0 0 auto;
  display: flex; gap: 1px;
  padding: 1px 4px;
  background: var(--face);
  border-bottom: 1px solid var(--face-line);
}
.win-menubar > button {
  border: 1px solid transparent; background: none; padding: 2px 7px; cursor: pointer;
}
.win-menubar > button:hover, .win-menubar > button[aria-expanded="true"] {
  background: var(--sel-bg); color: var(--sel-text);
}

.win-body {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  padding: 3px;
}

/* --- XP form controls -------------------------------------------------------------- */

.xp-btn {
  background: var(--btn-grad);
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  padding: 4px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75), inset -1px -2px 2px rgba(120,120,90,.18);
  cursor: pointer;
}
.xp-btn:hover { box-shadow: inset 0 0 0 1.5px #f8b64a66, inset 0 1px 0 rgba(255,255,255,.75); }
.xp-btn:active { background: var(--face-dark); box-shadow: inset 1px 1px 3px rgba(60,60,40,.3); }
.xp-btn:disabled { color: var(--text-dim); border-color: var(--face-line); box-shadow: none; cursor: default; background: var(--face); }
.xp-btn.primary { font-weight: 700; }
body[data-theme="midnight"] .xp-btn { box-shadow: inset 0 1px 0 rgba(160,175,220,.25); }

.xp-field, textarea.xp-field {
  border: 1px solid var(--field-border);
  background: var(--content-bg);
  color: var(--text);
  padding: 4px 5px;
  border-radius: 0;
}
.xp-field:focus { outline: 1px solid var(--accent); outline-offset: -1px; }

select.xp-field { padding: 3px 4px; }

.xp-group {
  border: 1px solid var(--face-line);
  border-radius: 4px;
  padding: 10px;
  position: relative;
  margin-top: 7px;
}
.xp-group > legend, .xp-group > .legend {
  position: absolute; top: -8px; left: 8px;
  background: var(--face); padding: 0 5px; color: var(--accent); font-weight: 700;
}

.hr { border: 0; border-top: 1px solid var(--face-line); border-bottom: 1px solid #fff; margin: 8px 0; }
body[data-theme="midnight"] .hr { border-bottom-color: #ffffff14; }

a.link { color: var(--accent); cursor: pointer; text-decoration: underline; background: none; border: none; font-size: 11px; font-family: var(--font-ui); }
a.link:hover { color: #ff7300; }

.dim { color: var(--text-dim); }
.small { font-size: 10px; }

/* --- Taskbar ---------------------------------------------------------------------- */

#taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--taskbar-h);
  display: flex; align-items: stretch;
  background: var(--taskbar-grad);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
  z-index: 5000;
}
#start-button {
  display: flex; align-items: center; gap: 5px;
  border: none; cursor: pointer;
  padding: 0 16px 0 10px;
  margin-right: 8px;
  color: #fff; font-family: var(--font-brand); font-style: italic; font-weight: 700; font-size: 15px;
  text-shadow: 1px 1px 2px rgba(0,40,0,.6);
  background: linear-gradient(180deg, #7ede64 0%, #3fae2a 45%, #2f8f1d 90%, #257715 100%);
  border-radius: 0 12px 12px 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 2px 0 6px rgba(0,20,60,.4);
}
#start-button:hover { filter: brightness(1.08); }
#start-logo :is(svg, img) { width: 20px; height: 20px; display: block; filter: drop-shadow(1px 1px 1px rgba(0,40,0,.5)); }

#task-buttons {
  flex: 1; display: flex; gap: 4px; align-items: center;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  padding: 0 4px;
}
#task-buttons::-webkit-scrollbar { display: none; }
.task-btn {
  flex: 0 1 170px; min-width: 60px; height: 24px;
  display: flex; align-items: center; gap: 5px;
  border: 1px solid rgba(0,20,80,.45);
  border-radius: 3px;
  padding: 0 7px;
  background: var(--taskbtn-grad);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
  cursor: pointer;
  overflow: hidden; white-space: nowrap;
}
.task-btn span.lbl { overflow: hidden; text-overflow: ellipsis; }
.task-btn :is(svg, img) { width: 14px; height: 14px; flex: 0 0 auto; }
.task-btn.active { background: var(--taskbtn-active); box-shadow: inset 1px 1px 3px rgba(0,0,30,.5); }
.task-btn .badge {
  background: #ffb900; color: #4b2a00; font-weight: 700;
  border-radius: 7px; padding: 0 5px; font-size: 10px; line-height: 13px;
}
.task-btn.flash { animation: taskflash 1s steps(2) infinite; }
@keyframes taskflash { 0% { background: var(--taskbtn-grad); } 50% { background: #f0a53f; } }

#tray {
  display: flex; align-items: center; gap: 8px;
  background: var(--tray-grad);
  box-shadow: inset 2px 0 4px rgba(0,10,50,.35);
  padding: 0 12px 0 10px;
  color: #fff;
}
#clock { font-size: 11px; text-shadow: 1px 1px 1px rgba(0,10,60,.5); min-width: 58px; text-align: right; }
#mute-button { background: none; border: none; cursor: pointer; display: grid; place-items: center; padding: 2px; }
#mute-button :is(svg, img) { width: 15px; height: 15px; }
#conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #67e457; box-shadow: 0 0 4px #67e457; }
#conn-dot.off { background: #e4bb2f; box-shadow: 0 0 4px #e4bb2f; animation: connpulse 1.2s infinite; }
@keyframes connpulse { 50% { opacity: .35; } }

/* --- Sign-in window ------------------------------------------------------------------ */

.signin-hero {
  background: var(--banner-grad);
  border-bottom: 1px solid var(--banner-line);
  padding: 16px 14px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
}
.signin-hero .logo-lockup { display: flex; align-items: center; gap: 9px; }
.signin-hero .logo-lockup :is(svg, img) { width: 52px; height: 52px; }
.brand-name {
  font-family: var(--font-brand); font-weight: 700; font-size: 21px; letter-spacing: -.5px;
  color: #1b53b8; text-shadow: 0 1px 0 #fff;
  line-height: 1.05; text-align: left;
}
body[data-theme="midnight"] .brand-name { color: #9db9f2; text-shadow: none; }
.brand-name .sub { display: block; font-size: 10px; font-weight: 400; letter-spacing: .4px; color: var(--text-dim); font-style: italic; }
.tagline { font-style: italic; color: var(--text-dim); }

.signin-form { padding: 12px 18px 14px; display: flex; flex-direction: column; gap: 9px; }
.signin-form label { font-weight: 700; }
.field-stack { display: flex; flex-direction: column; gap: 3px; }

.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.avatar-cell {
  border: 2px solid transparent; border-radius: 4px; padding: 2px;
  background: var(--content-bg); cursor: pointer;
  display: grid; place-items: center;
  border: 1px solid var(--face-line);
}
.avatar-cell :is(svg, img) { width: 30px; height: 30px; display: block; }
.avatar-cell[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 0; background: var(--accent-soft); }

.form-error { color: #c22a12; font-weight: 700; min-height: 13px; }
body[data-theme="midnight"] .form-error { color: #ff8f76; }

/* --- Contact list window --------------------------------------------------------------- */

.cl-banner {
  background: var(--banner-grad);
  border-bottom: 1px solid var(--banner-line);
  padding: 8px;
  display: flex; gap: 8px; align-items: center;
}
.avatar-tile {
  flex: 0 0 auto;
  background: var(--content-bg);
  border: 1px solid var(--face-line);
  border-radius: 4px;
  padding: 2px;
  box-shadow: 1px 1px 3px rgba(0,20,60,.25), inset 0 0 0 1px #fff;
  position: relative;
}
body[data-theme="midnight"] .avatar-tile { box-shadow: 1px 1px 3px rgba(0,0,0,.5); }
.avatar-tile :is(svg, img) { display: block; }
.avatar-tile .status-dot { position: absolute; right: -4px; bottom: -4px; width: 13px; height: 13px; }
.avatar-tile .status-dot :is(svg, img) { width: 13px; height: 13px; }

.cl-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cl-name-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.cl-name-btn {
  background: none; border: 1px solid transparent; cursor: pointer;
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; gap: 4px; min-width: 0;
  padding: 1px 3px; border-radius: 2px;
  color: var(--text);
}
.cl-name-btn:hover { border-color: var(--field-border); background: var(--content-bg); }
.cl-name-btn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psm-input {
  background: none; border: 1px solid transparent;
  font-style: italic; color: var(--text-dim);
  width: 100%; padding: 1px 3px; border-radius: 2px;
}
.psm-input:hover { border-color: var(--field-border); }
.psm-input:focus { background: var(--content-bg); border-color: var(--field-border); font-style: normal; color: var(--text); outline: none; }

.cl-tools { display: flex; gap: 4px; padding: 5px 7px; align-items: center; border-bottom: 1px solid var(--face-line); }
.cl-tools .xp-field { flex: 1; min-width: 0; }
.icon-btn {
  background: var(--btn-grad); border: 1px solid var(--btn-border); border-radius: 3px;
  width: 24px; height: 22px; display: grid; place-items: center; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.icon-btn :is(svg, img) { width: 14px; height: 14px; }
.icon-btn:hover { box-shadow: inset 0 0 0 1.5px #f8b64a66; }
.icon-btn:active { background: var(--face-dark); }
.icon-btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

.cl-list { flex: 1; overflow-y: auto; background: var(--content-bg); border: 1px solid var(--field-border); margin: 0 3px; }
.cl-section { border: none; background: none; width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px; font-weight: 700; color: var(--accent);
}
.cl-section:hover { text-decoration: underline; }
.cl-section .tri { font-size: 8px; width: 10px; color: var(--text-dim); }
.cl-section .pmbox {
  width: 11px; height: 11px; flex: 0 0 auto;
  border: 1px solid var(--field-border); background: var(--content-bg);
  color: var(--text); font-size: 10px; line-height: 9px; text-align: center;
  font-family: monospace;
}
.contact-row {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 6px;
  border: none; background: none; cursor: pointer;
  padding: 3px 6px 3px 18px;
}
.contact-row:hover { background: var(--accent-soft); }
.contact-row .st { flex: 0 0 auto; width: 16px; height: 16px; }
.contact-row .st :is(svg, img) { width: 16px; height: 16px; display: block; }
.contact-row .cname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-row .cname b.unread { color: #c25200; }
.contact-row .cpsm { color: var(--text-dim); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.contact-row.offline .cname, .contact-row.offline .cpsm { color: var(--text-dim); }
.contact-row .fav { color: #e8a800; }
.empty-note { padding: 10px 12px; color: var(--text-dim); font-style: italic; line-height: 1.5; }
.empty-note :is(svg, img) { width: 14px; height: 14px; vertical-align: -3px; }

.cl-footer {
  padding: 4px 8px; display: flex; align-items: center; gap: 6px;
  color: var(--text-dim);
}
.cl-footer .grow { flex: 1; }

.req-strip {
  background: #fff5d7; border: 1px solid #e3c76a; border-radius: 3px;
  margin: 4px 3px; padding: 6px 8px;
  display: flex; flex-direction: column; gap: 5px;
  color: #3c2f00;
}
body[data-theme="midnight"] .req-strip { background: #3a3315; border-color: #6b5a1e; color: #f0e3ae; }
.req-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.req-row .who { font-weight: 700; }
.req-actions { display: flex; gap: 4px; margin-left: auto; }
.req-actions .xp-btn { padding: 2px 9px; }

/* --- Chat window --------------------------------------------------------------------------- */

.chat-head {
  background: var(--banner-grad); border-bottom: 1px solid var(--banner-line);
  padding: 6px 8px; display: flex; align-items: center; gap: 8px;
}
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who .nm { font-weight: 700; font-size: 12px; display: flex; align-items: center; gap: 5px; }
.chat-head .who .nm .st-inline :is(svg, img) { width: 13px; height: 13px; }
.chat-head .who .ps { color: var(--text-dim); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-log-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  background: var(--chat-bg);
  border: 1px solid var(--field-border);
  padding: 6px 8px;
  overscroll-behavior: contain;
}
.chat-log.bg-clouds { background-image: radial-gradient(ellipse 60px 24px at 18% 12%, #dfeefd 60%, transparent 61%), radial-gradient(ellipse 80px 30px at 78% 30%, #e7f2fd 60%, transparent 61%); background-attachment: local; }
.chat-log.bg-hearts { background-image: radial-gradient(circle 5px at 24px 24px, #ffd9e8 90%, transparent), radial-gradient(circle 5px at 33px 24px, #ffd9e8 90%, transparent); background-size: 90px 70px; }
.chat-log.bg-grid { background-image: linear-gradient(var(--accent-soft) 1px, transparent 1px), linear-gradient(90deg, var(--accent-soft) 1px, transparent 1px); background-size: 22px 22px; }
body[data-theme="midnight"] .chat-log.bg-clouds { background-image: radial-gradient(ellipse 60px 24px at 18% 12%, #26314e 60%, transparent 61%), radial-gradient(ellipse 80px 30px at 78% 30%, #232e4a 60%, transparent 61%); }
body[data-theme="midnight"] .chat-log.bg-hearts { background-image: radial-gradient(circle 5px at 24px 24px, #3a2a3c 90%, transparent), radial-gradient(circle 5px at 33px 24px, #3a2a3c 90%, transparent); }

.msg-group { margin: 5px 0; display: flex; gap: 7px; }
.msg-group .g-avatar { flex: 0 0 auto; width: 34px; }
.msg-group .g-avatar .avatar-tile { padding: 1px; }
.msg-group .g-avatar :is(svg, img) { width: 28px; height: 28px; }
.msg-group .g-body { flex: 1; min-width: 0; }
.msg-meta { color: var(--text-dim); margin-bottom: 2px; }
.msg-meta .mname { font-weight: 700; color: var(--accent); }
.msg-meta .mname.mod::after { content: " ★mod"; color: #c98a00; font-size: 9px; }
.msg-line { padding: 2px 5px; border-radius: 3px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; position: relative; }
.msg-line:hover { background: var(--accent-soft); }
.msg-line .t { color: var(--text-dim); font-size: 9px; margin-left: 6px; }
.msg-group.mine .msg-line { background: var(--msg-me); }
.msg-group.mine .msg-line:hover { background: var(--accent-soft); }
.msg-line.pending { opacity: .55; }
.msg-line.failed { background: #fde4de; }
body[data-theme="midnight"] .msg-line.failed { background: #4c221a; }
.msg-line .retry { color: #c22a12; font-weight: 700; }
.msg-line.deleted { color: var(--text-dim); font-style: italic; }
.msg-line img.emoticon, .msg-line :is(svg, img).emoticon { width: 18px; height: 18px; vertical-align: -4px; }

.sys-line {
  text-align: center; color: var(--text-dim); font-style: italic;
  margin: 6px 12px; padding: 2px;
  border-top: 1px dotted var(--face-line); border-bottom: 1px dotted var(--face-line);
}
.nudge-line { text-align: center; font-weight: 700; color: #b96a00; margin: 6px 0; }
.nudge-line :is(svg, img), .sys-line :is(svg, img), .pinned-strip .pin-ico :is(svg, img), .cl-footer :is(svg, img), .req-strip :is(svg, img) {
  width: 14px; height: 14px; vertical-align: -3px;
}
body[data-theme="midnight"] .nudge-line { color: #f0b45e; }

.newmsg-chip {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: #316ac5; color: #fff; border: 1px solid #fff;
  border-radius: 10px; padding: 3px 12px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,20,80,.4);
  font-weight: 700;
}

.typing-line { min-height: 15px; padding: 1px 6px; color: var(--text-dim); font-style: italic; }
.chat-status {
  margin: 2px 3px 0;
  border: 1px solid var(--face-line);
  background: var(--face-dark);
  box-shadow: inset 1px 1px 2px rgba(60,60,40,.18);
  min-height: 17px; line-height: 15px;
  border-radius: 2px;
}

/* display-picture rail (classic DM layout: theirs top, yours bottom) */
.dp-rail {
  flex: 0 0 104px;
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 2px;
}
.dp-rail .dp-gap { flex: 1; }
.dp-frame {
  width: 92px; height: 92px;
  background: var(--content-bg);
  border: 1px solid var(--face-line);
  border-radius: 4px;
  padding: 4px;
  box-shadow: 1px 2px 4px rgba(0,20,60,.25), inset 0 0 0 1px #fff;
  display: grid; place-items: center;
}
body[data-theme="midnight"] .dp-frame { box-shadow: 1px 2px 4px rgba(0,0,0,.5); }
.dp-frame img, .dp-frame :is(svg, img) { width: 82px; height: 82px; display: block; border-radius: 2px; }
.chat-head .to-label { color: var(--text-dim); font-weight: 400; }

.chat-toolbar {
  display: flex; gap: 3px; align-items: center;
  padding: 3px 2px;
}
.chat-toolbar .spacer { flex: 1; }
.nudge-cd { color: var(--text-dim); font-size: 10px; min-width: 26px; text-align: center; }

.composer { display: flex; gap: 4px; align-items: stretch; }
.composer textarea {
  flex: 1; resize: none; height: 46px;
  border: 1px solid var(--field-border); background: var(--content-bg); color: var(--text);
  padding: 5px 6px;
}
.composer .send-col { display: flex; flex-direction: column; gap: 3px; }
.composer .send-col .xp-btn { flex: 1; min-width: 62px; }

.charcount { text-align: right; color: var(--text-dim); font-size: 9px; padding: 1px 4px 0; }
.charcount.over { color: #c22a12; font-weight: 700; }

/* member list (lounge) */
.lounge-split { flex: 1; display: flex; gap: 4px; min-height: 0; }
.lounge-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.member-list {
  flex: 0 0 132px; display: flex; flex-direction: column;
  border: 1px solid var(--field-border); background: var(--content-bg);
  min-height: 0;
}
.member-list h3 {
  font-size: 10px; padding: 4px 6px; background: var(--banner-grad);
  border-bottom: 1px solid var(--banner-line); color: var(--text);
}
.member-scroll { flex: 1; overflow-y: auto; }
.member-row { display: flex; align-items: center; gap: 4px; padding: 2px 6px; width: 100%; border: none; background: none; text-align: left; cursor: pointer; }
.member-row:hover { background: var(--accent-soft); }
.member-row :is(svg, img) { width: 13px; height: 13px; flex: 0 0 auto; }
.member-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pinned-strip {
  background: #fdf6dd; border: 1px solid #e0cd82; color: #4a3b00;
  padding: 5px 8px; margin-bottom: 3px; border-radius: 3px;
  display: flex; gap: 6px; align-items: baseline;
}
body[data-theme="midnight"] .pinned-strip { background: #33301c; border-color: #5c5426; color: #ede0a8; }
.pinned-strip .pin-ico { flex: 0 0 auto; }

/* --- Emoticon picker / menus ------------------------------------------------------------------ */

.popover {
  position: fixed; z-index: 6000;
  background: var(--face);
  border: 1px solid var(--win-border);
  border-radius: 3px;
  box-shadow: 3px 3px 8px rgba(0,10,40,.4);
  padding: 4px;
}
.emo-grid { display: grid; grid-template-columns: repeat(6, 26px); gap: 2px; }
.emo-grid button, .wink-list button { background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer; display: grid; place-items: center; padding: 2px; }
.emo-grid button:hover, .wink-list button:hover { border-color: var(--accent); background: var(--accent-soft); }
.emo-grid :is(svg, img) { width: 19px; height: 19px; display: block; }
.wink-list { display: flex; flex-direction: column; }
.wink-list button { display: flex; gap: 6px; align-items: center; justify-content: flex-start; padding: 4px 8px; width: 100%; }
.wink-list :is(svg, img) { width: 20px; height: 20px; }

.ctx-menu {
  position: fixed; z-index: 6500;
  min-width: 160px;
  background: var(--face);
  border: 1px solid var(--face-line);
  box-shadow: 3px 3px 6px rgba(0,10,40,.35);
  padding: 2px;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  padding: 4px 18px 4px 22px; border: none; background: none; cursor: pointer;
  color: var(--text);
}
.ctx-menu button:hover:not(:disabled) { background: var(--sel-bg); color: var(--sel-text); }
.ctx-menu button:disabled { color: var(--text-dim); }
.ctx-menu .sep { border-top: 1px solid var(--face-line); margin: 2px 4px; }

/* --- Toast notifications ------------------------------------------------------------------------- */

#toasts {
  position: absolute; right: 10px; bottom: 8px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 4500;
  width: 230px;
}
.toast {
  background: var(--banner-grad);
  border: 1px solid var(--win-border);
  border-radius: 6px 6px 3px 3px;
  box-shadow: 2px 3px 10px rgba(0,10,50,.45);
  overflow: hidden;
  cursor: pointer;
  animation: toast-in .28s ease-out;
  text-align: left;
  padding: 0;
}
@keyframes toast-in { from { transform: translateY(30px); opacity: 0; } }
.toast .t-title {
  background: var(--title-grad); color: var(--title-text);
  font-weight: 700; padding: 3px 8px; font-family: var(--font-brand); font-size: 11px;
  display: flex; justify-content: space-between; align-items: center;
}
.toast .t-title .x { cursor: pointer; padding: 0 3px; background: none; border: none; color: inherit; font-weight: 700; }
.toast .t-body { padding: 7px 9px; display: flex; gap: 7px; align-items: center; color: var(--text); }
.toast .t-body :is(svg, img) { width: 24px; height: 24px; flex: 0 0 auto; }
.toast .t-body .txt { min-width: 0; }
.toast .t-body .txt b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast .t-body .txt span { color: var(--text-dim); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Winks (fullscreen-in-window animations) ------------------------------------------------------ */

.wink-stage {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 30;
}
.wink-stage.dismissible { pointer-events: auto; cursor: pointer; }
.wink-sprite { position: absolute; }
.wink-sprite :is(svg, img) { width: 48px; height: 48px; filter: drop-shadow(0 2px 3px rgba(0,10,40,.3)); }
.wink-heart { animation: wink-heart 2.6s ease-in-out forwards; left: 10%; bottom: -50px; }
@keyframes wink-heart {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { opacity: 1; }
  50% { transform: translateY(-46vh) translateX(40px) scale(1.1) rotate(-8deg); }
  100% { transform: translateY(-92vh) translateX(-10px) scale(.9) rotate(6deg); opacity: 0; }
}
.wink-rocket { animation: wink-rocket 2.2s cubic-bezier(.5,.1,.8,.4) forwards; left: 18%; bottom: -60px; }
@keyframes wink-rocket {
  0% { transform: translate(0,0) rotate(-4deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(50vw, -110vh) rotate(8deg); opacity: 1; }
}
.wink-wave { animation: wink-wave 2.8s ease-in-out forwards; left: calc(50% - 24px); bottom: -56px; }
@keyframes wink-wave {
  0% { transform: translateY(0); }
  20% { transform: translateY(-70px); }
  30% { transform: translateY(-64px) rotate(-8deg); }
  40% { transform: translateY(-70px) rotate(8deg); }
  50% { transform: translateY(-64px) rotate(-8deg); }
  60% { transform: translateY(-70px) rotate(8deg); }
  80% { transform: translateY(-66px) rotate(0); opacity: 1; }
  100% { transform: translateY(10px); opacity: 0; }
}
.wink-moon { animation: wink-moon 3.2s ease-in-out forwards; left: -60px; top: 12%; }
@keyframes wink-moon {
  0% { transform: translateX(0) rotate(0); opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { transform: translateX(calc(100vw)) rotate(30deg); opacity: 0; }
}

/* window shake (nudge) */
@keyframes win-shake {
  0%, 100% { translate: 0 0; }
  10% { translate: -7px 3px; } 20% { translate: 6px -4px; }
  30% { translate: -5px -3px; } 40% { translate: 7px 4px; }
  50% { translate: -6px 2px; } 60% { translate: 5px -3px; }
  70% { translate: -4px 4px; } 80% { translate: 6px -2px; } 90% { translate: -3px 1px; }
}
.win.shaking { animation: win-shake .55s linear 2; }
.win.nudge-flash { animation: nudge-flash 1.4s ease-out; }
@keyframes nudge-flash {
  0%, 40% { box-shadow: 0 0 0 3px #ffb900, 2px 4px 14px rgba(0,10,40,.45); }
  100% { box-shadow: 2px 4px 14px rgba(0,10,40,.45); }
}

/* --- Dialogs (modal) --------------------------------------------------------------------------------- */

.modal-veil { position: fixed; inset: 0; z-index: 5800; background: rgba(10,20,50,.25); display: grid; place-items: center; }
.modal { min-width: 280px; max-width: 92vw; position: static; }

/* --- Welcome wizard / profile / appearance ------------------------------------------------------------ */

.pad { padding: 10px 12px; overflow-y: auto; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row .grow { flex: 1; }
.theme-swatch {
  width: 72px; height: 44px; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--face-line); overflow: hidden; position: relative;
  padding: 0;
}
.theme-swatch .bar { height: 12px; }
.theme-swatch[aria-pressed="true"] { outline: 2px solid var(--accent); }
.theme-swatch span { position: absolute; bottom: 2px; left: 4px; font-size: 9px; text-shadow: 0 0 3px #fff; }
.check-row { display: flex; align-items: flex-start; gap: 6px; }
.check-row input { margin-top: 1px; }
.check-row label { line-height: 1.4; }

.profile-card-head {
  background: var(--banner-grad); border-bottom: 1px solid var(--banner-line);
  display: flex; gap: 10px; padding: 12px; align-items: center;
}
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 4px 8px; }
.kv dt { color: var(--text-dim); }
.kv dd { word-break: break-word; }

/* help window */
.help-body { line-height: 1.55; }
.help-body h3 { font-size: 12px; margin: 10px 0 3px; color: var(--accent); }
.help-body p, .help-body li { margin-bottom: 4px; }
.help-body ul { padding-left: 18px; }
kbd {
  background: var(--content-bg); border: 1px solid var(--face-line); border-bottom-width: 2px;
  border-radius: 3px; padding: 0 4px; font-family: var(--font-ui); font-size: 10px;
}

/* --- Reduced motion ------------------------------------------------------------------------------------- */

body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --- Mobile -------------------------------------------------------------------------------------------- */

@media (max-width: 720px), (pointer: coarse) and (max-width: 1024px) {
  :root { --taskbar-h: 46px; }
  body { font-size: 13px; }
  button, input, textarea, select { font-size: 14px; }
  body.has-windows #desktop-icons { display: none; }

  .win {
    position: fixed !important;
    inset: 0 0 var(--taskbar-h) 0 !important;
    width: auto !important; height: auto !important;
    border-radius: 0; border: none;
  }
  .win.minimized-mobile { display: none; }
  .win-title { height: 40px; border-radius: 0; padding: 0 8px; }
  .win-title h2 { font-size: 15px; }
  .win-btn { width: 32px; height: 32px; }
  .win-btn.max { display: none; }
  .win-btn.min { display: none; }

  .task-btn { flex: 0 0 auto; max-width: 120px; height: 34px; }
  #start-button { font-size: 17px; }
  .desk-icon { width: 96px; }

  .dp-rail { display: none; }
  .contact-row { padding: 9px 8px 9px 14px; }
  .contact-row .st, .contact-row .st :is(svg, img) { width: 18px; height: 18px; }
  .cl-section { padding: 8px; }
  .member-list { display: none; }
  .composer textarea { height: 54px; font-size: 16px; } /* 16px stops iOS zoom */
  .icon-btn { width: 36px; height: 34px; }
  .icon-btn :is(svg, img) { width: 18px; height: 18px; }
  .win-btn :is(svg, img) { width: 15px; height: 15px; }
  .xp-btn { padding: 8px 16px; }
  #toasts { width: 78vw; }
  .avatar-grid { grid-template-columns: repeat(4, 1fr); }
  .avatar-cell :is(svg, img) { width: 40px; height: 40px; }
  .emo-grid { grid-template-columns: repeat(6, 38px); }
  .emo-grid :is(svg, img) { width: 26px; height: 26px; }
  .msg-line .t { font-size: 10px; }
}

/* Desktop edge/corner resizing. Phone windows keep their full-screen layout. */
.win-resize{position:absolute;z-index:25;touch-action:none;border:0!important;padding:0!important;margin:0;background:transparent!important;box-shadow:none!important;border-radius:0!important}
.win-resize-n{top:-3px;left:10px;right:10px;height:7px;cursor:n-resize}
.win-resize-s{bottom:-3px;left:10px;right:10px;height:7px;cursor:s-resize}
.win-resize-e{right:-3px;top:10px;bottom:10px;width:7px;cursor:e-resize}
.win-resize-w{left:-3px;top:10px;bottom:10px;width:7px;cursor:w-resize}
.win-resize-ne,.win-resize-nw,.win-resize-sw,.win-resize-se{width:12px;height:12px}
.win-resize-ne{right:-3px;top:-3px;cursor:ne-resize}.win-resize-nw{left:-3px;top:-3px;cursor:nw-resize}.win-resize-sw{left:-3px;bottom:-3px;cursor:sw-resize}.win-resize-se{right:0;bottom:0;cursor:se-resize}
.win-resize-se::after{content:"";position:absolute;inset:3px 1px 1px 3px;background:repeating-linear-gradient(135deg,transparent 0 2px,#7d8aab 2px 3px,#fff9 3px 4px);clip-path:polygon(100% 0,100% 100%,0 100%)}
.win-resize-se:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.win.maximized>.win-resize{display:none}
body.wm-interacting,body.wm-interacting *{cursor:var(--wm-cursor)!important;user-select:none!important}
.chat-window .win-body,.chat-log-wrap,.chat-log,.composer textarea{min-width:0}
@media(max-width:720px),(pointer:coarse) and (max-width:1024px){.win>.win-resize{display:none}}
