/* S183 NEW CHAT + PROJECT HOME REAL FLOW FIX
   Functional sidebar flow layer. No polling. No backend secrets. */

html body.s183-sidebar-flow .s183-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: grid;
  place-items: center;
  background: rgba(2,4,10,.58);
  backdrop-filter: blur(10px);
}

html body.s183-sidebar-flow .s183-modal[hidden] {
  display: none !important;
}

html body.s183-sidebar-flow #modal-create-project {
  z-index: 11100;
  pointer-events: auto;
}

html body.s183-sidebar-flow #modal-create-project[hidden] {
  display: none !important;
  pointer-events: none !important;
}

html body.s183-sidebar-flow #modal-create-project .modal-card {
  max-height: calc(100vh - 40px);
  overflow: auto;
}

html body.s183-sidebar-flow #form-create-project .auth-submit {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.s183-card {
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(12,14,20,.97);
  box-shadow: 0 24px 80px rgba(0,0,0,.42);
}

.s183-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 10px;
}

.s183-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.s183-sub {
  margin: 5px 0 0;
  color: var(--tx-3, rgba(232,236,245,.62));
  font-size: 12.5px;
  line-height: 1.4;
}

.s183-close {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--tx-2);
}

.s183-form {
  display: grid;
  gap: 12px;
  padding: 8px 20px 20px;
}

.s183-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.s183-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--tx-3, rgba(232,236,245,.62));
}

.s183-field.full {
  grid-column: 1 / -1;
}

.s183-input,
.s183-select,
.s183-textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(255,255,255,.035);
  color: var(--tx-1, #f3f6ff);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.s183-textarea {
  min-height: 68px;
  resize: vertical;
}

.s183-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.s183-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: var(--tx-1, #f3f6ff);
}

.s183-btn.primary {
  background: linear-gradient(135deg, rgba(14,165,233,.92), rgba(59,130,246,.8));
  border-color: transparent;
  color: #fff;
}

.s183-error {
  color: var(--ac-red, #ef8354);
  font-size: 12px;
}

.s183-project-home {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 22px 22px 42px;
}

.s183-home-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.s183-home-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0;
}

.s183-home-head p {
  margin: 6px 0 0;
  color: var(--tx-3);
  font-size: 13px;
}

.s183-home-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.s183-search {
  min-width: 220px;
}

.s183-project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.s183-project-card {
  display: grid;
  gap: 10px;
  text-align: left;
  padding: 14px;
  min-height: 148px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
  color: var(--tx-1);
}

.s183-project-card:hover {
  background: rgba(255,255,255,.045);
}

.s183-project-card[data-active="true"] {
  border-color: rgba(14,165,233,.38);
  background: rgba(14,165,233,.07);
}

.s183-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.s183-card-meta,
.s183-card-desc,
.s183-card-folder {
  color: var(--tx-3);
  font-size: 12px;
  line-height: 1.35;
}

.s183-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  color: var(--tx-3);
  font-size: 12px;
}

.s183-home-empty {
  border: 1px dashed rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 22px;
  color: var(--tx-3);
}

.history-item.s183-history-item .history-main {
  min-width: 0;
}

.history-item.s183-history-item .history-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.s183-time {
  flex: 0 0 auto;
  color: var(--tx-3);
}

.s183-see-more {
  margin: 4px 4px 0;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--tx-3);
  text-align: left;
}

.s183-see-more:hover {
  background: rgba(255,255,255,.04);
  color: var(--tx-1);
}

.s183-context-menu {
  position: fixed;
  z-index: 12000;
  min-width: 178px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px;
  background: rgba(14,16,22,.98);
  box-shadow: 0 18px 48px rgba(0,0,0,.35);
}

.s183-menu-item {
  width: 100%;
  display: block;
  text-align: left;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--tx-1);
  font-size: 13px;
}

.s183-menu-item:hover {
  background: rgba(255,255,255,.055);
}

.s183-menu-item.danger {
  color: var(--ac-red, #ef8354);
}

.s183-menu-sep {
  height: 1px;
  margin: 4px;
  background: rgba(255,255,255,.07);
}

@media (max-width: 760px) {
  .s183-grid,
  .s183-home-head {
    grid-template-columns: 1fr;
    display: grid;
  }
  .s183-home-tools {
    flex-wrap: wrap;
  }
  .s183-search {
    min-width: 0;
    width: 100%;
  }
}
