:root {
  --color-orange: #faa652;
  --color-blue: #3b3db8;
  --color-white: #ffffff;
  --color-sidebar-bg: #faa652;
  --color-header-bg: #3b3db8;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #faf7f2 0%, #f4efe8 100%);
  color: #111827;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}
.mobile-backdrop {
  display: none;
  pointer-events: none;
}

.app-shell {
  width: 100%;
  max-width: 1400px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  backdrop-filter: blur(10px);
}

.sidebar {
  width: 280px;
  background: #faa652;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 16px;
  transition: transform 0.25s ease;
  z-index: 40;
}
.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.sidebar-btn,
.nav-btn,
.top-btn,
#sendBtn,
.history-item,
.menu-toggle-btn {
  border: 0;
  cursor: pointer;
  transition: 0.2s ease;
}

.sidebar-btn.primary {
  background: #3b3db8;
  color: white;
  padding: 12px 14px;
  border-radius: 14px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

.sidebar-btn.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.history-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-title {
  font-size: 0.82rem;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.history-item {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.35;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.25);
}

.history-item.active {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.history-empty {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 8px 4px;
}

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

.nav-btn {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.sidebar-bottom {
  padding-top: 6px;
}

.mini-note {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  line-height: 1.45;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  padding-top: max(18px, calc(env(safe-area-inset-top) + 12px));
  background: #3b3db8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
}
.topbar-left-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.menu-toggle-btn {
  display: none;
  background: rgba(30, 41, 59, 0.82);
  color: #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  flex-shrink: 0;
}

.topbar-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #ffffff;
}
.topbar-left p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  line-height: 1.4;


}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.top-btn {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.top-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.top-btn.danger {
  color: #ffcccc;
  border-color: rgba(255, 200, 200, 0.35);
}

.top-btn.danger:hover {
  background: rgba(255, 100, 100, 0.2);
}
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: #ffffff;
}
.message {
  display: flex;
  width: 100%;
}

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

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

.content {
  max-width: 78%;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-size: 0.96rem;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.16);
}

.message.assistant .content {
  background: rgba(255, 255, 255, 0.96);
  color: #111827;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom-left-radius: 6px;
}
.message.assistant .content {
  background: rgba(30, 41, 59, 0.9);

  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-bottom-left-radius: 6px;
}

.composer {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 16px 20px;
  padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px));
  background: #3b3db8;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(18px);
}
#messageInput {
  flex: 1;
  background: #3b3db8;
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: #111827;
  border-radius: 18px;
  padding: 14px 16px;
  min-height: 54px;
  max-height: 180px;
  resize: none;
  outline: none;
  font: inherit;
  line-height: 1.45;
}
#messageInput::placeholder {
  color: #64748b;
}

#messageInput:focus {
  border-color: rgba(96, 165, 250, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

#sendBtn {
  background: #faa652;
  color: #fff;
  border-radius: 16px;
  padding: 0 18px;
  height: 54px;
  min-width: 92px;
  font-size: 0.95rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

#sendBtn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

#sendBtn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 900px) {
  .menu-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 70;
  }

  .mobile-backdrop {
    display: none !important;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82vw;
    max-width: 320px;
    background: #faa652;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    z-index: 60;
    overflow-y: auto;
  }

  .sidebar.mobile-visible {
    display: flex;
  }

  .main-panel {
    width: 100%;
  }

  .content {
    max-width: 88%;
  }
}
.hidden {
  display: none !important;
}

.search-panel {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-box {
  display: flex;
}

#searchInput {
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: #0f172a;
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  font: inherit;
  line-height: 1.45;
}

#searchInput::placeholder {
  color: #64748b;
}

#searchInput:focus {
  border-color: rgba(96, 165, 250, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result-item {
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}

.search-result-item:hover {
  background: rgba(241, 245, 249, 1);
}

.search-result-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.search-result-snippet {
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.45;
}

.search-empty {
  color: #64748b;
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 8px 2px;
}
.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.project-main {
  flex: 1;
  text-align: left;
}

.project-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-delete-btn {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.8rem;
}

.project-delete-btn:hover {
  background: rgba(241, 245, 249, 1);
}
.file-card {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.file-main {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  word-break: break-word;
  margin-bottom: 4px;
}

.file-meta {
  font-size: 0.84rem;
  color: #64748b;
  line-height: 1.45;
}

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

.file-btn {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.8rem;
}

.file-btn:hover {
  background: rgba(241, 245, 249, 1);
}

.file-preview {
  background: rgba(248, 250, 252, 1);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.45;
  overflow: hidden;
}

.file-preview img {
  max-width: 100%;
  border-radius: 10px;
  display: block;
}

.file-empty {
  color: #64748b;
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 8px 2px;
}
.composer-tools {
  position: relative;
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
}

.attach-btn {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: #3b3db8;
  color: #0f172a;
  font-size: 1.35rem;
  font-weight: 600;
  cursor: pointer;
}

.attach-btn:hover {
  background: rgba(241, 245, 249, 1);
}

.attach-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  min-width: 160px;
  background: #3b3db8;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 80;
}

.attach-menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #0f172a;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

.attach-menu-item:hover {
  background: rgba(241, 245, 249, 1);
}
.file-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
}

.file-preview-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.file-preview-modal-content {
  position: absolute;
  inset: 5% 5%;
  background: #3b3db8;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.95);
}

.file-preview-modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  word-break: break-word;
}

.file-preview-modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  color: #0f172a;
  background: #ffffff;
}

.file-preview-modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
}

.file-preview-modal-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #0f172a;
}

.file-preview-modal-body iframe,
.file-preview-modal-body embed {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

/* Composer blue background fixes */
.composer textarea {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.composer textarea::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

#morganModeSelect {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
}

.attach-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* History item delete button */
.history-item-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-item-wrapper .history-item {
  flex: 1;
  width: auto;
}

.history-delete-btn {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.history-item-wrapper:hover .history-delete-btn {
  opacity: 1;
}

.history-delete-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

/* Message bubble copy button */
.message {
  position: relative;
}

.message-copy-btn {
  flex-shrink: 0;
  align-self: flex-end;
  background: transparent;
  border: 0;
  color: rgba(100, 116, 139, 0.5);
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  margin-bottom: 4px;
}

.message:hover .message-copy-btn {
  opacity: 1;
}

.message-copy-btn:hover {
  color: #3b3db8;
  background: rgba(59, 61, 184, 0.08);
}
