:root {
  color-scheme: light dark;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --bg: #171717;
  --bg-deep: #121212;
  --surface: #232323;
  --surface-soft: #2a2a2a;
  --border: #414141;
  --text: #ececec;
  --muted: #b6b6b6;
  --accent: #c64600;
  --accent-soft: #ffbe6f;
  --accent-hover: #da5a11;
}

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text);
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.container {
  max-width: 920px;
  margin: 24px auto;
  padding: 0 16px 40px;
}

h1 {
  margin: 0 0 8px;
}

.sub {
  margin: 0 0 16px;
  color: var(--muted);
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 2;
}

.light-pillar-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #242424 0%, var(--bg-deep) 58%, #0f0f0f 100%);
  z-index: 0;
}

.pillar {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1080px;
  height: 1080px;
  transform-origin: 50% 58%;
  border-radius: 999px;
  pointer-events: none;
}

.pillar-a {
  background: conic-gradient(from 0deg, transparent 0deg, rgba(198, 70, 0, 0.84) 70deg, rgba(255, 190, 111, 0.3) 120deg, transparent 180deg);
  filter: blur(10px);
  transform: translate(-50%, -50%) rotate(0deg) scaleX(0.34) scaleY(0.72);
  animation: spin-a 26s linear infinite;
}

.pillar-b {
  background: conic-gradient(from 180deg, transparent 0deg, rgba(255, 190, 111, 0.62) 78deg, rgba(198, 70, 0, 0.26) 130deg, transparent 190deg);
  filter: blur(16px);
  transform: translate(-50%, -50%) rotate(60deg) scaleX(0.31) scaleY(0.68);
  animation: spin-b 34s linear infinite reverse;
}

.pillar.glow {
  background: radial-gradient(ellipse at 50% 58%, rgba(198, 70, 0, 0.13) 0%, rgba(255, 190, 111, 0.09) 38%, transparent 70%);
  transform: translate(-50%, -50%) scale(0.96);
  filter: blur(28px);
}

@keyframes spin-a {
  from { transform: translate(-50%, -50%) rotate(0deg) scaleX(0.34) scaleY(0.72); }
  to { transform: translate(-50%, -50%) rotate(360deg) scaleX(0.34) scaleY(0.72); }
}

@keyframes spin-b {
  from { transform: translate(-50%, -50%) rotate(0deg) scaleX(0.31) scaleY(0.68); }
  to { transform: translate(-50%, -50%) rotate(360deg) scaleX(0.31) scaleY(0.68); }
}

.login-card {
  width: 100%;
  max-width: 520px;
  background: rgba(35, 35, 35, 0.88);
  border: 1px solid rgba(255, 190, 111, 0.28);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(5px);
}

.brand-logo {
  display: block;
  width: 116px;
  max-width: 48%;
  margin: 2px auto 8px;
  object-fit: contain;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 8px;
}

.login-card .sub {
  text-align: center;
  margin-bottom: 20px;
}

.app-layout {
  margin-top: 20px;
  position: relative;
  z-index: 2;
}

.app-shell {
  height: 100vh;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.app-topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 20, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 650;
}

.brand-logo-small {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.incognito-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--muted);
  border: 1px solid #3f3f3f;
  border-radius: 999px;
  padding: 4px 10px;
  background: #1d1d1d;
}

.incognito-toggle:disabled,
.incognito-toggle.locked {
  opacity: 0.72;
  cursor: not-allowed;
}

.incognito-toggle i {
  font-size: 1.2rem;
  line-height: 1;
}

.incognito-toggle.on i {
  color: var(--accent-soft);
}

.incognito-toggle.off i {
  color: #a6a6a6;
}

.app-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: rgba(22, 22, 22, 0.72);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  grid-auto-rows: min-content;
  gap: 6px;
  padding-right: 4px;
}

.sidebar-scroll > * + * {
  border-top: 1px solid #2f2f2f;
  margin-top: 6px;
  padding-top: 8px;
}

.section-divider {
  border-top: 1px solid #2f2f2f;
  margin-top: 6px;
  padding-top: 8px;
}

.sidebar-bottom {
  display: grid;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid #353535;
}

.menu-group {
  display: grid;
  gap: 4px;
}

.menu-item,
.menu-sub {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
}

.menu-item i,
.menu-sub i,
.menu-list button i {
  font-size: 1rem;
  color: #cfd2d7;
}

.menu-item:hover,
.menu-sub:hover,
.menu-list button:hover {
  background: #2a2a2a;
  border-color: #444;
}

.menu-sub {
  margin-left: 10px;
  color: var(--muted);
}

.menu-list {
  display: grid;
  gap: 3px;
  margin-left: 20px;
}

.chat-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
}

.chat-list-open {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-delete-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #5c2d2d;
  background: transparent;
  color: #ff7474;
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-delete-btn:hover {
  background: #3a1919;
}

.chat-list-row:hover .chat-delete-btn {
  opacity: 1;
  pointer-events: auto;
}

.menu-list button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 400;
  text-align: left;
  padding: 7px 9px;
}

.menu-item.danger {
  color: #ffb088;
}

.sidebar-user {
  margin-top: 4px;
  padding: 6px 10px 2px;
  color: #b6b6b6;
  font-size: 0.84rem;
}

.content-area {
  padding: 18px;
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.view-panel {
  background: rgba(31, 31, 31, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 0;
  height: 100%;
  padding: 20px;
  overflow: hidden;
  box-sizing: border-box;
}

.chat-layout {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100%;
  min-height: 0;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-view-title {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
}

.chat-title-edit {
  border: 1px solid #4a4a4a;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chat-title-edit i {
  line-height: 1;
  display: block;
}

.chat-title-edit:hover {
  background: #2b2b2b;
  color: #e4e4e4;
}

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  background: rgba(18, 18, 18, 0.42);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-messages::before {
  content: '';
  flex: 1 0 8px;
}

.message {
  width: fit-content;
  max-width: 85%;
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
  border: 1px solid #3b3b3b;
}

.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
  margin: 0 0 8px;
  line-height: 1.25;
}

.message p {
  margin: 0 0 8px;
}

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

.message ul,
.message ol {
  margin: 0 0 8px 20px;
  padding: 0;
}

.message code {
  background: #292929;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.9em;
}

.message pre {
  margin: 0 0 8px;
  background: #161616;
  border: 1px solid #3e3e3e;
  border-radius: 10px;
  padding: 10px;
  overflow: auto;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message pre code {
  border: 0;
  background: transparent;
  padding: 0;
  white-space: inherit;
}

.message table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0 0 8px;
}

.message th,
.message td {
  border: 1px solid #3f3f3f;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.message.assistant {
  align-self: flex-start;
  background: rgba(27, 27, 27, 0.78);
}

.message.user {
  align-self: flex-end;
  background: rgba(42, 42, 42, 0.78);
  border-color: #4b4b4b;
}

.chat-working {
  margin: 8px 2px 2px;
  font-size: 0.85rem;
  color: #bbbbbb;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chat-working i {
  color: var(--accent-soft);
  animation: spin-loader 0.9s linear infinite;
}

@keyframes spin-loader {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.chat-composer-wrap {
  margin-top: 12px;
  border: 1px solid #494949;
  border-radius: 12px;
  background: rgba(27, 27, 27, 0.76);
  padding: 10px;
}

.chat-composer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.chat-composer {
  min-height: 86px;
  resize: vertical;
}

.chat-send {
  align-self: end;
  min-width: 84px;
}

.chat-disclaimer {
  margin: 8px 0 2px;
  text-align: center;
  color: #b9b9b9;
  font-style: italic;
  font-size: 0.85rem;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.chats-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.standalone-trash-toggle-pill {
  opacity: 1;
  pointer-events: auto;
}

.invite-box {
  border: 1px dashed #8c5a2f;
  border-radius: 12px;
  padding: 20px;
  background: #1b1b1b;
}

.invite-box textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  margin-top: 10px;
}

.simple-list {
  display: grid;
  gap: 8px;
}

.simple-list-item {
  border: 1px solid #3f3f3f;
  border-radius: 10px;
  background: rgba(32, 32, 32, 0.72);
  padding: 10px;
}

.standalone-chat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: min-content;
  align-items: start;
  justify-items: stretch;
  gap: 8px;
}

.standalone-chat-tile {
  grid-column: auto / span 1;
  width: auto;
  min-width: 0;
  display: block;
  text-align: left;
}

.project-detail-layout {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  height: 100%;
}

.project-chat-actions,
.project-files-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.project-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

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

.project-chat-actions button,
.project-files-actions button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.project-files-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.project-section-title {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.project-chats-wrap,
.project-files-wrap {
  min-height: 0;
  overflow: auto;
}

.project-chats-wrap {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: min-content;
  align-items: start;
  gap: 8px;
}

.project-chat-tile {
  background: rgba(35, 35, 35, 0.72);
  border: 1px solid #414141;
  border-radius: 10px;
  text-align: left;
  padding: 10px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-chat-open {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  min-width: 0;
  flex: 1;
  display: block;
}

button.project-chat-open,
button.project-chat-open:hover,
button.project-chat-open:focus {
  background: transparent !important;
  border: 0 !important;
  border-color: transparent !important;
  padding: 0 !important;
}

.project-node-tile.chat .project-file-footer {
  justify-content: space-between;
}

.project-chat-delete,
.project-file-delete {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #5c2d2d;
  background: transparent;
  color: #ff7878;
  opacity: 1;
  pointer-events: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.project-chat-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-chat-time {
  color: var(--muted);
  font-size: 0.8rem;
}

.project-files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-files-actions {
  margin-left: auto;
}

.project-files-wrap {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: min-content;
  align-items: start;
  gap: 8px;
}

.project-node-tile {
  border: 1px solid #414141;
  border-radius: 10px;
  background: rgba(34, 34, 34, 0.7);
  min-height: 0;
  padding: 10px;
  text-align: left;
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
}

.project-node-tile.folder {
  cursor: pointer;
}

.project-node-title {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
}

.project-node-title i {
  font-size: 1rem;
  color: #d9d9d9;
}

.project-node-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-node-time {
  color: var(--muted);
  font-size: 0.8rem;
}

.project-file-status {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  border: 1px solid transparent;
}

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

.project-file-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.project-file-status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.trash-countdown {
  color: #ff8a8a;
  font-size: 0.72rem;
  font-weight: 600;
}

.project-file-status.processing {
  color: #ffbe6f;
  border-color: #8c5a2f;
  background: rgba(140, 90, 47, 0.18);
}

.project-file-status.ready {
  color: #7de38f;
  border-color: #2f7a42;
  background: rgba(47, 122, 66, 0.2);
}

.project-file-status.trashed {
  color: #ffb088;
  border-color: #7b3d21;
  background: rgba(123, 61, 33, 0.2);
}

.project-file-retry {
  position: static;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #2f5169;
  background: transparent;
  color: #8fcfff;
  opacity: 1;
  pointer-events: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.project-file-restore {
  position: static;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #2f7a42;
  background: transparent;
  color: #7de38f;
  opacity: 1;
  pointer-events: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.project-chat-delete:hover,
.project-chat-delete:focus,
.project-file-delete:hover,
.project-file-delete:focus {
  background: #3a1919;
}

.project-file-restore:hover,
.project-file-restore:focus {
  background: rgba(47, 122, 66, 0.2);
}

.project-file-retry:hover {
  background: #162534;
}

.project-delete-warning {
  color: #ffb088;
  font-weight: 600;
}

.pill {
  display: inline-block;
  border: 1px solid #6a6a6a;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 2px 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  display: grid;
  place-items: center;
  z-index: 10000;
}

.modal-card {
  width: min(520px, calc(100vw - 26px));
  background: #232323;
  border: 1px solid #4c4c4c;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.4);
}

.modal-card h3 {
  margin: 0 0 10px;
}

.card {
  background: rgba(35, 35, 35, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

h2 {
  margin-top: 0;
  font-size: 1.08rem;
}

.row {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.row.two {
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.row.inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

input,
select,
textarea,
button {
  border-radius: 8px;
  border: 1px solid #4a4a4a;
  background: #1d1d1d;
  color: var(--text);
  padding: 9px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(198, 70, 0, 0.55);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  background: var(--accent);
  border-color: #ac3c00;
}

button:hover {
  background: var(--accent-hover);
}

button.ghost {
  background: transparent;
  border-color: #595959;
}

button.ghost:hover {
  background: #2a2a2a;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-soft);
  padding: 2px 0;
  width: fit-content;
}

.link-button:hover {
  background: transparent;
  color: #ffd7a8;
}

.output {
  background: #181818;
  border: 1px solid #363636;
  border-radius: 8px;
  min-height: 40px;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

.files-list {
  display: grid;
  gap: 8px;
}

.file-item {
  border: 1px solid #383838;
  border-radius: 8px;
  padding: 10px;
  background: #1d1d1d;
  display: grid;
  gap: 6px;
}

.file-meta {
  font-size: 0.9rem;
  opacity: 0.9;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #5a5a5a;
  background: #1f1f1f;
  color: var(--text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 9999;
}

.toast #toastMessage {
  flex: 1;
}

.toast-close {
  border: 1px solid #575757;
  background: transparent;
  color: var(--text);
  width: 24px;
  height: 24px;
  line-height: 1;
  border-radius: 6px;
  padding: 0;
  font-size: 16px;
}

.toast-close:hover {
  background: #333333;
}

.toast.success {
  border-color: #c56b20;
  background: #352213;
}

.toast.error {
  border-color: #8e3b1a;
  background: #31180e;
}

.toast.info {
  border-color: #8c5a2f;
  background: #2f2115;
}
