/* ChatLLLM — static ChatGPT-like shell */

:root {
  --sidebar-bg: #f9f9f9;
  --sidebar-border: #e8e8e8;
  --main-bg: #fff;
  --text: #0d0d0d;
  --text-muted: #8e8e8e;
  --composer-border: #e5e5e5;
  --composer-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --user-bubble: #f4f4f4;
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 52px;
  --header-h: 52px;
  --radius-pill: 999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--main-bg);
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.icon {
  width: 22px;
  height: 22px;
  display: block;
}

.icon--sm {
  width: 18px;
  height: 18px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

.icon-btn:focus-visible {
  outline: 2px solid #0d0d0d;
  outline-offset: 2px;
}

.icon-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.icon-btn--ghost:disabled {
  opacity: 1;
}

.app {
  display: flex;
  height: 100%;
  min-height: 0;
}

/* Sidebar */

.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-width);
  min-height: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 10px 12px 16px;
  transition: width 0.2s ease, padding 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
  padding-left: 8px;
  padding-right: 8px;
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 12px;
}

.sidebar.collapsed .sidebar__top {
  flex-direction: column;
  gap: 8px;
}

.sidebar__logo {
  padding: 6px;
}

.sidebar.collapsed .sidebar__logo {
  order: 1;
}

.sidebar.collapsed #btn-sidebar-toggle {
  order: 0;
}

.btn-new-chat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-top: 20px;
  margin-bottom: 0px;
  border: 1px solid var(--sidebar-border);
  border-radius: 10px;
  background: var(--main-bg);
  font: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.btn-new-chat:hover {
  background: #f0f0f0;
}

.btn-new-chat:focus-visible {
  outline: 2px solid #0d0d0d;
  outline-offset: 2px;
}

.sidebar.collapsed .btn-new-chat {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .btn-new-chat__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.sidebar__shortcuts {
  flex-shrink: 0;
  margin-bottom: 16px;
}

.sidebar__shortcuts-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__shortcut {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.sidebar__shortcut:hover {
  background: rgba(0, 0, 0, 0.06);
}

.sidebar__shortcut:focus-visible {
  outline: 2px solid #0d0d0d;
  outline-offset: 2px;
}

.sidebar__shortcut-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.sidebar__shortcut-icon .icon {
  width: 22px;
  height: 22px;
}

.sidebar__shortcut-label {
  flex: 1;
  min-width: 0;
}

.sidebar.collapsed .sidebar__shortcut {
  justify-content: center;
  padding: 9px 10px;
}

.sidebar.collapsed .sidebar__shortcut-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.sidebar__blurb {
  margin: 0;
  padding: 0 8px;
  font-size: 13px;
  line-height: 1.55;
  color: #5c5c5c;
  text-align: center;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar__blurb {
  display: none;
}

.sidebar__chats-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 0px;
  margin-bottom: 12px;
}

.sidebar.collapsed .sidebar__chats-wrap {
  display: none;
}

.sidebar__chats {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__chats-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
  padding: 4px 8px 8px;
  margin: 0;
  list-style: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.sidebar__chats-summary::-webkit-details-marker {
  display: none;
}

.sidebar__chats-title {
  flex: 1;
  text-align: left;
}

.sidebar__chats-chevron {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.sidebar__chats:not([open]) .sidebar__chats-chevron {
  transform: rotate(-90deg);
}

.sidebar__chats-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 4px 4px;
  -webkit-overflow-scrolling: touch;
}

.sidebar__chats-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar__chat-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-radius: 8px;
  margin-bottom: 2px;
}

.sidebar__chat-row:last-child {
  margin-bottom: 0;
}

.sidebar__chat-row:hover,
.sidebar__chat-row:focus-within {
  background: rgba(0, 0, 0, 0.06);
}

.sidebar__chat-pick {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__chat-pick:hover {
  background: transparent;
}

.sidebar__chat-pick:focus-visible {
  outline: 2px solid #0d0d0d;
  outline-offset: 0;
  z-index: 1;
}

.sidebar__water {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--sidebar-border);
  border-radius: 10px;
  background: #ffffff;
}

.sidebar__water-label {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar__water-value {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.sidebar.collapsed .sidebar__water {
  display: none;
}

/* Main */

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--main-bg);
}

.main-header {
  flex-shrink: 0;
  height: var(--header-h);
  padding: 0 16px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
}

.main-header__start {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.main-header__menu-btn {
  display: none;
  flex-shrink: 0;
}

.main-header__logo-mark {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.main-header__logo-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.main-header__title-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  margin-left: -6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: default;
}

.main-header__title {
  letter-spacing: -0.02em;
  font-size: 120%;
}

.icon--chevron {
  color: var(--text-muted);
  margin-top: 2px;
}

.main-header__actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.main__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Empty state */

.empty-state {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 120px;
  gap: 28px;
}

.empty-state__title {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-align: center;
}

/* Chat panel */

.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Full-width scroll so the scrollbar sits at the main pane edge, not beside the narrow column. */
.messages-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.messages {
  box-sizing: border-box;
  max-width: 768px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding: 24px 16px 120px;
}

.message-row {
  display: flex;
  margin-bottom: 20px;
}

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

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

.message-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row--user .message-bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 6px;
}

.message-row--assistant .message-bubble {
  background: transparent;
  padding-left: 4px;
  max-width: 100%;
}

/* Composer */

.composer {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.composer--dock {
  flex-shrink: 0;
  padding: 12px 16px 24px;
  background: linear-gradient(to top, var(--main-bg) 70%, rgba(255, 255, 255, 0));
}

.composer__pill {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 10px 8px 6px;
  border: 1px solid var(--composer-border);
  border-radius: var(--radius-pill);
  background: var(--main-bg);
  box-shadow: var(--composer-shadow);
}

.composer__field {
  flex: 1;
  min-width: 0;
  display: flex;
}

.composer__input {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  resize: none;
  max-height: 200px;
  padding: 8px 4px;
  margin: 0;
}

.composer__input::placeholder {
  color: var(--text-muted);
}

.composer__input:focus {
  outline: none;
}

.composer__attach,
.composer__mic {
  flex-shrink: 0;
  align-self: center;
  color: var(--text-muted);
}

.composer__send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: #0d0d0d;
  color: #fff;
  cursor: pointer;
  align-self: center;
}

.composer__send:hover {
  background: #2a2a2a;
}

.composer__send:focus-visible {
  outline: 2px solid #0d0d0d;
  outline-offset: 2px;
}

.icon--send-wave {
  width: 18px;
  height: 18px;
}

.icon--send-wave rect {
  fill: currentColor;
}

@media (max-width: 640px) {
  .sidebar.collapsed {
    display: none;
  }

  .sidebar:not(.collapsed) {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(280px, 85vw);
    display: flex;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.08);
  }

  .main .main-header__logo-mark {
    display: flex;
  }

  .sidebar:not(.collapsed) ~ .main .main-header__menu-btn {
    display: none;
  }

  .sidebar.collapsed ~ .main .main-header__menu-btn {
    display: inline-flex;
  }

  .empty-state__title {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }

  .img-gen-skeleton {
    animation: none;
    background: #e8e8ea;
  }

  .img-gen-spinner,
  .img-gen-icon {
    animation: none;
  }

  .img-gen-label {
    animation: none;
    opacity: 0.85;
  }
}

/* Image generation spinner (skeleton matches .msg-generated-image size & radius) */

.img-gen-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: 380px;
  width: 100%;
}

/* Placeholder footprint: matches .msg-generated-image width; neutral ratio for mixed assets in img/gen/ */
.img-gen-skeleton {
  position: relative;
  width: 100%;
  min-width: 380px;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  box-sizing: border-box;
  background: linear-gradient(
    110deg,
    #e8e8ea 0%,
    #ececec 40%,
    #f2f2f4 50%,
    #ececec 60%,
    #e8e8ea 100%
  );
  background-size: 200% 100%;
  animation: img-gen-skeleton-shimmer 1.4s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
}

.img-gen-spinner {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-top-color: #0d0d0d;
  animation: img-gen-spin 1s linear infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.65);
}

.img-gen-icon {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  flex-shrink: 0;
  animation: img-gen-spin 1s linear infinite reverse;
}

.img-gen-label {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  animation: img-gen-pulse 1.4s ease-in-out infinite;
}

@keyframes img-gen-skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes img-gen-spin {
  to { transform: rotate(360deg); }
}

@keyframes img-gen-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Generated image result */

.msg-generated-image {
  display: block;
  max-width: 380px;
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
}
