/* Alfred AI — Chat UI (no build step) */

:root {
  --bg: #0b0f19;
  --panel: #0f172a;
  --panel-2: rgba(15, 23, 42, 0.72);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #42abe4;
  --accent-2: #3897d0;
  --danger: #ef4444;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --max-width: 56rem;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    "Noto Sans", "Liberation Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1000px 700px at 15% 15%, rgba(66, 171, 228, 0.14), transparent 55%),
    radial-gradient(1000px 700px at 85% 40%, rgba(139, 92, 246, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

.app {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 300px;
  min-width: 260px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
    var(--panel);
  border-right: 1px solid var(--border);
  transition: width 200ms ease, transform 200ms ease;
  position: relative;
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sidebar #sidebarCollapseBtn {
  position: absolute;
  top: 14px;
  right: 14px;
  transition: opacity 200ms ease;
}

.icon-btn svg {
  transition: transform 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.icon-btn:active {
  transform: translateY(1px);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item__icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.nav-item__text {
  font-size: 14px;
  font-weight: 750;
}

.chat-search {
  padding: 0 2px;
}

.chat-search__input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.55);
  padding: 10px 12px;
  outline: none;
}

.chat-search__input:focus {
  border-color: rgba(66, 171, 228, 0.55);
  box-shadow: 0 0 0 3px rgba(66, 171, 228, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
}

.brand--button {
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: default;
}

.brand__logo {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  position: relative;
  background: radial-gradient(14px 14px at 30% 30%, rgba(255, 255, 255, 0.65), transparent 60%),
    linear-gradient(135deg, rgba(66, 171, 228, 0.95), rgba(56, 151, 208, 0.75));
  border: 1px solid rgba(66, 171, 228, 0.35);
  box-shadow: 0 10px 18px rgba(66, 171, 228, 0.08);
}

.brand__logo-overlay {
  position: absolute;
  inset: -1px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 200ms ease, transform 200ms ease;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(229, 231, 235, 0.92);
  pointer-events: none;
}

.brand__logo img {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.22));
  transition: opacity 200ms ease;
}

.brand__titles {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__name {
  font-weight: 800;
  letter-spacing: 0.2px;
}

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

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  border-color: rgba(66, 171, 228, 0.35);
  background: linear-gradient(135deg, rgba(66, 171, 228, 0.95), rgba(56, 151, 208, 0.78));
  box-shadow: 0 12px 26px rgba(66, 171, 228, 0.10);
}

.btn--primary:hover {
  background: linear-gradient(135deg, rgba(66, 171, 228, 1), rgba(56, 151, 208, 0.88));
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
}

.btn--danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.10);
}

.btn--danger:hover {
  background: rgba(239, 68, 68, 0.16);
}

.sidebar__actions {
  display: flex;
  gap: 10px;
}

.sidebar__actions .btn {
  flex: 1;
}

.chat-list {
  flex: 1;
  overflow: auto;
  padding-right: 4px;
}

.chat-list::-webkit-scrollbar,
.messages::-webkit-scrollbar {
  width: 10px;
}

.chat-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chat-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  text-align: left;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-item--active {
  background: rgba(66, 171, 228, 0.12);
  border-color: rgba(66, 171, 228, 0.35);
}

.chat-item__icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.chat-item__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item__title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item__time {
  font-size: 12px;
  color: var(--muted);
}

.sidebar__footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  position: relative;
}

.user-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  text-align: left;
}

.user-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.user-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.user-btn__avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.user-btn__name {
  min-width: 0;
  flex: 1;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-btn__chevron {
  color: rgba(229, 231, 235, 0.7);
  flex: 0 0 auto;
}

.menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 56px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 45;
}

.menu[hidden] {
  display: none;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.menu-item:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.24);
}

/* Sidebar collapsed (как иконки в ChatGPT) */
.sidebar.sidebar--collapsed {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

.sidebar.sidebar--collapsed .brand__titles,
.sidebar.sidebar--collapsed .nav-item__text,
.sidebar.sidebar--collapsed .chat-search,
.sidebar.sidebar--collapsed .chat-list,
.sidebar.sidebar--collapsed .user-btn__name,
.sidebar.sidebar--collapsed .user-btn__chevron {
  display: none;
}

.sidebar.sidebar--collapsed #sidebarCollapseBtn {
  opacity: 0;
  pointer-events: none;
}

.sidebar.sidebar--collapsed .brand--button {
  cursor: pointer;
}

.sidebar.sidebar--collapsed .brand__logo:hover .brand__logo-overlay {
  opacity: 1;
  transform: scale(1);
}

.sidebar.sidebar--collapsed .brand__logo:hover img {
  opacity: 0.25;
}

.sidebar.sidebar--collapsed .menu {
  left: 8px;
  right: auto;
  width: 220px;
  transform: translateX(68px);
  bottom: 56px;
}

.sidebar.sidebar--collapsed .user-btn {
  justify-content: center;
  gap: 0;
  padding: 10px;
}


.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  backdrop-filter: blur(10px);
}

.topbar__left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar__title {
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.75);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.10);
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 14px 0;
}

.msg-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px 18px;
}

.msg-row--assistant {
  background: rgba(255, 255, 255, 0.02);
}

.msg-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 14px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(229, 231, 235, 0.92);
  font-weight: 900;
}

.avatar--assistant {
  border-color: rgba(66, 171, 228, 0.35);
  background: rgba(66, 171, 228, 0.14);
  color: rgba(191, 233, 255, 0.95);
}

.msg-content {
  min-width: 0;
  line-height: 1.58;
  font-size: 15px;
}

.msg-content p {
  margin: 0 0 10px;
}

.msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content a {
  color: rgba(147, 197, 253, 1);
}

.msg-content pre {
  background: rgba(2, 6, 23, 0.60);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  overflow: auto;
  margin: 10px 0;
}

.msg-content code {
  background: rgba(2, 6, 23, 0.60);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
}

.msg-content pre code {
  border: none;
  background: transparent;
  padding: 0;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.msg-debug {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.debug-section {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(2, 6, 23, 0.35);
  border-radius: 14px;
  overflow: hidden;
}

.debug-section > summary {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: rgba(229, 231, 235, 0.78);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.debug-section > summary::-webkit-details-marker {
  display: none;
}

.debug-section > summary::before {
  content: '▸';
  color: rgba(156, 163, 175, 0.92);
  transform: translateY(-1px);
  transition: transform 160ms ease;
}

.debug-section[open] > summary::before {
  transform: rotate(90deg) translateY(-1px);
}

.debug-body {
  padding: 0 12px 12px;
}

.debug-steps {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.debug-steps > li {
  margin: 0;
}

.debug-step {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(2, 6, 23, 0.22);
  border-radius: 12px;
  overflow: hidden;
}

.debug-step > summary {
  padding: 9px 10px;
  cursor: pointer;
  font-size: 12px;
  color: rgba(229, 231, 235, 0.78);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.debug-step > summary::-webkit-details-marker {
  display: none;
}

.debug-step > summary::before {
  content: '▸';
  color: rgba(156, 163, 175, 0.92);
  transition: transform 160ms ease;
  display: inline-block;
}

.debug-step[open] > summary::before {
  transform: rotate(90deg);
}

.debug-step__idx {
  color: rgba(156, 163, 175, 0.92);
  font-weight: 800;
}

.debug-step__tool {
  font-weight: 800;
}

.debug-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(229, 231, 235, 0.72);
}

.debug-badge--running {
  border-color: rgba(66, 171, 228, 0.28);
  background: rgba(66, 171, 228, 0.12);
  color: rgba(191, 233, 255, 0.95);
}

.debug-badge--ok {
  border-color: rgba(34, 197, 94, 0.22);
  background: rgba(34, 197, 94, 0.10);
  color: rgba(187, 247, 208, 0.95);
}

.debug-badge--error {
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.12);
  color: rgba(254, 202, 202, 0.95);
}

.debug-kv {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: rgba(229, 231, 235, 0.80);
}

.debug-kv__k {
  flex: 0 0 auto;
  width: 76px;
  color: rgba(156, 163, 175, 0.92);
  font-weight: 800;
}

.debug-kv__v {
  min-width: 0;
  color: rgba(229, 231, 235, 0.82);
}

.debug-kv--error .debug-kv__v {
  color: rgba(254, 202, 202, 0.95);
}

.debug-pre {
  margin: 10px 0 0;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.5;
}

.debug-pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.debug-chunk {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(2, 6, 23, 0.25);
  border-radius: 12px;
  margin-top: 10px;
  overflow: hidden;
}

.debug-chunk > summary {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  color: rgba(229, 231, 235, 0.72);
  user-select: none;
  list-style: none;
}

.debug-chunk > summary::-webkit-details-marker {
  display: none;
}

.debug-chunk > summary::before {
  content: '▸';
  margin-right: 8px;
  color: rgba(156, 163, 175, 0.92);
  transition: transform 160ms ease;
  display: inline-block;
}

.debug-chunk[open] > summary::before {
  transform: rotate(90deg);
}

.debug-think {
  color: rgba(229, 231, 235, 0.85);
  font-size: 13.5px;
}

.debug-think p {
  margin: 0 0 10px;
}

.debug-think p:last-child {
  margin-bottom: 0;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(229, 231, 235, 0.55);
  animation: dotBounce 1.1s infinite;
}

.dot:nth-child(2) {
  animation-delay: 0.12s;
}

.dot:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes dotBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  backdrop-filter: blur(10px);
  padding: 14px 18px 18px;
}

.composer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  min-height: 46px;
  /* высота ограничивается JS до 8 строк */
  max-height: none;
  resize: none;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.60);
  padding: 12px 14px;
  outline: none;
  font-size: 15px;
  line-height: 20px;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.composer textarea:focus {
  border-color: rgba(66, 171, 228, 0.55);
  box-shadow: 0 0 0 3px rgba(66, 171, 228, 0.16);
}

.composer textarea::-webkit-scrollbar {
  width: 10px;
}

.composer textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.composer textarea::-webkit-scrollbar-track {
  background: transparent;
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(66, 171, 228, 0.35);
  background: linear-gradient(135deg, rgba(66, 171, 228, 0.95), rgba(56, 151, 208, 0.78));
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
}

.send-btn:hover {
  background: linear-gradient(135deg, rgba(66, 171, 228, 1), rgba(56, 151, 208, 0.88));
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hint {
  max-width: var(--max-width);
  margin: 8px auto 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.hint kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 2px 6px;
  border-radius: 8px;
}

.note {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 18px 2px;
  font-size: 12px;
  color: rgba(229, 231, 235, 0.72);
}

.note strong {
  color: rgba(229, 231, 235, 0.92);
}

.auth {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(1000px 700px at 15% 15%, rgba(66, 171, 228, 0.14), transparent 60%),
    rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  z-index: 50;
}

.auth[hidden] {
  display: none;
}

.auth-card {
  width: min(520px, 100%);
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}

.auth-card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.60);
  padding: 12px 14px;
  outline: none;
}

.auth-form input:focus {
  border-color: rgba(66, 171, 228, 0.55);
  box-shadow: 0 0 0 3px rgba(66, 171, 228, 0.16);
}

.auth-form .btn {
  width: 100%;
}

.auth-error {
  margin-top: 10px;
  color: rgba(239, 68, 68, 0.95);
  font-size: 13px;
}

/* Mobile */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-110%);
    transition: transform 0.22s ease;
    box-shadow: 24px 0 80px rgba(0, 0, 0, 0.45);
  }

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

  .topbar {
    padding-left: 12px;
  }

  .topbar__right {
    gap: 8px;
  }
}

