* {
  box-sizing: border-box;
}

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

body {
  background: #f0f0f0;
  color: #111;
  font-family: "Inter", sans-serif;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #f5f5f5;
  border-radius: 6px;
  padding: 0.1em 0.35em;
}

.shell {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

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

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

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  padding: 22px;
}

.auth-card h1,
.chat-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-copy,
.chat-subtitle,
.panel-feedback,
.auth-feedback,
.feedback,
.account-role,
.account-label,
.session-empty,
.session-meta {
  margin: 0;
  font-size: 13px;
  color: #777;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.panel-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #666;
}

.sidebar {
  display: grid;
  gap: 14px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 14px;
  padding: 16px;
  position: sticky;
  top: 24px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e8e8e8;
}

h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.account-panel,
.admin-panel {
  display: grid;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid #ececec;
}

.account-panel {
  align-items: start;
}

.account-name {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.admin-form {
  display: grid;
  gap: 8px;
}

.user-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #f5f5f5;
  font-size: 12px;
  color: #444;
}

.user-chip strong {
  font-weight: 600;
}

.session-list {
  display: grid;
  gap: 4px;
}

.session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
  border-radius: 10px;
}

.session-row:hover .session-delete,
.session-row.is-active .session-delete {
  opacity: 1;
}

.session-button {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 3px;
  background: transparent;
  color: #111;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  transition: background 0.1s ease;
}

.session-button:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: transparent;
}

.session-row.is-active .session-button {
  background: #111;
  border-color: #111;
  color: #fff;
}

.session-delete {
  opacity: 0;
  min-width: 32px;
  padding: 0;
  background: transparent;
  color: #888;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
  transition: opacity 0.1s ease, background 0.1s ease, color 0.1s ease;
}

.session-delete:hover:not(:disabled) {
  background: #fee2e2;
  color: #b91c1c;
  border-color: transparent;
}

.session-row.is-active .session-delete {
  color: rgba(255, 255, 255, 0.62);
}

.session-row.is-active .session-delete:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.session-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-row.is-active .session-meta {
  color: rgba(255, 255, 255, 0.68);
}

.chat-panel {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.chat-header {
  display: flex;
  align-items: start;
}

.messages {
  display: grid;
  gap: 12px;
}

.message {
  max-width: min(780px, 100%);
  border-radius: 14px;
  padding: 14px 16px;
}

.message.user {
  justify-self: end;
  background: #111;
  color: #fff;
}

.message.assistant {
  justify-self: start;
  background: #fff;
  border: 1px solid #e0e0e0;
}

.role {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.message-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.composer {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafafa;
  color: #111;
  font-size: 14px;
  line-height: 1.5;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #aaa;
  background: #fff;
}

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

button {
  border: 1px solid #111;
  background: #111;
  color: #fff;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s ease, border-color 0.12s ease;
}

button:hover:not(:disabled) {
  background: #333;
  border-color: #333;
}

button:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.button-secondary {
  background: #fff;
  color: #111;
  border-color: #d8d8d8;
  padding: 7px 14px;
}

.button-secondary:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #bbb;
}

@media (max-width: 680px) {
  .shell {
    width: calc(100vw - 24px);
    padding: 16px 0 32px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .sidebar {
    position: static;
  }

  .session-delete {
    opacity: 1;
  }

  .actions,
  .account-panel {
    grid-auto-flow: row;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-card button,
  .composer > .actions > button,
  .admin-form > button,
  #logout-button {
    width: 100%;
    text-align: center;
  }
}
