@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces-latin.woff2") format("woff2");
  font-display: swap;
  font-weight: 100 900;
}

@font-face {
  font-family: "Inter Tight";
  src: url("/assets/fonts/inter-tight-latin.woff2") format("woff2");
  font-display: swap;
  font-weight: 300 700;
}

:root {
  color-scheme: light;
  --cream: #f6f1e8;
  --cream-soft: #fbf8f1;
  --paper: #f0e9dc;
  --harbor: #23465a;
  --harbor-soft: #2c5670;
  --harbor-deep: #1a3645;
  --rainy: #6f8794;
  --wheat: #d9c4a1;
  --wheat-soft: #ebdfc4;
  --brick: #a4624a;
  --brick-deep: #8c4f3b;
  --ink: #1a2a33;
  --line: color-mix(in oklab, var(--harbor) 15%, transparent);
  --line-strong: color-mix(in oklab, var(--harbor) 26%, transparent);
  --shadow: 0 30px 60px -32px color-mix(in oklab, var(--harbor) 42%, transparent);
  --radius: 8px;
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Inter Tight", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-sans);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--harbor);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.48;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .96 0 0 0 0 .94 0 0 0 0 .91 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--brick-deep);
}

::selection {
  background: var(--harbor);
  color: var(--cream);
}

:focus-visible {
  outline: 2px solid var(--brick);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--brick-deep);
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.site-mark {
  margin: 0 0 8px;
  color: var(--harbor);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 430;
  line-height: 1;
  letter-spacing: 0;
}

.site-mark b {
  margin: 0 3px;
  color: color-mix(in oklab, var(--brick) 82%, transparent);
  font-family: var(--font-sans);
  font-weight: 500;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--cream);
}

.login-shell {
  width: min(100%, 980px);
}

.login-panel {
  min-height: 560px;
  display: grid;
  grid-template-columns: 0.92fr 1fr;
  gap: 44px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 42px;
  position: relative;
  overflow: hidden;
}

.login-panel::before {
  content: "LeadsLord";
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  min-height: 420px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--cream);
  background: var(--harbor-deep);
  font-family: var(--font-display);
  font-size: 3.35rem;
  font-weight: 360;
  line-height: 0.98;
}

.login-content {
  min-width: 0;
}

.login-panel h1 {
  margin: 0;
  color: var(--harbor);
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 380;
  line-height: 1;
}

.login-copy {
  max-width: 30ch;
  color: color-mix(in oklab, var(--harbor) 78%, transparent);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 18px 0 28px;
}

.login-error {
  margin: 0 0 16px;
  padding: 11px 13px;
  color: var(--brick-deep);
  background: color-mix(in oklab, var(--brick) 11%, var(--cream));
  border: 1px solid color-mix(in oklab, var(--brick) 32%, transparent);
  border-radius: var(--radius);
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: color-mix(in oklab, var(--harbor) 76%, transparent);
  font-size: 0.9rem;
  font-weight: 650;
}

.login-form input,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--cream-soft);
  color: var(--ink);
  outline: none;
}

.login-form input {
  min-height: 48px;
  padding: 11px 13px;
}

.login-form input:focus,
.composer textarea:focus {
  border-color: var(--brick);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brick) 17%, transparent);
}

.login-form button,
.composer button,
.new-thread-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 650;
}

.login-form button,
.composer button,
.new-thread-button {
  color: var(--cream);
  background: var(--harbor);
  transition: background-color 160ms ease-out, box-shadow 160ms ease-out;
}

.login-form button {
  min-height: 48px;
}

.login-form button:hover,
.composer button:hover,
.new-thread-button:hover {
  background: var(--harbor-deep);
  box-shadow: 0 14px 30px -18px color-mix(in oklab, var(--harbor) 75%, transparent);
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  background: var(--cream);
}

.sidebar,
.files-panel {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.sidebar {
  border-right: 1px solid var(--line);
}

.files-panel {
  border-left: 1px solid var(--line);
}

.brand-row,
.workspace-header,
.files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-row {
  padding: 22px 22px 20px;
  border-bottom: 1px solid var(--line);
}

.brand-row h1,
.files-header h2,
.workspace-header h2 {
  margin: 0;
  color: var(--harbor);
  font-family: var(--font-display);
  font-weight: 380;
  line-height: 1.08;
}

.brand-row h1 {
  font-size: 2rem;
}

.workspace-header h2 {
  max-width: min(66ch, 62vw);
  overflow: hidden;
  color: var(--harbor-deep);
  font-size: 1.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-header h2 {
  font-size: 1.42rem;
}

.icon-button,
.secondary-button {
  color: var(--harbor);
  background: transparent;
  border-color: var(--line-strong);
  transition: background-color 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
}

.icon-button:hover,
.secondary-button:hover {
  background: color-mix(in oklab, var(--wheat-soft) 55%, transparent);
  border-color: color-mix(in oklab, var(--harbor) 32%, transparent);
}

.icon-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.secondary-button.danger {
  color: var(--brick-deep);
}

.new-thread-button {
  margin: 18px 22px 14px;
}

.thread-list,
.file-list {
  display: grid;
  gap: 6px;
  overflow: auto;
  padding: 0 14px 22px;
}

.thread-list {
  counter-reset: thread;
}

.thread-item,
.file-item {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 13px 12px;
  text-align: left;
  text-decoration: none;
  color: var(--harbor);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background-color 130ms ease-out, border-color 130ms ease-out;
}

.thread-item {
  position: relative;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  padding: 9px 8px 9px 12px;
}

.thread-item::before {
  counter-increment: thread;
  content: counter(thread, decimal-leading-zero);
  color: color-mix(in oklab, var(--harbor) 50%, transparent);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.4;
}

.thread-open-button,
.thread-hide-button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.thread-open-button {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 4px 0;
  text-align: left;
}

.thread-hide-button {
  min-height: 30px;
  margin-left: 8px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--brick-deep);
  font-size: 0.76rem;
  font-weight: 650;
  opacity: 0.72;
  transition: background-color 130ms ease-out, border-color 130ms ease-out, opacity 130ms ease-out;
}

.thread-hide-button:hover,
.thread-hide-button:focus-visible {
  background: color-mix(in oklab, var(--brick) 10%, var(--cream));
  border-color: color-mix(in oklab, var(--brick) 25%, transparent);
  opacity: 1;
}

.thread-item:hover,
.file-item:hover,
.thread-item.active {
  background: color-mix(in oklab, var(--wheat-soft) 43%, transparent);
  border-color: var(--line);
}

.thread-item.active {
  background: color-mix(in oklab, var(--wheat) 34%, var(--cream));
}

.thread-item-title,
.file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--harbor-deep);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-item-title,
.thread-item-meta,
.file-meta,
.muted-list-copy {
  color: color-mix(in oklab, var(--harbor) 63%, transparent);
  font-size: 0.82rem;
}

.muted-list-copy {
  margin: 12px 8px;
}

.workspace {
  min-width: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--cream);
}

.workspace-header {
  padding: 22px 28px 20px;
  background: color-mix(in oklab, var(--cream) 82%, var(--paper));
  border-bottom: 1px solid var(--line);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.chat-log {
  overflow: auto;
  padding: 34px max(26px, 7vw) 28px;
}

.message {
  display: grid;
  grid-template-columns: 100px minmax(0, 72ch);
  gap: 20px;
  justify-content: start;
  margin: 0 0 26px;
}

.message.user {
  grid-template-columns: minmax(0, 58ch) 100px;
  justify-content: end;
}

.message-meta {
  color: color-mix(in oklab, var(--harbor) 60%, transparent);
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.55;
}

.message.user .message-meta {
  grid-column: 2;
  grid-row: 1;
  text-align: right;
}

.message-body {
  min-width: 0;
  color: color-mix(in oklab, var(--harbor) 86%, transparent);
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .message-body {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  width: fit-content;
  max-width: 100%;
  padding: 13px 15px;
  color: var(--harbor-deep);
  background: color-mix(in oklab, var(--wheat-soft) 48%, var(--cream));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 600;
}

.message-body a {
  color: var(--brick-deep);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.empty-state {
  max-width: 580px;
  margin: 12vh auto 0;
  padding: 28px;
  color: color-mix(in oklab, var(--harbor) 76%, transparent);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 26px 54px -42px color-mix(in oklab, var(--harbor) 48%, transparent);
}

.empty-state h3 {
  margin: 0 0 10px;
  color: var(--harbor-deep);
  font-family: var(--font-display);
  font-size: 2.15rem;
  font-weight: 380;
  line-height: 1.05;
}

.empty-state p {
  margin: 0;
  max-width: 44ch;
  line-height: 1.65;
}

.empty-state.error {
  border-color: color-mix(in oklab, var(--brick) 45%, transparent);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px 28px 24px;
  background: color-mix(in oklab, var(--cream) 82%, var(--paper));
  border-top: 1px solid var(--line);
}

.composer textarea {
  min-height: 48px;
  max-height: 180px;
  resize: none;
  padding: 12px 14px;
  line-height: 1.45;
}

.composer textarea::placeholder,
.login-form input::placeholder {
  color: color-mix(in oklab, var(--harbor) 46%, transparent);
}

.composer button {
  min-width: 88px;
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.files-header {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.file-list {
  padding-top: 14px;
}

.file-item {
  border-color: var(--line);
  background: color-mix(in oklab, var(--cream) 56%, transparent);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .files-panel {
    grid-column: 1 / -1;
    min-height: 240px;
    max-height: 36vh;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .file-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .login-screen {
    place-items: stretch;
    padding: 14px;
  }

  .login-panel {
    min-height: calc(100dvh - 28px);
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px;
  }

  .login-panel::before {
    min-height: 180px;
    padding: 22px;
    font-size: 2.5rem;
  }

  .login-panel h1 {
    font-size: 2.5rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .workspace,
  .files-panel {
    min-height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-row {
    padding: 18px;
  }

  .brand-row h1 {
    font-size: 1.72rem;
  }

  .thread-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 72vw);
    overflow-x: auto;
    padding-bottom: 16px;
  }

  .workspace {
    height: 68vh;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .workspace-header h2 {
    max-width: 100%;
    font-size: 1.45rem;
  }

  .chat-log {
    padding: 22px 18px;
  }

  .message {
    grid-template-columns: 1fr;
    justify-content: stretch;
    gap: 6px;
    margin-bottom: 24px;
  }

  .message.user {
    grid-template-columns: 1fr;
  }

  .message-meta {
    font-size: 0.86rem;
  }

  .message.user .message-meta,
  .message.user .message-body {
    grid-column: 1;
  }

  .message.user .message-meta {
    text-align: right;
  }

  .message.user .message-body {
    max-width: min(100%, 28rem);
  }

  .empty-state {
    margin-top: 8vh;
  }

  .empty-state h3 {
    font-size: 1.8rem;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 14px 18px 18px;
  }

  .file-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}
