﻿:root {
  --bg-start: #153a34;
  --bg-end: #0f1b1a;
  --topbar-start: #0f2624;
  --topbar-mid: #14332f;
  --topbar-end: #0f2624;
  --panel: #0f2624;
  --card: #102f2b;
  --accent: #1fa86a;
  --accent-soft: #c5f2d6;
  --bubble-self: #dcf8c6;
  --bubble-other: #ffffff;
  --text: #eaf8f1;
  --muted: #93b7a7;
  --line: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, var(--bg-start), var(--bg-end) 45%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--topbar-start), var(--topbar-mid) 60%, var(--topbar-end));
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06) 55%, rgba(0, 0, 0, 0.1));
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

.brand-icon svg {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.24));
}

.back-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateX(-1px);
}

.title-wrap h1 {
  margin: 0;
  font-size: 20px;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.home-hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.self-select {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.self-select select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 8px;
}

.appearance {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.appearance-control {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.appearance-control select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 8px;
}

.content {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 24px;
  width: 100%;
}

.upload-screen,
.chat-screen {
  width: 100%;
  max-width: 1200px;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 14px;
  height: calc(100vh - 72px);
}

.card {
  background: linear-gradient(165deg, var(--card), var(--panel));
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(2px);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 8px;
}

.help {
  margin: 0 0 24px;
  color: var(--muted);
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.upload-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.22));
  font-size: 13px;
}

.upload-item input {
  width: 100%;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.upload-item input::file-selector-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.06));
  color: var(--text);
  font-weight: 600;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
}

.upload-item input::-webkit-file-upload-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.06));
  color: var(--text);
  font-weight: 600;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

button {
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #081715;
  font-weight: 600;
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.disclaimer {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

.status {
  margin-top: 12px;
  font-size: 13px;
}

.status.error {
  color: #ffb3a5;
}

.status.success {
  color: #b8f6c7;
}

.chat-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: #183b36;
  background-size: 180px 180px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  scroll-behavior: smooth;
}

.chat-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(150deg, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.24));
}

.chat-header {
  background: linear-gradient(180deg, var(--card), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.chat-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.chat-encryption {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.assistant-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(150deg, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.24));
}

.assistant-head h3 {
  margin: 0;
  font-size: 18px;
}

.assistant-usage {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.assistant-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.assistant-config {
  display: grid;
  gap: 8px;
}

.assistant-config label {
  font-size: 12px;
  color: var(--muted);
}

.assistant-config select,
.assistant-config input,
.assistant-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 8px 10px;
}

.assistant-config input::placeholder,
.assistant-form textarea::placeholder {
  color: rgba(234, 248, 241, 0.7);
}

.assistant-summary {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.16);
}

.assistant-summary h4 {
  margin: 0 0 6px;
  font-size: 13px;
}

.assistant-summary-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text);
  display: grid;
  gap: 6px;
}

.assistant-thread {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assistant-msg {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.assistant-msg.user {
  align-self: flex-end;
  background: rgba(31, 168, 106, 0.2);
  border: 1px solid rgba(31, 168, 106, 0.35);
}

.assistant-msg.ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.assistant-form {
  display: grid;
  gap: 8px;
}

.assistant-form textarea {
  resize: vertical;
  min-height: 70px;
}

.message {
  max-width: 70%;
  padding: 10px 12px 8px;
  border-radius: 16px;
  position: relative;
  background: var(--bubble-other);
  color: #13221f;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.12);
}

.message.self {
  align-self: flex-end;
  background: var(--bubble-self);
}

.message.other {
  align-self: flex-start;
}

.message .sender {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--accent);
}

.message .body {
  white-space: pre-wrap;
  font-size: 14px;
}

.message .timestamp {
  font-size: 10px;
  color: rgba(20, 40, 36, 0.5);
  text-align: right;
  margin-top: 6px;
}

.message.system {
  align-self: center;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  max-width: 80%;
}

.media-thumb,
.media-video {
  width: 100%;
  border-radius: 12px;
  margin-top: 8px;
  cursor: pointer;
}

.placeholder {
  font-size: 12px;
  color: rgba(20, 40, 36, 0.7);
  background: rgba(255, 255, 255, 0.7);
  padding: 8px;
  border-radius: 10px;
  margin-top: 8px;
}

.hidden {
  display: none;
}

.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

.modal-content {
  position: relative;
  z-index: 41;
  max-width: min(90vw, 900px);
  max-height: 90vh;
}

.modal-content img,
.modal-content video {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 12px;
}

.modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: #ffffff;
  border: none;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.chat-area.wallpaper-1 {
  background-image: linear-gradient(145deg, #ffeaf3, #e8f6ff), radial-gradient(circle, rgba(255, 163, 201, 0.45) 0 7px, transparent 8px), radial-gradient(circle, rgba(145, 208, 255, 0.45) 0 6px, transparent 7px);
  background-size: cover, 44px 44px, 44px 44px;
  background-position: center, 0 0, 22px 22px;
}

.chat-area.wallpaper-2 {
  background-image: linear-gradient(160deg, #f8f5ff, #eef4ff), repeating-conic-gradient(from 30deg, rgba(255, 182, 193, 0.7) 0 60deg, rgba(255, 226, 138, 0.7) 60deg 120deg, rgba(153, 221, 255, 0.68) 120deg 180deg);
  background-size: cover, 88px 88px;
}

.chat-area.wallpaper-3 {
  background-image: radial-gradient(circle at 18% 22%, rgba(255, 126, 95, 0.4), transparent 32%), radial-gradient(circle at 76% 24%, rgba(255, 214, 102, 0.46), transparent 34%), radial-gradient(circle at 30% 76%, rgba(115, 211, 255, 0.42), transparent 36%), radial-gradient(circle at 78% 74%, rgba(181, 144, 255, 0.38), transparent 34%), linear-gradient(145deg, #fff1ea, #edf7ff);
  background-size: cover;
}

.chat-area.wallpaper-4 {
  background-image: linear-gradient(160deg, #fff4e8, #f1f7ff), radial-gradient(circle at 12% 18%, rgba(255, 112, 156, 0.36) 0 6px, transparent 7px), radial-gradient(circle at 84% 20%, rgba(95, 190, 255, 0.36) 0 5px, transparent 6px), radial-gradient(circle at 34% 64%, rgba(255, 186, 82, 0.34) 0 8px, transparent 9px), linear-gradient(42deg, rgba(255, 255, 255, 0) 0 34%, rgba(255, 255, 255, 0.46) 34% 38%, rgba(255, 255, 255, 0) 38% 100%);
  background-size: cover, 120px 120px, 130px 130px, 150px 150px, cover;
  background-position: center, 0 0, 20px 30px, 50px 20px, center;
}

.chat-area.wallpaper-5 {
  background-image: linear-gradient(145deg, #ffecd8, #ffe7e0), conic-gradient(from 210deg at 22% 76%, rgba(255, 144, 90, 0.7), rgba(255, 208, 83, 0.7), rgba(255, 144, 90, 0.7)), conic-gradient(from 30deg at 76% 26%, rgba(255, 127, 123, 0.58), rgba(255, 220, 119, 0.6), rgba(255, 127, 123, 0.58));
  background-size: cover, 220px 220px, 240px 240px;
  background-position: center, 0 0, 120px 80px;
}

.chat-area.wallpaper-6 {
  background-image: linear-gradient(155deg, #eef2ff, #e3ebfb), repeating-radial-gradient(circle at -20% 50%, rgba(255, 255, 255, 0.72) 0 14px, rgba(205, 219, 246, 0.68) 14px 28px);
  background-size: cover;
}

.chat-area.wallpaper-7 {
  background-image: linear-gradient(180deg, rgba(255, 252, 242, 0.94), rgba(247, 255, 251, 0.96)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='168' height='145' viewBox='0 0 168 145'%3E%3Cg fill='none' stroke-width='4'%3E%3Cpath stroke='rgba(141,216,197,0.55)' d='M42 0L21 36.3v36.2L42 109h42l21-36.5V36.3L84 0H42zM126 0l-21 36.3v36.2l21 36.5h42l21-36.5V36.3L168 0h-42zM0 72.5L21 109v36.3L0 181h42l21-35.7V109L42 72.5H0z'/%3E%3Cpath stroke='rgba(255,226,141,0.46)' d='M44 6L26 37.5v33L44 103h36l18-32.5v-33L80 6H44zM128 6l-18 31.5v33l18 32.5h36l18-32.5v-33L164 6h-36z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover, 168px 145px;
}

.chat-area.wallpaper-8 {
  background-image: linear-gradient(180deg, #06163f, #0a0732), repeating-linear-gradient(60deg, rgba(0, 245, 255, 0.45) 0 2px, transparent 2px 26px), repeating-linear-gradient(-60deg, rgba(255, 66, 237, 0.42) 0 2px, transparent 2px 26px), repeating-linear-gradient(0deg, rgba(255, 235, 92, 0.32) 0 2px, transparent 2px 22px);
  background-size: cover;
}

.chat-area.wallpaper-9 {
  background-image: radial-gradient(circle at 24% 28%, rgba(255, 203, 213, 0.45), transparent 36%), radial-gradient(circle at 66% 24%, rgba(255, 234, 178, 0.38), transparent 34%), radial-gradient(circle at 34% 72%, rgba(207, 236, 255, 0.42), transparent 36%), radial-gradient(circle at 78% 68%, rgba(236, 218, 255, 0.36), transparent 33%), linear-gradient(135deg, #fff4f0, #f1f8ff);
  background-size: cover;
}

.chat-area.wallpaper-10 {
  background-image: linear-gradient(145deg, #1a214f, #281440), radial-gradient(circle, rgba(119, 152, 255, 0.5) 0 6px, transparent 7px), radial-gradient(circle, rgba(220, 141, 255, 0.46) 0 5px, transparent 6px), radial-gradient(circle, rgba(255, 223, 112, 0.3) 0 4px, transparent 5px);
  background-size: cover, 40px 40px, 40px 40px, 80px 80px;
  background-position: center, 0 0, 20px 20px, 10px 30px;
}

.app.theme-1 {
  --bg-start: #153a34;
  --bg-end: #0f1b1a;
  --topbar-start: #0f2624;
  --topbar-mid: #14332f;
  --topbar-end: #0f2624;
  --panel: #0f2624;
  --card: #102f2b;
  --accent: #1fa86a;
  --bubble-self: #dcf8c6;
  --bubble-other: #ffffff;
  --text: #eaf8f1;
  --muted: #93b7a7;
  --line: rgba(255, 255, 255, 0.08);
}

.app.theme-2 {
  --bg-start: #1f2d4d;
  --bg-end: #121924;
  --topbar-start: #16223a;
  --topbar-mid: #1f2d4d;
  --topbar-end: #16223a;
  --panel: #16223a;
  --card: #1b2b48;
  --accent: #6ec1ff;
  --bubble-self: #d8edff;
  --bubble-other: #ffffff;
  --text: #eef5ff;
  --muted: #a8bfd6;
  --line: rgba(255, 255, 255, 0.12);
}

.app.theme-3 {
  --bg-start: #4b2230;
  --bg-end: #201017;
  --topbar-start: #3b1b28;
  --topbar-mid: #5a2939;
  --topbar-end: #3b1b28;
  --panel: #3b1b28;
  --card: #4a2332;
  --accent: #ff8aa9;
  --bubble-self: #ffe0ea;
  --bubble-other: #fff7fb;
  --text: #fff2f7;
  --muted: #e4b7c7;
  --line: rgba(255, 255, 255, 0.12);
}

.app.theme-4 {
  --bg-start: #3a2b58;
  --bg-end: #1a1430;
  --topbar-start: #2e2248;
  --topbar-mid: #3f2f61;
  --topbar-end: #2e2248;
  --panel: #2f234a;
  --card: #3a2b58;
  --accent: #c1a7ff;
  --bubble-self: #eadeff;
  --bubble-other: #f8f4ff;
  --text: #f5efff;
  --muted: #c8b6e8;
  --line: rgba(255, 255, 255, 0.12);
}

.app.theme-5 {
  --bg-start: #4a3521;
  --bg-end: #21170f;
  --topbar-start: #3f2d1c;
  --topbar-mid: #513a25;
  --topbar-end: #3f2d1c;
  --panel: #3f2d1c;
  --card: #4b3622;
  --accent: #ffbe7a;
  --bubble-self: #ffe9d1;
  --bubble-other: #fff8ef;
  --text: #fff4e8;
  --muted: #e0c0a0;
  --line: rgba(255, 255, 255, 0.12);
}

.app.theme-6 {
  --bg-start: #264735;
  --bg-end: #12241b;
  --topbar-start: #1f3b2c;
  --topbar-mid: #2d543f;
  --topbar-end: #1f3b2c;
  --panel: #1f3b2c;
  --card: #2a4b38;
  --accent: #7ad69c;
  --bubble-self: #def6e4;
  --bubble-other: #f7fff9;
  --text: #eefcf2;
  --muted: #a8cfb5;
  --line: rgba(255, 255, 255, 0.11);
}

.app.theme-7 {
  --bg-start: #4f2e17;
  --bg-end: #201109;
  --topbar-start: #3d2412;
  --topbar-mid: #5a341b;
  --topbar-end: #3d2412;
  --panel: #3d2412;
  --card: #4a2b16;
  --accent: #ff9f5d;
  --bubble-self: #ffe3cf;
  --bubble-other: #fff6ef;
  --text: #fff1e7;
  --muted: #dfb397;
  --line: rgba(255, 255, 255, 0.12);
}

.app.theme-8 {
  --bg-start: #163b4a;
  --bg-end: #0a1c25;
  --topbar-start: #123240;
  --topbar-mid: #1a495c;
  --topbar-end: #123240;
  --panel: #123240;
  --card: #184255;
  --accent: #7fd3f5;
  --bubble-self: #ddf4ff;
  --bubble-other: #f6fbff;
  --text: #ecf8ff;
  --muted: #a7cad9;
  --line: rgba(255, 255, 255, 0.12);
}

.app.theme-9 {
  --bg-start: #183826;
  --bg-end: #0b1d14;
  --topbar-start: #143021;
  --topbar-mid: #1d4630;
  --topbar-end: #143021;
  --panel: #143021;
  --card: #1a3f2b;
  --accent: #8ecf7a;
  --bubble-self: #e6f8df;
  --bubble-other: #f8fff5;
  --text: #effbeb;
  --muted: #adc9a4;
  --line: rgba(255, 255, 255, 0.11);
}

.app.theme-10 {
  --bg-start: #2b1d3d;
  --bg-end: #130b1d;
  --topbar-start: #231733;
  --topbar-mid: #321f48;
  --topbar-end: #231733;
  --panel: #231733;
  --card: #2c1e41;
  --accent: #d8a9ff;
  --bubble-self: #f1e2ff;
  --bubble-other: #fbf6ff;
  --text: #f6eeff;
  --muted: #cab4e5;
  --line: rgba(255, 255, 255, 0.12);
}

@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .topbar {
    position: sticky;
    top: 0;
    height: 100vh;
    border-bottom: none;
    border-right: 1px solid var(--line);
    padding: 28px 20px;
    background: linear-gradient(180deg, var(--topbar-start) 0%, var(--topbar-mid) 48%, var(--topbar-end) 100%);
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .self-select {
    justify-content: space-between;
  }

  .self-select select {
    width: 100%;
  }

  .content {
    justify-content: flex-start;
    align-items: flex-start;
    padding: 24px;
  }

  .chat-layout {
    height: calc(100vh - 48px);
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 14px 16px;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .chat-shell {
    height: 58vh;
  }

  .chat-area {
    padding: 14px;
  }

  .assistant-pane {
    min-height: 45vh;
  }

  .message {
    max-width: 85%;
  }
}
