:root {
  --bg: #0b141a;
  --panel: #111b21;
  --panel-2: #0f1a20;
  --text: #e9edef;
  --muted: #8696a0;
  --border: rgba(255, 255, 255, 0.08);
  --me: #005c4b;
  --you: #202c33;
  --accent: #00a884;
  --shadow: 0 15px 45px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --sidebar-width: 270px;
  --vh: 1vh;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(1200px 700px at 30% -10%, rgba(0, 168, 132, 0.15), transparent 60%),
    radial-gradient(900px 600px at 90% 10%, rgba(0, 122, 255, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 18px;
}

.app-shell {
  width: min(1200px, 100%);
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 30%), var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-panel h1 {
  margin: 0 0 8px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.input-group input {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.send-btn {
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), #00715c);
  box-shadow: 0 12px 30px rgba(0, 168, 132, 0.35);
}

.error-banner {
  background: rgba(230, 0, 0, 0.12);
  border: 1px solid rgba(230, 0, 0, 0.35);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) auto;
  gap: 18px;
  width: min(1200px, 100%);
  align-items: stretch;
}

.workspace .app,
.workspace .sidebar {
  height: min(86vh, 820px);
}

.sidebar {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-item {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
}

.session-item.active {
  border-color: var(--accent);
  background: rgba(0, 168, 132, 0.15);
}

.app {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 22px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--panel-2);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.25), transparent 55%),
    linear-gradient(135deg, rgba(0, 168, 132, 0.9), rgba(0, 122, 255, 0.65));
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.title strong {
  font-size: 15px;
}

.title span {
  font-size: 12px;
  color: var(--muted);
}

.actions,
.iconbtn-group {
  display: flex;
  gap: 10px;
}

.iconbtn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.chat {
  position: relative;
  overflow-y: auto;
  padding: 20px 16px 10px;
  background: radial-gradient(900px 500px at 50% 0%, rgba(255, 255, 255, 0.03), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 35%),
    var(--panel);
}

.message-row {
  display: flex;
  margin: 12px 0;
}

.message-row.me {
  justify-content: flex-end;
}

.message-row.you {
  justify-content: flex-start;
}

.bubble {
  max-width: min(80%, 560px);
  padding: 12px 14px 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  line-height: 1.4;
  font-size: 14px;
  background: var(--you);
  word-break: break-word;
}

.bubble.me {
  background: var(--me);
  border-top-right-radius: 10px;
}

.bubble.you {
  border-top-left-radius: 10px;
}

.meta {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: rgba(233, 237, 239, 0.7);
}

.attachment-group {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}

.attachment-preview {
  margin: 8px 16px 0;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
}

.typing-indicator {
  margin: 6px 16px 0;
  font-size: 12px;
  color: var(--muted);
}

.composer {
  padding: 12px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.field {
  flex: 1;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  max-height: 140px;
  min-height: 24px;
}

textarea::placeholder {
  color: rgba(134, 150, 160, 0.9);
}

.send {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(0, 168, 132, 0.35);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 45%), rgba(0, 168, 132, 0.22);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .sidebar {
    order: 2;
  }
  .app {
    order: 1;
  }
}

@media (max-width: 520px) {
  body {
    padding: 0;
  }
  .app-shell,
  .workspace {
    width: 100%;
  }
  .card,
  .sidebar,
  .app {
    border-radius: 0;
  }
  .hint {
    display: none;
  }
  .bubble {
    max-width: 90%;
  }
}
.mobile-only {
  display: none;
}

.new-message {
  position: absolute;
  right: 24px;
  bottom: 120px;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  background: linear-gradient(120deg, var(--accent), #00c296);
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.new-message:hover {
  transform: translateY(-2px);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  padding: 24px;
}

.modal-card {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 22px;
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.modal-card p {
  margin-top: 0;
  margin-bottom: 18px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.modal-actions button {
  flex: 1;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px 16px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 600;
}

.modal-actions button.danger {
  background: linear-gradient(120deg, #ff4e50, #f9d423);
  border: none;
  color: #0b0f13;
}

.modal-actions button.ghost {
  border-style: dashed;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 25;
  transition: opacity 0.25s ease;
}

body.newui {
  display: block;
  place-items: initial;
  padding: 0;
  min-height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
}

body.newui .app-shell {
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  justify-content: center;
}

body.newui .workspace {
  width: min(1200px, 100%);
  height: calc(var(--vh, 1vh) * 100);
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

body.newui .workspace.hidden {
  display: none;
}

body.newui .sidebar,
body.newui .app {
  height: 100%;
}

body.newui .app {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.newui .chat {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 32px;
}

body.newui .composer {
  padding: 16px;
}

body.newui .drawer-backdrop {
  display: none;
  opacity: 0;
  pointer-events: none;
}

body.newui .sidebar {
  position: relative;
  z-index: 10;
}

@media (max-width: 960px) {
  .mobile-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.newui .workspace {
    grid-template-columns: 1fr;
    padding: 0;
  }

  body.newui .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(400px, 92%);
    height: calc(var(--vh, 1vh) * 100);
    transform: translateX(-105%);
    transition: transform 0.3s ease;
    border-radius: 0;
    box-shadow: var(--shadow);
  }

  body.newui .app {
    border-radius: 0;
  }

  body.newui.drawer-open .sidebar {
    transform: translateX(0);
  }

  body.newui .drawer-backdrop {
    display: block;
  }

  body.newui.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.newui .card,
  body.newui .sidebar,
  body.newui .app {
    border-radius: 0;
  }
}

@media (max-width: 520px) {
  .bubble {
    max-width: 90%;
  }

  body.newui .composer {
    padding: 12px;
  }
}
.empty-state {
  text-align: center;
  color: var(--muted);
  margin-top: 80px;
  font-size: 14px;
}
