:root {
  color-scheme: light;
  --teal: #056d84;
  --orange: #f39302;
  --magenta: #db2a54;
  --cream: #f1ece2;
  --navy: #0d212f;
  --bg: #f7f8f8;
  --panel: #ffffff;
  --text: var(--navy);
  --muted: #66737b;
  --line: #ddd7cc;
  --soft: #eef7f8;
  --shadow: rgba(13, 33, 47, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Lato", Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-bottom: 4px solid var(--orange);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(13, 33, 47, 0.06);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--navy);
  font-size: 19px;
  font-weight: 900;
  text-decoration: none;
}

.brand img {
  height: 44px;
  width: auto;
  display: block;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--soft);
}

.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;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  min-height: 38px;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.settings-panel {
  position: fixed;
  top: 68px;
  left: 0;
  bottom: 0;
  width: min(380px, 100vw);
  z-index: 30;
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 45px rgba(13, 33, 47, 0.16);
  padding: 18px;
  overflow: auto;
}

.settings-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.settings-header h2 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--navy);
  font-weight: 900;
}

.settings-form input,
.settings-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.settings-form input:focus,
.settings-form select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(5, 109, 132, 0.14);
}

.settings-form button[type="submit"] {
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  min-height: 44px;
  cursor: pointer;
  font-weight: 900;
}

.settings-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.ghost-button:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--soft);
}

.chat-menu {
  position: relative;
}

.chats-dropdown {
  position: absolute;
  top: 48px;
  right: 0;
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 88px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px var(--shadow);
  overflow: hidden;
}

.chats-list {
  max-height: min(430px, calc(100vh - 190px));
  overflow: auto;
}

.dropdown-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--teal);
  font-weight: 900;
}

.chat-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.chat-item:hover {
  background: var(--soft);
}

.chat-open {
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 10px 0 10px 14px;
  cursor: pointer;
}

.chat-delete {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
}

.chat-delete:hover {
  color: var(--magenta);
  background: #fff1f4;
}

.chat-item-title {
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-date {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.view-more-link {
  display: block;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--line);
  color: var(--magenta);
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.view-more-link:hover {
  background: #fff7e8;
  color: var(--orange);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.hero-search {
  min-height: 300px;
  display: grid;
  align-content: center;
  gap: 12px;
  background: transparent;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-box input {
  height: 58px;
  width: 100%;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 20px;
  outline: none;
  font-size: 18px;
  box-shadow: 0 10px 30px rgba(13, 33, 47, 0.09);
}

.search-box input:focus,
.chat-form textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(5, 109, 132, 0.14);
}

.search-box button,
.chat-form button {
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  min-height: 44px;
  padding: 0 20px;
  cursor: pointer;
  font-weight: 900;
}

.search-box button:hover,
.chat-form button:hover {
  background: var(--navy);
}

button:disabled,
input:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  padding-bottom: 36px;
}

.active-chat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--magenta);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.active-chat h1 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.results,
.chat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(13, 33, 47, 0.06);
}

.section-title {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  color: var(--navy);
  font-weight: 900;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-jump-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--teal);
  padding: 0 10px;
  cursor: pointer;
  font-weight: 900;
}

.chat-jump-button:hover {
  border-color: var(--teal);
  background: var(--soft);
}

.chat-jump-icon {
  position: relative;
  width: 16px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.chat-jump-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  bottom: -5px;
  width: 6px;
  height: 6px;
  background: #fff;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-20deg);
}

.result {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.result:last-child {
  border-bottom: 0;
}

.result-title {
  color: var(--teal);
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 7px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  background: var(--cream);
  border: 1px solid #e3d8c8;
  border-radius: 999px;
  padding: 3px 8px;
}

.snippet {
  line-height: 1.45;
  color: #34444d;
  margin: 8px 0;
}

.open-link {
  color: var(--magenta);
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.open-link:hover {
  color: var(--orange);
}

.chat {
  display: flex;
  flex-direction: column;
  height: min(680px, calc(100vh - 112px));
  min-height: 420px;
}

body.chat-fullscreen-open {
  overflow: hidden;
}

.chat-fullscreen-button {
  width: 34px;
  height: 34px;
  font-size: 17px;
}

.chat.chat-fullscreen {
  position: fixed;
  inset: 16px;
  z-index: 60;
  height: auto;
  max-height: none;
  min-height: 0;
  border-color: var(--teal);
  box-shadow: 0 24px 70px rgba(13, 33, 47, 0.28);
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: min(82%, 760px);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
}

.message-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid currentColor;
  font-size: 18px;
  line-height: 1;
}

.message-content {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  justify-self: start;
  background: #fef3df;
  border-left: 4px solid var(--orange);
}

.message.assistant {
  justify-self: end;
  grid-template-columns: minmax(0, 1fr) 34px;
  background: var(--soft);
  border-left: 0;
  border-right: 4px solid var(--teal);
}

.message.assistant .message-avatar {
  grid-column: 2;
  grid-row: 1;
}

.message.assistant .message-content {
  grid-column: 1;
  grid-row: 1;
}

.chat-form {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  background: #fff;
}

.chat-form textarea {
  width: 100%;
  min-height: 46px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.empty {
  padding: 18px 16px;
  color: var(--muted);
}

.history-shell {
  padding: 34px 0 44px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.history-header h1 {
  margin: 3px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

.history-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(13, 33, 47, 0.06);
}

.history-panel .status {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.history-list {
  display: grid;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 15px 16px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.history-item:hover {
  background: var(--soft);
}

.history-item-title {
  font-weight: 900;
  margin-bottom: 5px;
}

.history-item-preview {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-date {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.load-more {
  margin: 14px auto;
}

@media (max-width: 900px) {
}

@media (max-width: 560px) {
  .topbar {
    padding: 0 12px;
  }

  .brand span {
    display: none;
  }

  .shell {
    width: min(100% - 20px, 1120px);
  }

  .hero-search {
    min-height: 230px;
  }

  .search-box {
    grid-template-columns: 1fr;
  }

  .history-header,
  .history-item {
    grid-template-columns: 1fr;
  }

  .history-header {
    align-items: stretch;
  }

  .history-item-date {
    white-space: normal;
  }

  .chat {
    height: calc(100vh - 96px);
    min-height: 360px;
  }

  .chat.chat-fullscreen {
    inset: 0;
    border-radius: 0;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .message {
    width: 94%;
  }
}
