:root {
  color-scheme: light dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #1c2530;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #aab4c0;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #6f7f90;
}

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

input,
textarea {
  min-height: 38px;
  border: 1px solid #aab4c0;
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  color: #17202a;
}

textarea {
  padding: 10px 12px;
  resize: none;
  line-height: 1.4;
}

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

.page-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.page-nav a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 10px;
  color: #25313d;
  text-decoration: none;
}

.page-nav a:hover {
  border-color: #aab4c0;
}

.page-nav a[aria-current="page"] {
  border-color: #7c8a99;
  background: #ffffff;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-form {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
}

.login-form h1 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

.login-error {
  margin: 0;
  color: #a12222;
}

.toolbar,
.prompt-row,
.input-row {
  display: flex;
  gap: 8px;
}

.toolbar input,
.prompt-row input,
.input-row input {
  flex: 1;
  min-width: 0;
}

.terminal {
  min-height: 520px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #303946;
  border-radius: 8px;
  background: #10151b;
  color: #e7edf5;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

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

.chat-messages {
  min-height: 0;
  overflow: auto;
  border: 1px solid #d2d8df;
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  width: min(760px, 100%);
  display: grid;
  gap: 5px;
}

.message.user {
  align-self: flex-end;
}

.message-role {
  font-size: 12px;
  line-height: 1.2;
  color: #657180;
}

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

.message-body {
  border: 1px solid #d6dde4;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fafc;
  color: #1c2530;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.message.user .message-body {
  border-color: #9fb2c6;
  background: #eaf2fb;
}

.message.pending .message-body {
  color: #596675;
}

.message.error .message-body {
  border-color: #d79898;
  background: #fff2f2;
  color: #8f1f1f;
}

.chat-composer {
  display: grid;
  gap: 10px;
}

.resume-toggle {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: #25313d;
  font-size: 14px;
}

.resume-toggle input {
  min-height: 0;
  width: 16px;
  height: 16px;
  padding: 0;
}

.composer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.composer-row textarea {
  max-height: 180px;
}

.composer-row button {
  height: 42px;
}

@media (max-width: 720px) {
  .shell {
    width: calc(100vw - 20px);
    padding: 10px 0;
  }

  .toolbar,
  .prompt-row,
  .input-row {
    flex-wrap: wrap;
  }

  .toolbar button,
  .prompt-row button,
  .input-row button {
    flex: 1 1 120px;
  }

  .terminal {
    min-height: 55vh;
  }

  .chat-shell {
    width: calc(100vw - 20px);
    padding: 10px 0;
  }

  .chat-messages {
    padding: 10px;
  }

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