/* Layout shell styles */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --brand: #065f46;
  --brand-soft: #ecfdf5;
  --danger: #991b1b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(160deg, #f8fafc, #eef2ff);
  color: var(--text);
}
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
h1,
h2,
h3 {
  margin: 0 0 0.75rem 0;
}
p {
  margin: 0.5rem 0;
}
.muted {
  color: var(--muted);
}
.grid {
  display: grid;
  gap: 0.75rem;
}
label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
input,
select,
textarea {
  width: 100%;
  padding: 0.58rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
}
.btn-secondary {
  background: #1f2937;
}
.btn-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #065f46;
  font-size: 0.78rem;
  border: 1px solid #a7f3d0;
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}
ul {
  margin: 0.25rem 0 0.5rem 1rem;
  padding: 0;
}
.errorlist {
  margin: 0.3rem 0;
  color: var(--danger);
  font-size: 0.88rem;
  list-style: none;
  padding: 0;
}
.message {
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.7rem;
  border: 1px solid var(--border);
  background: #fff;
}
.message.success {
  border-color: #86efac;
  background: #f0fdf4;
}
@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Shared project panel styles */
.project-panel {
  position: relative;
  overflow: visible;
}
.project-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}
.project-title-link {
  color: inherit;
  text-decoration: none;
}
.project-title-link:hover {
  color: var(--brand);
  text-decoration: underline;
}
.panel-icon-actions {
  display: inline-flex;
  gap: 0.4rem;
  margin-top: 0.1rem;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: #1f2937;
  cursor: pointer;
}
.icon-btn:hover {
  background: #f9fafb;
}
.project-popup {
  position: absolute;
  top: 3.2rem;
  right: 1rem;
  width: min(420px, calc(100% - 2rem));
  padding: 0.95rem;
  border: 1px solid #9ca3af;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.2);
  z-index: 3;
}
.project-popup--settings {
  width: min(960px, calc(100% - 2rem));
}
.settings-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.settings-content-grid--single {
  grid-template-columns: 1fr;
}
.settings-column {
  min-width: 0;
}
.settings-delete-column {
  padding-left: 1.1rem;
  border-left: 1px dashed #fca5a5;
}
.project-popup[hidden] {
  display: none;
}
.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.popup-header h3,
.danger-zone h4 {
  margin: 0;
}
.popup-close {
  color: var(--muted);
}
.popup-checkbox label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: 0;
  font-weight: 500;
}
.popup-checkbox input {
  width: auto;
  margin-top: 0.2rem;
}
.danger-zone {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.btn-danger {
  background: #b91c1c;
}
.icon-btn.active {
  border-color: #93c5fd;
  background: #eff6ff;
}
@media (max-width: 640px) {
  .project-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .project-popup {
    position: static;
    width: 100%;
    margin-top: 0.8rem;
  }
  .settings-content-grid {
    grid-template-columns: 1fr;
  }
  .settings-delete-column {
    padding-left: 0;
    padding-top: 0.95rem;
    border-left: 0;
    border-top: 1px dashed #fca5a5;
  }
}
@media (max-width: 980px) {
  .project-popup--settings {
    width: min(700px, calc(100% - 2rem));
  }
  .settings-content-grid {
    grid-template-columns: 1fr;
  }
  .settings-delete-column {
    padding-left: 0;
    padding-top: 0.95rem;
    border-left: 0;
    border-top: 1px dashed #fca5a5;
  }
}

/* Project landing workspace, notes, and chat */
.project-workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.project-note-entry-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(140px, 180px) auto auto;
  gap: 0.65rem;
  align-items: end;
}
.project-note-entry-form .actions {
  margin: 0;
}
.project-note-entry-form input,
.project-note-entry-form select {
  margin-top: 0.35rem;
  width: 100%;
}
.project-note-submit-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
  margin-top: 0.35rem;
}
.project-note-submit-prefix {
  color: var(--muted);
  font-size: 0.9rem;
}
.project-note-open-btn {
  margin-top: 0.35rem;
}
.project-note-status {
  margin: 0.65rem 0 0;
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.application-details-panel h2 {
  margin-bottom: 0.35rem;
}
.application-title-form {
  margin-top: 0.75rem;
}
.application-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: stretch;
}
.application-title-row input,
.application-title-row textarea {
  margin: 0;
}
.application-title-row textarea {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  font-variant: normal;
  letter-spacing: normal;
}
.application-title-row textarea::placeholder {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
}
.application-title-actions {
  display: grid;
  gap: 0.35rem;
  align-content: end;
  justify-items: start;
}
.application-title-counter {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.application-title-save-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.project-document-section {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}
.project-document-section h3 {
  margin: 0 0 0.35rem;
}
.project-document-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.65rem 0 0.55rem;
}
.project-document-control-row {
  margin: 0 0 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: nowrap;
}
.project-document-style-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  min-width: 2.25rem;
}
.project-document-style-btn.active {
  border-color: #93c5fd;
  background: #eff6ff;
}
.project-document-editor-frame {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 180px;
  background: #fff;
  padding: 0.55rem 0.65rem;
  cursor: text;
}
.project-document-editor-frame .DraftEditor-root {
  min-height: 145px;
}
.project-document-actions {
  margin-top: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.8rem;
}
.project-document-update-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.project-document-docx-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.project-document-docx-btn {
  min-height: 2rem;
  border-radius: 6px;
  border: 1px solid #1d4ed8;
  background: #1d4ed8;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  line-height: 1.1;
  white-space: nowrap;
}
.project-document-docx-btn[aria-disabled="true"] {
  border-color: #9ca3af;
  background: #9ca3af;
  color: #fff;
  cursor: not-allowed;
  pointer-events: none;
}
.project-document-docx-btn:hover:not([aria-disabled="true"]),
.project-document-refresh-btn:hover:not([disabled]) {
  background: #1e40af;
  border-color: #1e40af;
}
.project-document-docx-btn:focus-visible,
.project-document-refresh-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.project-document-refresh-btn {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 6px;
  border: 1px solid #1d4ed8;
  background: #1d4ed8;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  font-size: 0.9rem;
}
.project-document-refresh-btn[disabled] {
  border-color: #9ca3af;
  background: #9ca3af;
  color: #fff;
  cursor: not-allowed;
}
.project-document-status {
  margin: 0.55rem 0 0;
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.project-notes-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(17, 24, 39, 0.42);
  padding: 1rem;
}
.project-notes-modal-backdrop[hidden] {
  display: none;
}
.project-notes-modal {
  position: relative;
  width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.project-notes-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.55rem;
}
.project-notes-modal-header h2 {
  margin: 0;
}
.project-notes-list-status {
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.project-notes-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  background: #ffffff;
  max-height: calc(100vh - 11rem);
}
.project-notes-table {
  width: 100%;
  border-collapse: collapse;
}
.project-notes-table th,
.project-notes-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.9rem;
}
.project-notes-table tbody tr:last-child td {
  border-bottom: 0;
}
.project-notes-table th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 1;
}
.project-notes-sort-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin-left: 0.25rem;
  color: #4b5563;
  font-size: 0.82rem;
}
.project-notes-sort-btn.active {
  color: #111827;
}
.project-note-text-wrap {
  display: grid;
  gap: 0.4rem;
}
.project-note-inline-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
}
.project-note-inline-edit[hidden] {
  display: none;
}
.project-note-inline-edit input {
  margin: 0;
}
.project-note-action-buttons {
  display: inline-flex;
  gap: 0.35rem;
}
.project-note-action-icon {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  line-height: 1;
}
.project-note-action-icon:hover {
  background: #f9fafb;
}
.project-note-empty {
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}
.chat-panel {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  position: relative;
}
.chat-panel-top h2 {
  margin: 0;
  font-size: 1rem;
}
.chat-settings-popup {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  width: min(360px, calc(100vw - 2rem));
  z-index: 5;
}
.chat-settings-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.6rem;
}
.chat-settings-actions .btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
}
.chat-settings-note {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}
.chat-history {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem;
  overflow-y: auto;
  background: #f8fafc;
  min-height: 300px;
  max-height: 60vh;
}
.chat-empty {
  font-size: 0.9rem;
  color: var(--muted);
}
.chat-entry {
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid transparent;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.3;
}
.chat-entry-body {
  font-size: 12px;
  line-height: 1.3;
}
.chat-entry-body p {
  margin: 0 0 0.35rem;
}
.chat-entry-body ul {
  margin: 0.35rem 0;
  padding-left: 1.05rem;
}
.chat-entry-body li {
  margin-bottom: 0.25rem;
}
.chat-entry-body strong {
  font-weight: 600;
}
.chat-entry--prompt {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #374151;
}
.chat-entry--response {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #000000;
}
.chat-entry-meta {
  display: block;
  color: #6b7280;
  font-size: 7px;
  line-height: 1;
  margin-top: 0.3rem;
}
.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: stretch;
}
.chat-composer .chat-input-wrap {
  min-width: 0;
}
.chat-composer textarea {
  width: 100%;
  min-height: 0;
  resize: none;
  font: 400 12px/1.3 sans-serif;
}
.chat-composer textarea::placeholder {
  font-family: sans-serif;
  font-size: 12px;
  line-height: 1.3;
}
.chat-composer .actions {
  margin: 0;
  display: flex;
  align-items: stretch;
}
.chat-composer .actions .btn {
  height: 100%;
  min-height: 0;
  padding: 0.4rem 0.8rem;
  white-space: nowrap;
}
.chat-composer .chat-status {
  grid-column: 1 / -1;
}
.chat-composer .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.35);
}
.chat-status {
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.84rem;
}
.chat-entry--loading {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #374151;
}
.chat-loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.chat-loading-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 2px solid #d1d5db;
  border-top-color: #6b7280;
  animation: chat-spin 0.8s linear infinite;
}
@keyframes chat-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 980px) {
  .project-note-entry-form {
    grid-template-columns: 1fr;
  }
  .application-title-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .project-note-submit-wrap {
    justify-content: flex-start;
  }
  .project-note-open-btn {
    width: 2.15rem;
  }
  .project-workspace-grid {
    grid-template-columns: 1fr;
  }
  .chat-panel {
    position: static;
    max-height: none;
  }
  .chat-history {
    max-height: 340px;
  }
}
