html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #f8f9f6;
  color: #1f2933;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

button,
a,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.hku-page {
  --hku-header-height: 72px;
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f8f9f6, #f1f4ec);
}

.hku-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  height: var(--hku-header-height);
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(216 221 207);
  background: rgb(255 255 255 / 96%);
  padding: 0 28px;
  box-shadow: 0 8px 28px rgb(36 82 1 / 7%);
}

.hku-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
  color: #000;
  font-size: 22px;
  font-weight: 760;
  text-decoration: none;
}

.hku-brand span {
  overflow-wrap: anywhere;
}

.hku-brand img {
  width: 43px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
}

.menu-anchor {
  position: relative;
}

.icon-button,
.mini-button,
.row-action,
.account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(153 108 43 / 18%);
  border-radius: 8px;
  background: #fff;
  color: #000;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.icon-button,
.mini-button {
  width: 40px;
  height: 40px;
}

.account-button {
  width: 44px;
  height: 44px;
}

.icon-button:hover,
.mini-button:hover,
.row-action:hover,
.account-button:hover {
  border-color: rgb(109 188 47 / 50%);
  background: rgb(109 188 47 / 10%);
}

.hku-menu,
.row-menu,
.account-menu {
  position: absolute;
  right: 0;
  z-index: 50;
  display: grid;
  min-width: 220px;
  gap: 4px;
  border: 1px solid rgb(216 221 207);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  color: #1f2933;
  box-shadow: 0 18px 48px rgb(31 41 51 / 16%);
}

.hku-menu {
  top: calc(100% + 10px);
}

.row-menu {
  top: calc(100% + 6px);
  min-width: 140px;
}

.hku-menu a,
.hku-menu button,
.row-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 10px 11px;
  color: #1f2933;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}

.hku-menu a:hover,
.hku-menu button:hover,
.row-menu button:hover {
  background: rgb(109 188 47 / 12%);
}

.landing {
  display: grid;
  min-height: calc(100vh - var(--hku-header-height));
  place-items: center;
  padding: 34px 24px;
}

.terms-panel {
  display: grid;
  width: min(860px, 100%);
  gap: 22px;
  border: 1px solid rgb(216 221 207);
  border-radius: 8px;
  background: #fff;
  padding: clamp(24px, 4vw, 44px);
  box-shadow: 0 24px 70px rgb(36 82 1 / 12%);
}

.eyebrow {
  margin: 0 0 6px;
  color: #996c2b;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.terms-panel h1,
.chat-toolbar h1 {
  margin: 0;
  color: #000;
  font-weight: 760;
  line-height: 1.15;
  letter-spacing: 0;
}

.terms-panel h1 {
  font-size: clamp(30px, 4vw, 44px);
}

.terms-copy {
  display: grid;
  gap: 14px;
  color: #4b5660;
  font-size: 14px;
  line-height: 1.7;
}

.terms-copy p {
  margin: 0;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-top: 1px solid rgb(216 221 207);
  padding-top: 18px;
  color: #1f2933;
  font-size: 15px;
  line-height: 1.5;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  accent-color: #245201;
}

.primary-action {
  width: fit-content;
  min-width: 260px;
  border: 0;
  border-radius: 8px;
  background: #245201;
  padding: 13px 20px;
  color: #fff;
  font-size: 15px;
  font-weight: 720;
  text-align: center;
  text-decoration: none;
}

.primary-action.disabled {
  pointer-events: none;
  background: #97a090;
  opacity: 0.66;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 304px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: calc(100vh - var(--hku-header-height));
  max-height: calc(100vh - var(--hku-header-height));
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgb(216 221 207);
  background: rgb(255 255 255 / 92%);
}

.sidebar-top {
  display: grid;
  gap: 14px;
  padding: 22px 18px 14px;
}

.sidebar-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar h2 {
  margin: 0;
  color: #000;
  font-size: 18px;
  font-weight: 760;
}

.search-input {
  width: 100%;
  border: 1px solid rgb(216 221 207);
  border-radius: 8px;
  background: #f6f7f4;
  padding: 10px 12px;
  color: #1f2933;
  font-size: 13px;
  outline: 0;
}

.search-input::placeholder {
  color: #65727c;
}

.chat-list {
  display: grid;
  min-height: 0;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  padding: 4px 12px 18px;
}

.empty-list {
  margin: 4px 8px;
  color: #65727c;
  font-size: 13px;
}

.chat-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 7px 7px 7px 10px;
  text-align: left;
  transition:
    background-color 140ms ease,
    border-color 140ms ease;
}

.chat-row:hover,
.chat-row.actions-open {
  background: rgb(31 41 51 / 4%);
}

.chat-row.active {
  border-color: rgb(109 188 47 / 35%);
  background: rgb(109 188 47 / 12%);
}

.chat-select {
  display: grid;
  min-width: 0;
  gap: 4px;
  border: 0;
  background: transparent;
  text-align: left;
}

.chat-select span {
  overflow: hidden;
  color: #1f2933;
  font-size: 14px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-select small {
  overflow: hidden;
  color: #65727c;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-action {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  justify-self: end;
  border: 1px solid rgb(153 108 43 / 18%);
  border-radius: 8px;
  color: #000;
  background: #fff;
}

.sidebar-footer {
  display: grid;
  gap: 7px;
  margin-top: auto;
  border-top: 1px solid rgb(216 221 207);
  padding: 15px 16px 18px;
}

.sidebar-footer a,
.sidebar-footer button {
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 8px 6px;
  color: #000;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
}

.sidebar-footer a:hover,
.sidebar-footer button:hover {
  background: rgb(109 188 47 / 10%);
}

.sidebar-footer p {
  margin: 8px 0 0;
  border-left: 3px solid #b00020;
  padding-left: 10px;
  color: #8b0018;
  font-size: 11px;
  line-height: 1.45;
}

.chat-main {
  display: grid;
  box-sizing: border-box;
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  padding: 24px clamp(18px, 4vw, 48px);
}

.chat-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
}

.chat-toolbar h1 {
  font-size: clamp(24px, 3vw, 34px);
}

.account-menu {
  top: calc(100% + 10px);
  width: 276px;
}

.account-menu strong {
  color: #000;
  font-size: 14px;
}

.account-menu span,
.account-menu small {
  color: #65727c;
  font-size: 12px;
}

.thread {
  display: grid;
  height: 100%;
  min-height: 0;
  align-content: start;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 4px 24px;
}

.empty-state {
  display: grid;
  gap: 8px;
  max-width: 760px;
  border: 1px solid rgb(216 221 207);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 10px 28px rgb(31 41 51 / 6%);
}

.empty-state h3 {
  margin: 0;
  color: #000;
  font-size: 20px;
  line-height: 1.25;
}

.empty-state p {
  margin: 0;
  color: #65727c;
  font-size: 14px;
  line-height: 1.6;
}

.message {
  display: grid;
  max-width: min(760px, 90%);
  gap: 6px;
  border: 1px solid rgb(216 221 207);
  border-radius: 8px;
  background: #fff;
  padding: 15px 17px;
  box-shadow: 0 10px 28px rgb(31 41 51 / 6%);
}

.message.user {
  justify-self: end;
  border-color: rgb(153 108 43 / 25%);
  background: rgb(153 108 43 / 8%);
}

.message span {
  color: #996c2b;
  font-size: 12px;
  font-weight: 760;
}

.message p {
  margin: 0;
  white-space: pre-wrap;
  color: #1f2933;
  font-size: 14px;
  line-height: 1.6;
}

.message button {
  width: fit-content;
  border: 0;
  background: transparent;
  color: #000;
  font-size: 13px;
  font-weight: 700;
}

.status-error {
  margin: 0 0 10px;
  border-left: 3px solid #b00020;
  background: rgb(176 0 32 / 6%);
  padding: 9px 11px;
  color: #8b0018;
  font-size: 13px;
  line-height: 1.45;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 12px;
  border: 1px solid rgb(216 221 207);
  border-radius: 999px;
  background: #fff;
  padding: 8px;
  box-shadow: 0 16px 40px rgb(36 82 1 / 12%);
}

.composer input {
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  color: #1f2933;
  font-size: 15px;
  outline: 0;
}

.composer button {
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 22px;
}

.composer button:disabled {
  background: #65727c;
  opacity: 0.76;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgb(31 41 51 / 38%);
  padding: 20px;
}

.modal {
  display: grid;
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  gap: 22px;
  overflow: auto;
  border: 1px solid rgb(216 221 207);
  border-radius: 8px;
  background: #fff;
  padding: clamp(22px, 4vw, 34px);
  box-shadow: 0 28px 80px rgb(31 41 51 / 26%);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.modal h2 {
  margin: 0;
  color: #000;
  font-weight: 760;
  line-height: 1.15;
}

.reference-list {
  display: grid;
  gap: 9px;
}

.reference-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgb(216 221 207);
  border-radius: 8px;
  padding: 13px 14px;
  color: #000;
  font-size: 14px;
  font-weight: 670;
  text-decoration: none;
}

.reference-list a:hover {
  border-color: rgb(109 188 47 / 50%);
  background: rgb(109 188 47 / 8%);
}

.reference-list small {
  color: #996c2b;
}

@media (max-width: 860px) {
  .hku-page {
    --hku-header-height: 66px;
  }

  .hku-header {
    height: auto;
    min-height: 66px;
    padding: 10px 16px;
  }

  .hku-brand {
    gap: 10px;
    font-size: 17px;
  }

  .hku-brand img {
    width: 36px;
    height: 40px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    height: auto;
    min-height: 0;
    max-height: min(340px, 42vh);
    border-right: 0;
    border-bottom: 1px solid rgb(216 221 207);
  }


  .chat-main {
    height: 100%;
    min-height: 0;
    padding: 20px 14px;
  }

  .message {
    max-width: 100%;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 42px;
    border-radius: 22px;
  }

  .composer button {
    width: 42px;
    height: 42px;
  }
}
