@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #f4efe6;
  --paper: rgba(255, 252, 247, 0.92);
  --paper-strong: #fffdf9;
  --ink: #173230;
  --muted: #5c706d;
  --line: rgba(23, 50, 48, 0.12);
  --accent: #0e7d77;
  --accent-2: #bc6438;
  --shadow: 0 24px 70px rgba(17, 44, 41, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(14, 125, 119, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(188, 100, 56, 0.12), transparent 28%),
    linear-gradient(135deg, #f6f1e9 0%, var(--bg) 52%, #eadcc5 100%);
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  height: 100vh;
  padding: 20px 0;
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: 1fr;
  gap: 24px;
}

.sidebar,
.workspace {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  min-height: 0;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  overflow: hidden;
}

.workspace__header,
.messages,
.chat-form {
  padding-left: 28px;
  padding-right: 28px;
}

.workspace__header {
  padding-top: 28px;
}

.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.card {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
  line-height: 1;
}

.card__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  list-style: none;
  margin-bottom: 0;
}

.card__summary::-webkit-details-marker {
  display: none;
}

.card__chevron {
  font-size: 1rem;
  line-height: 1;
  transition: transform 140ms ease;
}

.card[open] .card__chevron {
  transform: rotate(180deg);
}

.card[open] .card__body {
  margin-top: 12px;
}

.card__body {
  display: grid;
  gap: 10px;
}

.eyebrow,
.message__role,
.label {
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-2);
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.02;
}

h1 {
  font-size: clamp(2.8rem, 6vw, 4.4rem);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.lede,
.muted,
.status-banner__content,
.issue p,
.message__content,
textarea,
input,
select,
button {
  font-size: 0.96rem;
}

.lede,
.muted,
.issue p,
.message__content {
  color: var(--muted);
}

.panel-form,
.project-actions,
.summary,
.project-links {
  display: grid;
  gap: 10px;
}

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

input,
select,
textarea,
button {
  border: 1px solid var(--line);
  border-radius: 16px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

button,
.icon-button {
  cursor: pointer;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  transition: transform 140ms ease, opacity 140ms ease;
}

button.secondary {
  background: rgba(14, 125, 119, 0.14);
  color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:hover:not(:disabled),
.icon-button:hover {
  transform: translateY(-1px);
}

.summary {
  padding: 16px;
  border-radius: 20px;
  background: rgba(14, 125, 119, 0.08);
}

.project-actions {
  margin-bottom: 4px;
}

.summary__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.4rem;
}

.project-links {
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(23, 50, 48, 0.04);
}

#project-links-list {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.project-link:hover {
  text-decoration: underline;
}

.panel-link summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.panel-link summary::-webkit-details-marker {
  display: none;
}

.panel-link summary span {
  flex: 1;
}

.panel-link__chevron {
  font-size: 1rem;
  line-height: 1;
  transition: transform 140ms ease;
}

.panel-link[open] .panel-link__chevron {
  transform: rotate(180deg);
}

.panel-link[open] .card__body {
  margin-top: 8px;
}

.messages {
  display: grid;
  gap: 12px;
  align-content: start;
  overflow: auto;
  padding-top: 24px;
  padding-bottom: 24px;
}

.message {
  max-width: 82%;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--paper-strong);
  border: 1px solid var(--line);
}

.message[data-pending="true"] {
  border-style: dashed;
}

.message[data-role="assistant"] {
  justify-self: start;
}

.message[data-role="user"] {
  justify-self: end;
  background: rgba(14, 125, 119, 0.08);
}

.message__role {
  display: block;
  margin-bottom: 8px;
}

.message__content ul,
.message__content ol {
  margin: 4px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.message__content li {
  line-height: 1.45;
}

.message__meta {
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 0.84rem;
}

.message__timer {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: pre-line;
}

.message__loading {
  display: inline-flex;
  gap: 6px;
  margin-top: 10px;
}

.message__loading span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(14, 125, 119, 0.45);
  animation: message-loading-pulse 1.1s ease-in-out infinite;
}

.message__loading span:nth-child(2) {
  animation-delay: 0.15s;
}

.message__loading span:nth-child(3) {
  animation-delay: 0.3s;
}

.chat-form {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 28px;
  border-top: 1px solid var(--line);
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
  align-items: center;
}

.chip {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(14, 125, 119, 0.1);
  color: var(--ink);
  border: 1px solid rgba(14, 125, 119, 0.14);
}

.status-banner {
  order: 10;
  margin-top: auto;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid transparent;
  font-size: 0.82rem;
  line-height: 1.35;
  background: rgba(23, 50, 48, 0.05);
}

.status-banner summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.status-banner__summary-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-banner__summary-label .mdi,
.status-banner__chevron {
  font-size: 1rem;
  line-height: 1;
}

.status-banner summary::-webkit-details-marker {
  display: none;
}

.status-banner__chevron {
  transition: transform 140ms ease;
}

.status-banner[open] .status-banner__chevron {
  transform: rotate(180deg);
}

.status-banner__content {
  margin-top: 8px;
  white-space: pre-wrap;
}

.status-banner--ok {
  background: rgba(15, 123, 119, 0.1);
  border-color: rgba(15, 123, 119, 0.18);
  color: var(--ink);
}

.status-banner--loading {
  background: rgba(23, 50, 48, 0.08);
  border-color: rgba(23, 50, 48, 0.14);
  color: var(--ink);
}

.status-banner__loading {
  display: none;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
}

.status-banner--loading .status-banner__loading {
  display: inline-flex;
}

.status-banner--loading .status-banner__chevron {
  display: none;
}

.status-banner__loading span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.5;
  animation: message-loading-pulse 1.1s ease-in-out infinite;
}

.status-banner__loading span:nth-child(2) { animation-delay: 0.15s; }
.status-banner__loading span:nth-child(3) { animation-delay: 0.3s; }

.status-banner--warning {
  background: rgba(188, 100, 56, 0.12);
  border-color: rgba(188, 100, 56, 0.24);
  color: #6b351f;
}

.issue {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(23, 50, 48, 0.04);
}

.issue strong {
  display: block;
  margin-bottom: 4px;
}

.issue p {
  margin: 0;
}

.issue .question {
  margin-top: 6px;
  color: var(--ink);
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-row label {
  margin: 0;
}

.label-row .icon-button {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  padding: 0;
  font-size: 1.1rem;
  background: rgba(14, 125, 119, 0.12);
  color: var(--accent);
  transition: background 140ms ease, transform 140ms ease;
}

.label-row .icon-button:hover {
  background: rgba(14, 125, 119, 0.22);
  transform: none;
}

.label-row .icon-button[aria-expanded="true"] {
  background: var(--accent);
  color: #fff;
}

.hidden,
.hidden-input {
  display: none !important;
}

@keyframes message-loading-pulse {
  0%,
  80%,
  100% {
    transform: scale(0.72);
    opacity: 0.45;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.user-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(23, 50, 48, 0.05);
  border: 1px solid var(--line);
  order: 11;
  margin-top: auto;
}

.user-avatar {
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-logout {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  padding: 0;
  font-size: 1rem;
  background: rgba(188, 100, 56, 0.1);
  color: var(--accent-2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 140ms ease, transform 140ms ease;
}

.user-logout:hover {
  background: rgba(188, 100, 56, 0.2);
  transform: translateY(-1px);
}

.login-page,
.auth-error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: auto;
}

.login-card {
  display: grid;
  gap: 18px;
  max-width: 400px;
  width: calc(100vw - 48px);
  padding: 48px 40px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.login-title {
  font-size: clamp(3rem, 10vw, 4.4rem);
  line-height: 1;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 18px;
  text-decoration: none;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 500;
  transition: transform 140ms ease, opacity 140ms ease;
}

.login-btn:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.login-btn .mdi {
  font-size: 1.2rem;
}

.login-project {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.auth-error-card {
  display: grid;
  gap: 16px;
  text-align: center;
  max-width: 420px;
  width: calc(100vw - 48px);
  padding: 40px 36px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.auth-error-icon {
  font-size: 2.8rem;
  color: var(--accent-2);
  justify-self: center;
}

.auth-error-card h2 {
  font-size: 1.6rem;
}

.auth-error-card button {
  width: 100%;
  border-radius: 18px;
}

@media (max-width: 980px) {
  .shell {
    width: min(100vw, calc(100vw - 16px));
    height: auto;
    min-height: 100vh;
    padding: 8px 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .sidebar {
    overflow-y: visible;
  }

  .workspace {
    min-height: 80vh;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }
}
