/* Vergilius web — tokens from pavlovapsyspb.ru */
:root {
  --color-brand-teal: #68AABD;
  --color-brand-teal-dark: #61A3B5;
  --color-brand-teal-shadow: #5893A4;
  --color-brand-green: #619E6F;
  --color-text-main: #4F4F4F;
  --color-text-muted: #5A5A5A;
  --color-bg-page: #F5F5F5;
  --color-bg-white: #FFFFFF;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(104, 170, 189, 0.18);
  --glass-shadow: 0 8px 32px rgba(104, 170, 189, 0.1);
  --radius: 1rem;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Montserrat", Arial, Helvetica, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--color-text-main);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(104, 170, 189, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(97, 158, 111, 0.12), transparent 55%),
    var(--color-bg-page);
}

h1, h2 {
  font-family: "Merriweather", Georgia, serif;
  font-weight: 400;
  margin: 0;
}

.hidden { display: none !important; }

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  box-shadow: var(--glass-shadow);
}

.brand {
  margin: 0;
  font-family: "Merriweather", Georgia, serif;
  font-size: 1.35rem;
  color: var(--color-brand-teal-dark);
}

.muted { color: var(--color-text-muted); }
.small { font-size: 0.85rem; }
.error { color: #c0392b; margin: 0.5rem 0 0; }

.btn-primary {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--color-brand-teal);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 3px 0 0 var(--color-brand-teal-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-brand-teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 1px var(--color-brand-teal-shadow);
}
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.9rem; }

.btn-ghost {
  appearance: none;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--color-text-main);
  font-family: inherit;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}
.btn-ghost.danger { color: #b33; border-color: rgba(179, 51, 51, 0.25); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* Login */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card {
  width: min(420px, 100%);
  padding: 2rem;
  border-radius: calc(var(--radius) + 4px);
}
.login-card h1 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.8rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 1rem 0;
  font-size: 0.92rem;
}
.field input, .field select, .composer textarea {
  font: inherit;
  border: 1px solid #e6e6e6;
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: #fff;
  color: inherit;
}
.login-card .btn-primary { width: 100%; margin-top: 0.5rem; }

/* App shell — DeepSeek-like */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 0;
}

.sidebar {
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 0;
}
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1rem 0.75rem;
}
.sidebar-section {
  padding: 0.35rem 0.65rem 0.75rem;
  overflow: auto;
  min-height: 0;
  flex: 1;
}
.sidebar-section h2 {
  font-family: "Inter", "Montserrat", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-brand-teal-dark);
  margin: 0.4rem 0.5rem 0.45rem;
}
.sidebar-foot {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--glass-border);
}

.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.session-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 0.85rem;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.session-item:hover { background: rgba(104, 170, 189, 0.1); }
.session-item.active {
  background: rgba(104, 170, 189, 0.18);
  box-shadow: inset 0 0 0 1px rgba(104, 170, 189, 0.28);
}
.session-item .title {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-item .meta {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.main-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(104, 170, 189, 0.15);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
}
.main-head h1 { font-size: 1.45rem; }
.main-actions { display: flex; gap: 0.4rem; }

.messages {
  overflow: auto;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bubble {
  max-width: min(820px, 92%);
  padding: 0.95rem 1.15rem;
  border-radius: 1.15rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: rise 0.25s ease;
}
.bubble.user {
  align-self: flex-end;
  background: var(--color-brand-teal);
  color: #fff;
  border-bottom-right-radius: 0.35rem;
}
.bubble.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-bottom-left-radius: 0.35rem;
}
.bubble.system {
  align-self: center;
  background: rgba(97, 158, 111, 0.12);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.bubble .role {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 0.25rem;
  font-family: "Inter", sans-serif;
}
.bubble.typing::after {
  content: "…";
  animation: blink 1s infinite;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes blink {
  50% { opacity: 0.3; }
}

.composer {
  margin: 0 1.25rem 1.25rem;
  border-radius: 1.25rem;
  padding: 0.65rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: end;
}
.composer textarea {
  resize: none;
  min-height: 3.1rem;
  max-height: 180px;
  border: none;
  outline: none;
  background: transparent;
  padding: 0.65rem 0.75rem;
}

.empty-hint {
  margin: auto;
  text-align: center;
  color: var(--color-text-muted);
  max-width: 28rem;
}
.empty-hint strong {
  display: block;
  font-family: "Merriweather", Georgia, serif;
  font-size: 1.4rem;
  color: var(--color-text-main);
  margin-bottom: 0.4rem;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
}
