:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #18201f;
  --muted: #63706d;
  --line: #dbe4e1;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --soft: #e7f3f1;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 280px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 24px 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 60px rgba(18, 32, 30, 0.08);
}

.login-panel {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 28px;
  border-radius: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

.brand p,
.chat-header p,
.notice,
.meta,
.sources {
  color: var(--muted);
}

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--soft);
  border: 1px solid #cce5e0;
  font-size: 14px;
  margin-bottom: 18px;
}

code {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.user-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fbfdfc;
  cursor: pointer;
  text-align: left;
}

.user-card:hover {
  border-color: var(--primary);
  background: var(--soft);
}

.user-card strong {
  display: block;
  font-size: 14px;
}

.user-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--primary-dark);
}

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

.error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

.hidden {
  display: none;
}

.chat-panel {
  height: min(820px, calc(100vh - 48px));
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-panel.hidden {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.chat-header h2 {
  font-size: 20px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.actions a,
.actions button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 9px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.actions a {
  color: var(--primary);
  background: var(--soft);
}

.actions button {
  background: #263331;
}

.messages {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: 78%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  line-height: 1.5;
}

.message-body {
  overflow-wrap: anywhere;
}

.message-body p {
  margin: 0 0 10px;
}

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

.message-body ol,
.message-body ul {
  margin: 8px 0 10px 22px;
  padding: 0;
}

.message-body li {
  margin: 4px 0;
  padding-left: 2px;
}

.message-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #eef6f4;
  color: #0b4f49;
}

.message-body a {
  color: var(--primary);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.message.assistant {
  align-self: flex-start;
  background: #fbfdfc;
}

.sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.sources div {
  margin-top: 4px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #fbfdfc;
}

textarea {
  resize: none;
}

@media (max-width: 860px) {
  .user-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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