:root {
  color-scheme: dark;
  --bg: #121412;
  --panel: #1b201c;
  --panel-2: #202821;
  --line: #344037;
  --text: #f3f5ef;
  --muted: #aab4a8;
  --accent: #7ccf91;
  --accent-2: #5fa8ff;
  --danger: #ff7a7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body.is-logged-out {
  overflow: hidden;
}

body.is-menu-open {
  overflow: hidden;
}

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

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
}

.mobile-bar,
.sidebar-backdrop {
  display: none;
}

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

.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #0d130f;
  background: var(--accent);
  font-weight: 800;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

p,
label {
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

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

select {
  text-overflow: ellipsis;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 8px;
  color: #07110a;
  background: var(--accent);
  font-weight: 700;
  padding: 11px 14px;
  cursor: pointer;
}

.ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}

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

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

.check input {
  width: auto;
}

.new-project {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.login {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 20, 18, 0.94);
}

.login[hidden] {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.4);
}

.login-error {
  min-height: 22px;
  color: var(--danger);
}

.log {
  padding: 24px;
  overflow: auto;
  min-height: 0;
  scroll-behavior: smooth;
}

.entry {
  max-width: 980px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.entry strong {
  color: var(--accent-2);
}

.entry.error strong {
  color: var(--danger);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  padding: 16px;
}

@media (max-width: 760px) {
  .shell {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 58px minmax(0, 1fr);
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 58px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    z-index: 4;
  }

  .mobile-bar h1 {
    font-size: 16px;
  }

  .mobile-bar p {
    font-size: 12px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    padding: 0;
    font-size: 22px;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(92vw, 360px);
    padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
    gap: 14px;
    z-index: 6;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 20px 0 70px rgba(0, 0, 0, 0.35);
  }

  body.is-menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: block;
    pointer-events: none;
    opacity: 0;
    background: rgba(0, 0, 0, 0.5);
    transition: opacity 180ms ease;
  }

  body.is-menu-open .sidebar-backdrop {
    pointer-events: auto;
    opacity: 1;
  }

  .chat {
    grid-row: 2;
    height: 100%;
  }

  .log {
    padding: 14px 12px;
  }

  .entry {
    padding: 11px 0;
    font-size: 14px;
  }

  .composer {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer textarea {
    min-height: 70px;
    max-height: 28vh;
    font-size: 16px;
  }

  .composer button {
    min-height: 44px;
  }

  input,
  select,
  textarea,
  button {
    min-height: 44px;
  }

  label {
    gap: 6px;
  }

  .brand {
    margin-bottom: 2px;
  }

  .login {
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }

  .login-panel {
    gap: 14px;
    padding: 18px;
  }
}

@media (max-width: 390px) {
  .sidebar {
    width: 94vw;
    padding-left: 14px;
    padding-right: 14px;
  }

  .mobile-bar {
    gap: 10px;
  }

  .mobile-bar h1 {
    font-size: 15px;
  }

  .composer textarea {
    min-height: 64px;
  }
}
