:root {
  --font-main: 'IBM Plex Mono', monospace;
  --radius: 12px;
  --radius-sm: 6px;
  --transition: 0.18s ease;
}

body.theme-cozy {
  --bg: #faf6f1;
  --bg2: #f0e9df;
  --bg3: #e8ddd0;
  --surface: #fff9f4;
  --surface2: #f5ede3;
  --border: #d9c9b8;
  --border2: #c9b59f;
  --text: #3d2b1f;
  --text2: #7a5c46;
  --text3: #a8896e;
  --accent: #c2734a;
  --accent2: #e8936b;
  --user-bg: #c2734a;
  --user-text: #fff9f4;
  --ai-bg: #f5ede3;
  --ai-text: #3d2b1f;
  --led-ready: #6bbf72;
  --led-gen: #e8b84b;
  --led-stop: #e05a5a;
  --input-bg: #fff9f4;
  --scrollbar: #d9c9b8;
  background: var(--bg);
  font-family: 'Crimson Pro', Georgia, serif;
  --font-main: 'Crimson Pro', Georgia, serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 17px;
}

body.theme-win98 {
  --bg: #008080;
  --bg2: #006868;
  --bg3: #005050;
  --surface: #d4d0c8;
  --surface2: #c0c0c0;
  --border: #808080;
  --border2: #404040;
  --text: #000000;
  --text2: #404040;
  --text3: #606060;
  --accent: #000080;
  --accent2: #1084d0;
  --user-bg: #000080;
  --user-text: #ffffff;
  --ai-bg: #d4d0c8;
  --ai-text: #000000;
  --led-ready: #00c800;
  --led-gen: #ffff00;
  --led-stop: #ff0000;
  --input-bg: #ffffff;
  background: var(--bg);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  --font-main: 'Share Tech Mono', 'Courier New', monospace;
  --font-mono: 'Share Tech Mono', monospace;
  --font-size-base: 14px;
  --radius: 0px;
  --radius-sm: 0px;
}
body.theme-win98 * { image-rendering: pixelated; }

body.theme-pixel {
  --bg: #0d0118;
  --bg2: #130224;
  --bg3: #1a0430;
  --surface: #110120;
  --surface2: #1c0535;
  --border: #6a0dad;
  --border2: #00e5ff;
  --text: #f0e6ff;
  --text2: #c89cf0;
  --text3: #7a50a8;
  --accent: #e040fb;
  --accent2: #00e5ff;
  --user-bg: linear-gradient(135deg, #e040fb, #7b2ff7);
  --user-text: #ffffff;
  --ai-bg: #1c0535;
  --ai-text: #f0e6ff;
  --led-ready: #00e5ff;
  --led-gen: #e040fb;
  --led-stop: #ff1744;
  --input-bg: #110120;
  background: var(--bg);
  font-family: 'Press Start 2P', monospace;
  --font-main: 'Press Start 2P', monospace;
  --font-mono: 'Press Start 2P', monospace;
  --font-size-base: 10px;
  --radius: 2px;
  --radius-sm: 2px;
}

body.theme-pixel .msg-text { line-height: 2.2; }
body.theme-pixel .msg-bubble { font-size: 8px; }
body.theme-pixel .opt-label { font-size: 8px; }
body.theme-pixel .opt-select, body.theme-pixel .opt-input { font-size: 8px; }
body.theme-pixel .theme-btn { font-size: 7px; padding: 5px 2px; }
body.theme-pixel #user-input { font-size: 9px; }
body.theme-pixel .modal-box h2 { font-size: 10px; }
body.theme-pixel .modal-box p { font-size: 8px; }
body.theme-pixel .modal-btn { font-size: 9px; }
body.theme-pixel #logo { font-size: 12px !important; }

body.theme-terminal {
  --bg: #0d0d0d;
  --bg2: #111111;
  --bg3: #161616;
  --surface: #0d0d0d;
  --surface2: #111111;
  --border: #1aff6e;
  --border2: #00ff41;
  --text: #00ff41;
  --text2: #1aff6e;
  --text3: #0aaa3c;
  --accent: #00ff41;
  --accent2: #1aff6e;
  --user-bg: #003300;
  --user-text: #00ff41;
  --ai-bg: #0d0d0d;
  --ai-text: #00ff41;
  --led-ready: #00ff41;
  --led-gen: #ffff00;
  --led-stop: #ff0000;
  --input-bg: #0d0d0d;
  background: var(--bg);
  font-family: 'VT323', 'Share Tech Mono', monospace;
  --font-main: 'VT323', monospace;
  --font-mono: 'VT323', monospace;
  --font-size-base: 20px;
}
body.theme-terminal * { text-shadow: 0 0 2px var(--text3); }
body.theme-terminal input, body.theme-terminal textarea, body.theme-terminal select { text-shadow: none; }

body.theme-dark {
  --bg: #000000;
  --bg2: #0a0a0a;
  --bg3: #111111;
  --surface: #111111;
  --surface2: #1a1a1a;
  --border: #2a2a2a;
  --border2: #3a3a3a;
  --text: #ffffff;
  --text2: #b0b0b0;
  --text3: #666666;
  --accent: #ffffff;
  --accent2: #cccccc;
  --user-bg: #ffffff;
  --user-text: #000000;
  --ai-bg: #1a1a1a;
  --ai-text: #ffffff;
  --led-ready: #4ade80;
  --led-gen: #facc15;
  --led-stop: #f87171;
  --input-bg: #111111;
  --scrollbar: #ffffff;
  background: var(--bg);
  font-family: 'IBM Plex Mono', monospace;
  --font-main: 'IBM Plex Mono', monospace;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 13px;
}

body.theme-coffee {
  --bg: #1c1007;
  --bg2: #251608;
  --bg3: #2e1c0a;
  --surface: #1e1208;
  --surface2: #2a1a0c;
  --border: #4a3020;
  --border2: #5e3e28;
  --text: #f5deb3;
  --text2: #c8a87a;
  --text3: #8a6a44;
  --accent: #d4843e;
  --accent2: #e8a05a;
  --user-bg: #c4712c;
  --user-text: #fff8f0;
  --ai-bg: #2a1a0c;
  --ai-text: #f5deb3;
  --led-ready: #7ec850;
  --led-gen: #e8c050;
  --led-stop: #e05050;
  --input-bg: #1e1208;
  --scrollbar: #4a3020;
  background: var(--bg);
  font-family: 'Crimson Pro', Georgia, serif;
  --font-main: 'Crimson Pro', Georgia, serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 17px;
}

body.theme-pistachio {
  --bg: #f0f7ec;
  --bg2: #e4f0dd;
  --bg3: #d4e8ca;
  --surface: #f7fbf5;
  --surface2: #e8f4e2;
  --border: #b8d9a8;
  --border2: #9eca8c;
  --text: #1e3a18;
  --text2: #3d6635;
  --text3: #6a9b5e;
  --accent: #4a8c3a;
  --accent2: #64a850;
  --user-bg: #4a8c3a;
  --user-text: #f0fbec;
  --ai-bg: #e8f4e2;
  --ai-text: #1e3a18;
  --led-ready: #4ade80;
  --led-gen: #a3e635;
  --led-stop: #f87171;
  --input-bg: #f7fbf5;
  --scrollbar: #b8d9a8;
  background: var(--bg);
  font-family: 'IBM Plex Mono', monospace;
  --font-main: 'IBM Plex Mono', monospace;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 13px;
}

body.theme-lofi {
  --bg: #f5f0e8;
  --bg2: #ede5d8;
  --bg3: #e0d5c5;
  --surface: #faf7f2;
  --surface2: #ede5d8;
  --border: #c8b89a;
  --border2: #b8a080;
  --text: #2a2018;
  --text2: #5a4838;
  --text3: #9a8068;
  --accent: #7c5c3a;
  --accent2: #a07850;
  --user-bg: #7c5c3a;
  --user-text: #faf7f2;
  --ai-bg: #ede5d8;
  --ai-text: #2a2018;
  --led-ready: #88b868;
  --led-gen: #d4b050;
  --led-stop: #c86050;
  --input-bg: #faf7f2;
  --scrollbar: #c8b89a;
  background: var(--bg);
  font-family: 'Crimson Pro', Georgia, serif;
  --font-main: 'Crimson Pro', Georgia, serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 17px;
  --radius: 8px;
  --radius-sm: 4px;
}

body.theme-glass {
  --bg: transparent;
  --bg2: rgba(255,255,255,0.08);
  --bg3: rgba(255,255,255,0.12);
  --surface: rgba(255,255,255,0.12);
  --surface2: rgba(255,255,255,0.18);
  --border: rgba(255,255,255,0.25);
  --border2: rgba(255,255,255,0.4);
  --text: #ffffff;
  --text2: rgba(255,255,255,0.75);
  --text3: rgba(255,255,255,0.45);
  --accent: rgba(255,255,255,0.9);
  --accent2: rgba(200,220,255,0.9);
  --user-bg: rgba(255,255,255,0.22);
  --user-text: #ffffff;
  --ai-bg: rgba(255,255,255,0.1);
  --ai-text: #ffffff;
  --led-ready: #4ade80;
  --led-gen: #facc15;
  --led-stop: #f87171;
  --input-bg: rgba(255,255,255,0.1);
  --scrollbar: rgba(255,255,255,0.2);
  font-family: 'IBM Plex Mono', monospace;
  --font-main: 'IBM Plex Mono', monospace;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 13px;
}
body.theme-glass {
  background:
    radial-gradient(ellipse at 20% 20%, rgba(120,80,255,0.45) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(0,180,255,0.4) 0%, transparent 55%),
    radial-gradient(ellipse at 60% 10%, rgba(255,80,180,0.35) 0%, transparent 50%),
    #0a0a18;
  background-attachment: fixed;
}
body.theme-glass #app,
body.theme-glass #topbar,
body.theme-glass #options-panel,
body.theme-glass #input-area,
body.theme-glass #sidebar,
body.theme-glass .modal-box {
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
}
body.theme-glass #app { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.18); }
body.theme-glass #topbar { background: rgba(255,255,255,0.1); border-bottom: 1px solid rgba(255,255,255,0.15); }
body.theme-glass #input-area { background: rgba(255,255,255,0.1); border-top: 1px solid rgba(255,255,255,0.18); }
body.theme-glass #user-input { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); color: #fff; }
body.theme-glass #user-input:focus { border-color: rgba(255,255,255,0.6); }
body.theme-glass #send-btn { background: rgba(255,255,255,0.25); border: 1px solid rgba(255,255,255,0.4); color: #fff; }
body.theme-glass #send-btn:hover { background: rgba(255,255,255,0.35); }
body.theme-glass .msg-bubble { backdrop-filter: blur(8px); }
body.theme-glass .msg-bubble.user { background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.35); }
body.theme-glass .msg-bubble.ai { background: rgba(255,255,255,0.09); border: 1px solid rgba(255,255,255,0.18); }
body.theme-glass .theme-btn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.8); }
body.theme-glass .theme-btn:hover, body.theme-glass .theme-btn.active { background: rgba(255,255,255,0.3); border-color: rgba(255,255,255,0.5); color: #fff; }
body.theme-glass .opt-select, body.theme-glass .opt-input { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); color: #fff; }
body.theme-glass #messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); }

body.theme-cyberpunk {
  --bg: #050010;
  --bg2: #08001a;
  --bg3: #0c0020;
  --surface: #06001a;
  --surface2: #0e0028;
  --border: #ff00aa;
  --border2: #00f0ff;
  --text: #f0e0ff;
  --text2: #c080f0;
  --text3: #7030a0;
  --accent: #ff00aa;
  --accent2: #00f0ff;
  --user-bg: linear-gradient(135deg, #ff00aa, #aa00ff);
  --user-text: #ffffff;
  --ai-bg: #0e0028;
  --ai-text: #f0e0ff;
  --led-ready: #00f0ff;
  --led-gen: #ff00aa;
  --led-stop: #ff3030;
  --input-bg: #080018;
  --scrollbar: #aa00ff;
  background: var(--bg);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  --font-main: 'Share Tech Mono', monospace;
  --font-mono: 'Share Tech Mono', monospace;
  --font-size-base: 13px;
  --radius: 0px;
  --radius-sm: 0px;
}
body.theme-cyberpunk #app { border: 1px solid #ff00aa; box-shadow: 0 0 30px rgba(255,0,170,0.2), inset 0 0 30px rgba(0,240,255,0.03); }
body.theme-cyberpunk #topbar { background: #06001a; border-bottom: 2px solid #ff00aa; box-shadow: 0 2px 20px rgba(255,0,170,0.4); }
body.theme-cyberpunk #logo { color: #00f0ff !important; text-shadow: 0 0 10px #00f0ff, 0 0 20px #00f0ff; letter-spacing: 6px; }
body.theme-cyberpunk #input-area { border-top: 2px solid #ff00aa; background: #06001a; }
body.theme-cyberpunk #user-input { border: 1px solid #ff00aa; background: #060012; color: #f0e0ff; caret-color: #00f0ff; }
body.theme-cyberpunk #user-input:focus { border-color: #00f0ff; box-shadow: 0 0 10px rgba(0,240,255,0.3); }
body.theme-cyberpunk #send-btn { background: #ff00aa; color: #fff; box-shadow: 0 0 12px rgba(255,0,170,0.6); }
body.theme-cyberpunk #send-btn:hover { background: #cc0088; box-shadow: 0 0 20px rgba(255,0,170,0.9); }
body.theme-cyberpunk .msg-bubble.user { background: linear-gradient(135deg, #ff00aa22, #aa00ff22); border: 1px solid #ff00aa; box-shadow: 0 0 8px rgba(255,0,170,0.3); }
body.theme-cyberpunk .msg-bubble.ai { background: #0c0022; border: 1px solid #00f0ff44; }
body.theme-cyberpunk .theme-btn { border-color: #ff00aa44; color: #c080f0; background: #0a0020; }
body.theme-cyberpunk .theme-btn:hover, body.theme-cyberpunk .theme-btn.active { background: #ff00aa; color: #fff; border-color: #ff00aa; box-shadow: 0 0 10px rgba(255,0,170,0.5); }
body.theme-cyberpunk .opt-select, body.theme-cyberpunk .opt-input { background: #060012; border-color: #ff00aa44; color: #f0e0ff; }
body.theme-cyberpunk::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255,0,170,0.015) 3px, rgba(255,0,170,0.015) 4px);
  pointer-events: none;
  z-index: 9999;
}
body.theme-cyberpunk #messages::-webkit-scrollbar-thumb { background: #ff00aa; box-shadow: 0 0 6px #ff00aa; }
body.theme-cyberpunk .modal-box { border: 2px solid #ff00aa; box-shadow: 0 0 30px rgba(255,0,170,0.4); }

body.theme-banana {
  --bg: #fef9c3;
  --bg2: #fef08a;
  --bg3: #fde047;
  --surface: #fefce8;
  --surface2: #fef9c3;
  --border: #eab308;
  --border2: #ca8a04;
  --text: #1c1400;
  --text2: #713f12;
  --text3: #a16207;
  --accent: #ca8a04;
  --accent2: #eab308;
  --user-bg: #ca8a04;
  --user-text: #fefce8;
  --ai-bg: #fef9c3;
  --ai-text: #1c1400;
  --led-ready: #4ade80;
  --led-gen: #f97316;
  --led-stop: #ef4444;
  --input-bg: #fefce8;
  --scrollbar: #fde047;
  background: var(--bg);
  font-family: 'IBM Plex Mono', monospace;
  --font-main: 'IBM Plex Mono', monospace;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 13px;
}
body.theme-banana #app { background: #fefce8; }
body.theme-banana #topbar { background: #fef08a; border-bottom: 2px solid #eab308; }
body.theme-banana #logo { color: #92400e !important; }
body.theme-banana #send-btn { background: #ca8a04; color: #fefce8; }
body.theme-banana .msg-bubble.user { background: #ca8a04; color: #fefce8; }
body.theme-banana .msg-bubble.ai { background: #fef9c3; border: 1px solid #eab308; }
body.theme-banana .theme-btn { background: #fef9c3; border-color: #eab308; color: #713f12; }
body.theme-banana .theme-btn:hover, body.theme-banana .theme-btn.active { background: #ca8a04; color: #fefce8; border-color: #ca8a04; }
body.theme-banana #user-input { background: #fefce8; border-color: #eab308; color: #1c1400; }
body.theme-banana #user-input:focus { border-color: #ca8a04; }
body.theme-banana #input-area { background: #fef9c3; border-top: 2px solid #eab308; }
body.theme-banana #messages::-webkit-scrollbar-thumb { background: #eab308; }
body.theme-banana .opt-select, body.theme-banana .opt-input { background: #fefce8; border-color: #eab308; color: #1c1400; }
body.theme-banana .modal-box { border-color: #eab308; background: #fefce8; }

body.theme-simplewhite {
  --bg: #ffffff;
  --bg2: #f8f8f8;
  --bg3: #f0f0f0;
  --surface: #ffffff;
  --surface2: #f5f5f5;
  --border: #d0d0d0;
  --border2: #b0b0b0;
  --text: #000000;
  --text2: #333333;
  --text3: #888888;
  --accent: #000000;
  --accent2: #333333;
  --user-bg: #000000;
  --user-text: #ffffff;
  --ai-bg: #f5f5f5;
  --ai-text: #000000;
  --led-ready: #22c55e;
  --led-gen: #eab308;
  --led-stop: #ef4444;
  --input-bg: #ffffff;
  --scrollbar: #d0d0d0;
  background: #ffffff;
  font-family: 'IBM Plex Mono', monospace;
  --font-main: 'IBM Plex Mono', monospace;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-size-base: 13px;
}
body.theme-simplewhite #app { background: #ffffff; border: 1px solid #d0d0d0; }
body.theme-simplewhite #topbar { background: #ffffff; border-bottom: 1px solid #d0d0d0; }
body.theme-simplewhite #logo { color: #000000 !important; }
body.theme-simplewhite #send-btn { background: #000000; color: #ffffff; }
body.theme-simplewhite #send-btn:hover { background: #333333; }
body.theme-simplewhite .msg-bubble.user { background: #000000; color: #ffffff; }
body.theme-simplewhite .msg-bubble.ai { background: #f5f5f5; border: 1px solid #d0d0d0; color: #000000; }
body.theme-simplewhite .theme-btn { background: #ffffff; border-color: #d0d0d0; color: #333333; }
body.theme-simplewhite .theme-btn:hover, body.theme-simplewhite .theme-btn.active { background: #000000; color: #ffffff; border-color: #000000; }
body.theme-simplewhite #user-input { background: #ffffff; border-color: #d0d0d0; color: #000000; }
body.theme-simplewhite #user-input:focus { border-color: #000000; }
body.theme-simplewhite #input-area { background: #ffffff; border-top: 1px solid #d0d0d0; }
body.theme-simplewhite #messages::-webkit-scrollbar-thumb { background: #c0c0c0; }
body.theme-simplewhite .opt-select, body.theme-simplewhite .opt-input { background: #ffffff; border-color: #d0d0d0; color: #000000; }
body.theme-simplewhite .modal-box { border-color: #d0d0d0; background: #ffffff; }
body.theme-simplewhite .modal-btn { color: #ffffff; }
body.theme-simplewhite #sidebar { background: #ffffff; border-right: 1px solid #d0d0d0; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-size: var(--font-size-base, 15px);
  transition: background var(--transition), color var(--transition);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  position: relative;
}

/* ---- Desktop fullscreen layout: treść centrowana w kolumnie 700px ---- */
@media (min-width: 601px) {
  #messages {
    padding-left: max(24px, calc((100% - 720px) / 2));
    padding-right: max(24px, calc((100% - 720px) / 2));
  }
  #input-area {
    padding-left: max(14px, calc((100% - 720px) / 2));
    padding-right: max(14px, calc((100% - 720px) / 2));
  }
  #img-preview-wrap,
  #file-preview-wrap {
    padding-left: max(14px, calc((100% - 720px) / 2));
    padding-right: max(14px, calc((100% - 720px) / 2));
  }
  #options-panel .options-inner {
    max-width: 720px;
    margin: 0 auto;
  }
}

.win98-titlebar {
  display: none;
  background: linear-gradient(to right, #000080, #1084d0);
  color: white;
  padding: 3px 6px;
  font-size: 12px;
  font-family: 'Share Tech Mono', monospace;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
body.theme-win98 .win98-titlebar { display: flex; }
.win98-btn {
  background: var(--surface2);
  border: 1px solid;
  border-color: #fff #808080 #808080 #fff;
  color: #000;
  width: 16px;
  height: 14px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  font-family: 'Share Tech Mono', monospace;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
body.theme-win98 #topbar {
  background: var(--surface2);
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  margin: 2px;
  padding: 6px 10px;
}

#logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.5px;
  flex-shrink: 0;
  font-family: var(--font-main);
}
body.theme-pixel #logo { font-size: 11px; text-shadow: 2px 2px var(--border); }
body.theme-terminal #logo { font-size: 22px; color: var(--accent); }
body.theme-win98 #logo { font-size: 14px; }

#led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
  box-shadow: 0 0 4px currentColor;
}
#led.ready { background: var(--led-ready); color: var(--led-ready); }
#led.generating { background: var(--led-gen); color: var(--led-gen); animation: pulse 0.8s ease-in-out infinite; }
#led.stopped { background: var(--led-stop); color: var(--led-stop); }
body.theme-win98 #led { border-radius: 0; box-shadow: none; border: 1px solid #404040; }
body.theme-pixel #led { border-radius: 0; box-shadow: 0 0 8px currentColor; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.topbar-spacer { flex: 1; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition);
  flex-shrink: 0;
  font-family: var(--font-mono, monospace);
}
.icon-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.icon-btn:active { transform: scale(0.95); }
body.theme-win98 .icon-btn {
  border: 1px solid;
  border-color: #fff #808080 #808080 #fff;
  background: var(--surface2);
  color: #000;
}
body.theme-pixel .icon-btn {
  border: 2px solid var(--accent);
  box-shadow: 2px 2px 0 var(--border2);
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#sidebar.open { transform: translateX(0); }
body.theme-win98 #sidebar {
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  border-left: none;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#sidebar-header span { font-size: 14px; font-weight: 500; color: var(--accent); }

#chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  border: 1px solid transparent;
  transition: all var(--transition);
  position: relative;
}
.chat-item:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }
.chat-item.active { background: var(--surface2); color: var(--accent); border-color: var(--accent); }
.chat-item .chat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .del-chat {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  border-radius: 4px;
  transition: all var(--transition);
  font-family: var(--font-mono, monospace);
}
.chat-item:hover .del-chat { opacity: 1; }
.chat-item .del-chat:hover { color: var(--led-stop); }

#sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
#new-chat-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: var(--user-text, #fff);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-main);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
}
#new-chat-btn:hover { opacity: 0.88; }

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
  display: none;
}
#overlay.visible { display: block; }

#messages-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  min-height: 0;
}
#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--scrollbar, var(--border)); border-radius: 99px; }

#welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 20px;
  color: var(--text3);
  text-align: center;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#welcome h2 { color: var(--accent); font-size: 22px; font-family: var(--font-main); }
#welcome p { font-size: 13px; max-width: 280px; line-height: 1.7; }
body.theme-pixel #welcome h2 { font-size: 12px; }
body.theme-terminal #welcome h2 { font-size: 28px; }

.msg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg-row.user { align-items: flex-end; }
.msg-row.ai { align-items: flex-start; }

.msg-bubble {
  max-width: 85%;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-main);
  font-size: var(--font-size-base, 15px);
  line-height: 1.65;
  position: relative;
  word-break: break-word;
}
.msg-row.user .msg-bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: var(--radius-sm);
}
.msg-row.ai .msg-bubble {
  background: var(--ai-bg);
  color: var(--ai-text);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}
body.theme-win98 .msg-row.ai .msg-bubble {
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
}
body.theme-win98 .msg-row.user .msg-bubble {
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
}

.msg-img { max-width: 200px; border-radius: var(--radius-sm); margin-bottom: 6px; display: block; }

.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  padding: 0 4px;
}
.msg-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text3);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--transition);
  font-family: var(--font-mono, monospace);
}
.msg-action-btn:hover { background: var(--surface2); color: var(--text); }

.msg-text h1, .msg-text h2, .msg-text h3 {
  margin: 10px 0 6px;
  color: var(--accent);
  font-family: var(--font-main);
}
.msg-text p { margin-bottom: 8px; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text ul, .msg-text ol { padding-left: 18px; margin-bottom: 8px; }
.msg-text li { margin-bottom: 4px; }
.msg-text code:not(pre code) {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.88em;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  color: var(--accent2, var(--accent));
}
body.theme-cozy .msg-text code:not(pre code) { color: #c2734a; }
.msg-text pre {
  position: relative;
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.msg-text pre code {
  display: block;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #1e2030 !important;
  color: #cdd6f4 !important;
  border-radius: 0;
}
body.theme-cozy .msg-text pre code { background: #2d2019 !important; color: #f0dcc6 !important; }
body.theme-win98 .msg-text pre code { background: #000080 !important; color: #ffffff !important; font-family: 'Share Tech Mono', monospace !important; }
body.theme-pixel .msg-text pre code { background: #0a0a1a !important; color: #e0e0ff !important; }
body.theme-terminal .msg-text pre code { background: #000 !important; color: #00ff41 !important; font-family: 'VT323', monospace !important; font-size: 18px !important; }
body.theme-dark .msg-text pre code { background: #0a0a0a !important; color: #e0e0e0 !important; }
body.theme-coffee .msg-text pre code { background: #120a04 !important; color: #f0d8b0 !important; }
body.theme-pistachio .msg-text pre code { background: #162812 !important; color: #c8e8b8 !important; }
body.theme-lofi .msg-text pre code { background: #1a1208 !important; color: #e8d8c0 !important; }
.copy-code-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  padding: 3px 8px;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
  z-index: 2;
}
.copy-code-btn:hover { background: var(--accent); color: var(--user-text); }
.msg-text blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text2);
  margin: 8px 0;
  font-style: italic;
}
.msg-text .table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.msg-text .table-wrapper::-webkit-scrollbar { height: 4px; }
.msg-text .table-wrapper::-webkit-scrollbar-track { background: transparent; }
.msg-text .table-wrapper::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
.msg-text table { border-collapse: collapse; width: max-content; min-width: 100%; margin: 0; font-size: 13px; }
.msg-text th, .msg-text td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; white-space: nowrap; }
.msg-text th { background: var(--surface2); }

.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--text3);
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }
body.theme-win98 .typing-dot { border-radius: 0; }
body.theme-pixel .typing-dot { border-radius: 0; width: 8px; height: 8px; }

#options-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.2s ease;
  flex-shrink: 0;
}
#options-panel.open { max-height: 420px; }
.options-inner { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

body.theme-win98 #options-panel {
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  margin: 0 2px;
}

.opt-row { display: flex; align-items: center; gap: 10px; }
.opt-label { font-size: 12px; color: var(--text3); white-space: nowrap; min-width: 70px; }

.opt-select, .opt-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
}
.opt-select:focus, .opt-input:focus { border-color: var(--accent); }
body.theme-win98 .opt-select, body.theme-win98 .opt-input {
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  background: #fff;
  border-radius: 0;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.theme-btn {
  padding: 6px 2px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  font-family: var(--font-main);
}
.theme-btn:hover, .theme-btn.active { background: var(--accent); color: var(--user-text); border-color: var(--accent); }
body.theme-win98 .theme-btn { border-radius: 0; border-color: #fff #808080 #808080 #fff; }

#img-preview-wrap {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#img-preview-wrap.visible { display: flex; }
#img-preview { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
#img-name { font-size: 12px; color: var(--text2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#img-remove { background: transparent; border: none; color: var(--text3); cursor: pointer; font-size: 18px; font-family: var(--font-mono, monospace); }

#file-preview-wrap {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#file-preview-wrap.visible { display: flex; }
#file-chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text2);
  max-width: 220px;
}
.file-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.file-chip button { background: transparent; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 0; display: flex; align-items: center; flex-shrink: 0; }
.file-chip button:hover { color: var(--text); }

#scroll-bottom-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 10;
  transition: opacity 0.15s, transform 0.15s;
  opacity: 0;
  transform: translateY(8px);
}
#scroll-bottom-btn.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.file-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
  max-width: 100%;
  overflow: hidden;
}
.file-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.user .file-badge { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.25); color: var(--user-text); }

#input-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
  flex-shrink: 0;
}
body.theme-win98 #input-area {
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  margin: 2px;
}

#input-row { display: flex; gap: 8px; align-items: flex-end; }

#user-input {
  flex: 1;
  min-height: 42px;
  max-height: 140px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-main);
  font-size: var(--font-size-base, 15px);
  padding: 10px 14px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  line-height: 1.5;
}
#user-input:focus { border-color: var(--accent); }
#user-input::placeholder { color: var(--text3); }
body.theme-win98 #user-input {
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  border-radius: 0;
  background: #fff;
}
body.theme-pixel #user-input { border: 2px solid var(--accent); box-shadow: 2px 2px 0 var(--bg3); }
body.theme-terminal #user-input { border-color: var(--accent); background: #000; caret-color: var(--accent); }

#send-btn {
  width: 42px;
  height: 42px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--user-text, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: all var(--transition);
  font-family: var(--font-mono, monospace);
}
#send-btn:hover { opacity: 0.85; }
#send-btn:active { transform: scale(0.94); }
#send-btn.stop { background: var(--led-stop); }
body.theme-win98 #send-btn {
  border-radius: 0;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
}
body.theme-pixel #send-btn {
  border-radius: 0;
  border: 2px solid var(--accent2);
  box-shadow: 2px 2px 0 var(--border2);
}
body.theme-dark #send-btn { color: #000000; }

.bottom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  display: none;
}
.bottom-row .icon-btn { width: 30px; height: 30px; font-size: 16px; display: none;}

#api-key-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
#api-key-modal.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
body.theme-win98 .modal-box { border: 2px solid; border-color: #fff #808080 #808080 #fff; border-radius: 0; }
body.theme-pixel .modal-box { border: 2px solid var(--accent); box-shadow: 4px 4px 0 var(--border2); }
.modal-box h2 { font-size: 16px; color: var(--accent); font-family: var(--font-main); }
.modal-box p { font-size: 13px; color: var(--text2); line-height: 1.6; }
.modal-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--user-text, #fff);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  font-family: var(--font-main);
  transition: all var(--transition);
}
.modal-btn:hover { opacity: 0.87; }
body.theme-dark .modal-btn { color: #000000; }

body.theme-dark .delete-modal-btn.confirm {
  color: #000000;
}
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--user-text, #fff);
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-main);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; }
body.theme-dark #toast { color: #000000; }

body.theme-win98 #messages::-webkit-scrollbar-thumb { background: #808080; }
body.theme-pixel #messages::-webkit-scrollbar-thumb { background: var(--accent); }
body.theme-terminal #messages::-webkit-scrollbar-thumb { background: var(--accent); }
body.theme-dark #messages::-webkit-scrollbar-thumb { background: #333333; }
body.theme-coffee #messages::-webkit-scrollbar-thumb { background: #5e3e28; }
body.theme-pistachio #messages::-webkit-scrollbar-thumb { background: #9eca8c; }
body.theme-lofi #messages::-webkit-scrollbar-thumb { background: #b8a080; }

body.theme-terminal::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,255,65,0.02) 2px, rgba(0,255,65,0.02) 4px);
  pointer-events: none;
  z-index: 9999;
}

.win98-status {
  display: none;
  background: var(--surface2);
  border-top: 1px solid #808080;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text2);
  font-family: 'Share Tech Mono', monospace;
  flex-shrink: 0;
}
body.theme-win98 .win98-status { display: flex; gap: 16px; }

.logog {
  max-width: 150px;
}

.file-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.file-modal-overlay.open { display: flex; }
.file-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.theme-win98 .file-modal-box { border-radius: 0; border: 2px solid; border-color: #fff #808080 #808080 #fff; }
body.theme-pixel .file-modal-box { border: 2px solid var(--accent); box-shadow: 4px 4px 0 var(--border2); border-radius: 2px; }
.file-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--font-main);
  font-weight: 500;
}
.file-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  margin: 0;
  border-radius: 0;
}
.file-modal-content::-webkit-scrollbar { width: 5px; }
.file-modal-content::-webkit-scrollbar-track { background: transparent; }
.file-modal-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.run-code-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: #2a6e2a;
  border: 1px solid #4aaa4a;
  border-radius: var(--radius-sm);
  color: #aaffaa;
  cursor: pointer;
  padding: 3px 10px;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
  z-index: 3;
}
.run-code-btn:hover { background: #3a8a3a; color: #ccffcc; border-color: #6acc6a; }

/* Button order from right: RUN → download → copy */
/* download button sits at right:6px (reuses copy-code-btn base, overridden below) */
.copy-code-btn.dl-btn { right: 6px; }
/* copy button shifts left of download */
.msg-text pre .copy-code-btn:not(.dl-btn) { right: 104px; }
/* when RUN is present, shift both copy and download further left */
.msg-text pre:has(.run-code-btn) .dl-btn { right: 76px; }
.msg-text pre:has(.run-code-btn) .copy-code-btn:not(.dl-btn) { right: 175px; }
.msg-text pre { padding-bottom: 34px; }

@media (max-width: 600px) {
  body.theme-cozy,
  body.theme-coffee,
  body.theme-lofi {
    --font-size-base: 15px;
  }
  body.theme-cozy .msg-bubble,
  body.theme-coffee .msg-bubble,
  body.theme-lofi .msg-bubble { font-size: 15px; }
  body.theme-cozy .opt-label,
  body.theme-coffee .opt-label,
  body.theme-lofi .opt-label { font-size: 12px; }
  body.theme-cozy .opt-select,
  body.theme-coffee .opt-select,
  body.theme-lofi .opt-select,
  body.theme-cozy .opt-input,
  body.theme-coffee .opt-input,
  body.theme-lofi .opt-input { font-size: 13px; }
  body.theme-cozy #user-input,
  body.theme-coffee #user-input,
  body.theme-lofi #user-input { font-size: 15px; }
  body.theme-cozy .theme-btn,
  body.theme-coffee .theme-btn,
  body.theme-lofi .theme-btn { font-size: 11px; }
  body.theme-cozy #welcome h2,
  body.theme-coffee #welcome h2,
  body.theme-lofi #welcome h2 { font-size: 20px; }
  body.theme-cozy #welcome p,
  body.theme-coffee #welcome p,
  body.theme-lofi #welcome p { font-size: 13px; }
  body.theme-cozy .modal-box h2,
  body.theme-coffee .modal-box h2,
  body.theme-lofi .modal-box h2 { font-size: 15px; }
  body.theme-cozy .modal-box p,
  body.theme-coffee .modal-box p,
  body.theme-lofi .modal-box p { font-size: 13px; }
  body.theme-cozy .modal-btn,
  body.theme-coffee .modal-btn,
  body.theme-lofi .modal-btn { font-size: 14px; }
  body.theme-terminal .msg-bubble { font-size: 18px; }
  body.theme-terminal #user-input { font-size: 18px; }
  .file-modal-box { max-height: 90vh; }
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border2);
  border-radius: 22px;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
body.theme-win98 .toggle-slider { border-radius: 0; }
body.theme-win98 .toggle-slider::before { border-radius: 0; }
body.theme-dark .toggle-switch input:checked + .toggle-slider { background: #ffffff; }
body.theme-dark .toggle-slider::before { background: #444; }
body.theme-dark .toggle-switch input:checked + .toggle-slider::before { background: #000; }

.opt-file-btn {
  width: auto;
  padding: 0 10px;
  gap: 5px;
  font-size: 13px;
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  max-width: 140px;
}

@media (max-width: 420px) {
  .opt-file-btn {
    font-size: 12px;
    padding: 0 7px;
    max-width: 110px;
  }
  .opt-label {
    min-width: 50px;
  }
  .opt-row {
    flex-wrap: nowrap;
    overflow: hidden;
  }
}

body.theme-dark #scroll-bottom-btn {
  background: #333333;
  color: #ffffff;
}

.reasoning-content {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  color: green;
  padding-left: 35px;
}

.reasoning-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #22d3ee, transparent);
  animation: scan 3s linear infinite;
}

@keyframes scan {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.reasoning-content h3 {
  font-style: oblique;
  color: #67e8f9;
  text-transform: uppercase;
  font-size: 0.95rem;
  letter-spacing: 2px;
  margin-bottom: 16px;
  opacity: 0.9;
}
/* Response time badge */
.response-time-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3);
  opacity: 0.65;
  margin-top: 3px;
  margin-left: 4px;
  font-family: var(--font-mono, monospace);
  transition: opacity 0.2s;
}
.response-time-badge:hover {
  opacity: 1;
}
.response-time-badge i {
  font-size: 12px;
}

/* Delete chat confirmation modal */
.delete-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}
.delete-modal-overlay.open {
  display: flex;
}
.delete-modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 28px 22px;
  width: min(320px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.35);
  animation: modal-pop 0.18s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modal-pop {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.delete-modal-icon {
  font-size: 32px;
  color: var(--accent);
  opacity: 0.85;
  line-height: 1;
}
.delete-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text1);
  margin-top: 2px;
}
.delete-modal-desc {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  line-height: 1.5;
}
.delete-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
}
.delete-modal-btn {
  flex: 1;
  padding: 9px 0;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.delete-modal-btn:hover  { opacity: 0.85; }
.delete-modal-btn:active { transform: scale(0.97); }
.delete-modal-btn.cancel {
  background: var(--bg3, var(--bg2));
  color: var(--text2);
  border: 1px solid var(--border);
}
.delete-modal-btn.confirm {
  background: var(--accent);
  color: #fff;
}