:root {
  --ink: #181614;
  --muted: #6e6863;
  --taupe: #b58c75;
  --taupe-dark: #8f6955;
  --taupe-soft: #f4ece7;
  --paper: #ffffff;
  --border: #e8e2de;
  --shadow: 0 24px 70px rgba(50, 38, 31, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(181, 140, 117, 0.09), transparent 26rem),
    var(--paper);
  font-family: "Poppins", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

.auth-shell {
  display: grid;
  width: min(100% - 40px, 470px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 64px 0;
  place-items: center;
}

.auth-card {
  width: 100%;
  padding: 46px 44px 40px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  text-align: center;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: clamp(38px, 9vw, 50px);
}

.auth-intro,
.auth-loading,
.auth-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.auth-intro {
  margin: 14px 0 28px;
}

.auth-loading {
  margin: 22px 0 0;
}

.auth-form {
  text-align: left;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
}

.auth-field input:focus {
  border-color: var(--taupe);
  box-shadow: 0 0 0 4px rgba(181, 140, 117, 0.14);
}

.auth-form > button {
  width: 100%;
  height: 50px;
  margin-top: 5px;
  border: 1px solid var(--taupe);
  border-radius: 11px;
  color: var(--paper);
  background: var(--taupe);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.auth-form > button:hover {
  border-color: var(--taupe-dark);
  background: var(--taupe-dark);
}

.auth-form > button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: #9c443d;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.auth-help {
  margin: 22px 0 0;
  font-size: 10px;
}

.page-shell {
  width: min(100% - 40px, 900px);
  margin: 0 auto;
  padding: 72px 0 88px;
}

.account-bar {
  display: flex;
  margin: 0 0 24px;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
  color: var(--muted);
  font-size: 11px;
}

.account-bar span {
  max-width: min(65vw, 340px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-bar button {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--taupe-dark);
  background: var(--paper);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.account-bar button:hover {
  border-color: var(--taupe);
}

.page-header {
  max-width: 690px;
  margin: 0 auto 42px;
  text-align: center;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  margin: 0 auto 18px;
  place-items: center;
  border: 1px solid rgba(181, 140, 117, 0.55);
  border-radius: 50%;
  color: var(--taupe-dark);
  background: rgba(255, 255, 255, 0.78);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.eyebrow,
.section-label {
  margin: 0 0 10px;
  color: var(--taupe-dark);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(42px, 7vw, 64px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.tagline {
  margin: 16px 0 0;
  font-size: clamp(17px, 2vw, 20px);
  font-weight: 500;
}

.intro {
  max-width: 620px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.chat-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.chat-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 30px 18px;
}

.chat-card__top h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.section-label {
  margin-bottom: 5px;
}

.connection-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  color: #765f52;
  background: var(--taupe-soft);
  font-size: 11px;
  font-weight: 500;
}

.connection-badge__dot {
  width: 7px;
  height: 7px;
  border: 1px solid var(--taupe);
  border-radius: 50%;
  background: var(--paper);
}

.workspace-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0 30px 24px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.workspace-row {
  display: flex;
  min-width: 0;
  padding: 13px 14px;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.workspace-row + .workspace-row {
  border-left: 1px solid var(--border);
}

.workspace-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.document-status {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.document-status.is-connected {
  color: #526b57;
  font-weight: 600;
}

.workspace-button,
.workspace-editor__footer button {
  padding: 6px 11px;
  border: 1px solid rgba(181, 140, 117, 0.48);
  border-radius: 8px;
  color: var(--taupe-dark);
  background: var(--paper);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.workspace-button:hover,
.workspace-editor__footer button:hover {
  border-color: var(--taupe);
  color: var(--paper);
  background: var(--taupe);
}

.workspace-button:focus-visible,
.workspace-close-button:focus-visible,
.workspace-editor__footer button:focus-visible {
  outline: 3px solid rgba(181, 140, 117, 0.28);
  outline-offset: 2px;
}

.workspace-editor {
  margin: 0 30px 24px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--taupe-soft);
}

.workspace-editor__header,
.workspace-editor__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.workspace-editor__header {
  margin-bottom: 16px;
}

.workspace-editor__header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.workspace-close-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  background: var(--paper);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.workspace-editor textarea,
.workspace-editor input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  font-size: 12px;
}

.file-picker {
  display: flex;
  min-height: 116px;
  padding: 22px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border: 1px dashed rgba(181, 140, 117, 0.72);
  border-radius: 11px;
  color: var(--ink);
  background: var(--paper);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.file-picker:hover {
  border-color: var(--taupe-dark);
  background: #fdfaf8;
}

.file-picker__title {
  font-size: 13px;
  font-weight: 600;
}

.file-picker__help,
.selected-file {
  color: var(--muted);
  font-size: 10px;
}

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

.file-picker:focus-within {
  border-color: var(--taupe);
  box-shadow: 0 0 0 4px rgba(181, 140, 117, 0.13);
}

.selected-file {
  margin: 8px 2px 0;
  overflow-wrap: anywhere;
}

.workspace-editor textarea {
  min-height: 150px;
  resize: vertical;
}

.workspace-editor textarea:focus,
.workspace-editor input:focus {
  border-color: var(--taupe);
  box-shadow: 0 0 0 4px rgba(181, 140, 117, 0.13);
}

.workspace-editor__footer {
  justify-content: flex-start;
  margin-top: 12px;
}

.workspace-editor__footer button {
  padding: 9px 18px;
  color: var(--paper);
  background: var(--taupe);
}

#workspaceSaveStatus {
  color: var(--muted);
  font-size: 11px;
}

.chat-heading {
  padding: 23px 30px 18px;
  border-top: 1px solid var(--border);
}

.chat-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.chat-area {
  height: min(44vh, 410px);
  min-height: 340px;
  padding: 30px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fcfbfa;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  margin-bottom: 22px;
  flex-direction: column;
  align-items: flex-start;
}

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

.message--user {
  align-items: flex-end;
}

.message__label {
  margin: 0 10px 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message__bubble {
  max-width: min(100%, 630px);
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 6px 18px 18px;
  background: var(--paper);
  font-size: 13px;
  line-height: 1.72;
  box-shadow: 0 6px 22px rgba(50, 38, 31, 0.04);
}

.message__bubble p {
  margin: 0 0 12px;
}

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

.message__bubble h3,
.message__bubble h4 {
  margin: 18px 0 8px;
  font-family: "Poppins", Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.message__bubble h3:first-child,
.message__bubble h4:first-child {
  margin-top: 0;
}

.message__bubble ul,
.message__bubble ol {
  margin: 6px 0 16px;
  padding-left: 23px;
}

.message__bubble li {
  margin: 5px 0;
  padding-left: 3px;
}

.message__bubble li::marker {
  color: var(--taupe-dark);
  font-weight: 600;
}

.message__bubble strong {
  font-weight: 600;
}

.message__bubble > *:last-child {
  margin-bottom: 0;
}

.message--user .message__bubble {
  max-width: min(85%, 560px);
  border-color: var(--taupe);
  border-radius: 18px 6px 18px 18px;
  color: var(--paper);
  background: var(--taupe);
  overflow-wrap: anywhere;
}

.message-form {
  display: flex;
  gap: 12px;
  padding: 22px 30px 8px;
}

.message-form textarea {
  width: 100%;
  min-width: 0;
  height: 52px;
  min-height: 52px;
  max-height: 130px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.message-form textarea::placeholder {
  color: #9b9590;
}

.message-form textarea:focus {
  border-color: var(--taupe);
  box-shadow: 0 0 0 4px rgba(181, 140, 117, 0.14);
}

.message-form button {
  min-width: 104px;
  height: 52px;
  padding: 0 24px;
  border: 1px solid var(--taupe);
  border-radius: 13px;
  color: var(--paper);
  background: var(--taupe);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.message-form button:hover {
  border-color: var(--taupe-dark);
  background: var(--taupe-dark);
}

.message-form button:active {
  transform: translateY(1px);
}

.message-form button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.message-form button:focus-visible {
  outline: 3px solid rgba(181, 140, 117, 0.35);
  outline-offset: 3px;
}

.form-note {
  margin: 0;
  padding: 0 31px 20px;
  color: #97908b;
  font-size: 10px;
}

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

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 28px, 900px);
    padding: 44px 0 50px;
  }

  .page-header {
    margin-bottom: 30px;
  }

  .chat-card {
    border-radius: 19px;
  }

  .chat-card__top {
    padding: 22px 20px 16px;
  }

  .workspace-list {
    grid-template-columns: repeat(2, 1fr);
    margin: 0 20px 20px;
  }

  .workspace-row:nth-child(3),
  .workspace-row:nth-child(4) {
    border-top: 1px solid var(--border);
  }

  .workspace-row:nth-child(3) {
    border-left: 0;
  }

  .workspace-editor {
    margin: 0 20px 20px;
  }

  .chat-heading {
    padding: 20px;
  }

  .chat-area {
    height: 48vh;
    min-height: 390px;
    padding: 22px 20px;
  }

  .message-form {
    padding: 18px 20px 8px;
  }

  .form-note {
    padding: 0 21px 17px;
  }
}

@media (max-width: 440px) {
  .auth-shell {
    width: min(100% - 24px, 470px);
    padding: 28px 0;
  }

  .auth-card {
    padding: 36px 24px 30px;
    border-radius: 19px;
  }

  .page-shell {
    width: min(100% - 20px, 900px);
    padding-top: 32px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    margin-bottom: 14px;
  }

  .connection-badge {
    padding: 7px 9px;
  }

  .message__bubble {
    padding: 15px 16px;
  }

  .message-form {
    gap: 8px;
  }

  .message-form textarea,
  .message-form button {
    height: 48px;
  }

  .message-form button {
    min-width: 76px;
    padding: 0 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
