:root {
  --bg-warm: #fbfaf8;
  --sidebar-bg: #f4efe9;
  --sidebar-hover: #eae3da;
  --card-bg: #ffffff;
  --text-main: #2b2724;
  --text-muted: #7d756d;
  --border-soft: #e8e1d7;
  --claude-accent: #c95d3b;
  --claude-accent-hover: #b34e2f;
  --user-bubble: #f0ebe4;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-warm);
  color: var(--text-main);
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* Сайдбар */
aside {
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  z-index: 50;
}

.sidebar-header {
  padding: 18px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 1.55rem;
  color: #1f1c1a;
}

.badge {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  background: #e6ded3;
  padding: 2px 7px;
  border-radius: 99px;
  color: #5c554e;
}

.new-chat-btn {
  margin: 8px 16px 14px;
  padding: 10px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-main);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  background: #fffdfa;
  border-color: #d1c6b6;
}

.shortcut {
  font-size: 0.75rem;
  opacity: 0.6;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-item {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s;
}

.chat-item:hover {
  background: var(--sidebar-hover);
  color: var(--text-main);
}

.chat-item.active {
  background: #e8ded2;
  color: #1f1c1a;
  font-weight: 500;
}

.chat-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.del-chat-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #998f84;
  padding: 2px 4px;
}

.chat-item:hover .del-chat-btn {
  opacity: 1;
}

.del-chat-btn:hover {
  color: #dc2626;
}

/* Футер сайдбара */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.2);
}

.auth-button-sidebar {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #fff;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-button-sidebar:hover {
  background: #fafaf8;
  border-color: #d1c6b6;
}

.user-pill {
  display: none;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.user-pill b {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: #dc2626;
  cursor: pointer;
  text-decoration: underline;
}

.model-picker {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--card-bg);
  font-size: 0.78rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

/* Модальное окно */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 39, 36, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  position: relative;
}

.modal-card h3 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.modal-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.4;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  font-size: 0.92rem;
  outline: none;
  margin-bottom: 12px;
}

.modal-input:focus {
  border-color: var(--claude-accent);
}

.modal-submit {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  background: var(--claude-accent);
  color: #fff;
  border: none;
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
}

.modal-submit:hover {
  background: var(--claude-accent-hover);
}

.modal-status {
  margin-top: 10px;
  font-size: 0.8rem;
  text-align: center;
  display: none;
}

/* Главная область */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
  overflow: hidden;
}

.topbar {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(232, 225, 215, 0.4);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
}

.model-indicator {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.topbar-spacer {
  width: 24px;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-inner {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msg-group {
  display: flex;
  gap: 14px;
  width: 100%;
}

.msg-group.user {
  justify-content: flex-end;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: #eee6dc;
  flex-shrink: 0;
}

.msg-content {
  max-width: 85%;
  padding: 12px 18px;
  line-height: 1.6;
  font-size: 0.94rem;
  word-wrap: break-word;
}

.msg-group.bot .msg-content {
  color: #1f1c1a;
  background: transparent;
  padding-left: 0;
}

.msg-group.user .msg-content {
  background: var(--user-bubble);
  border-radius: 18px 18px 4px 18px;
}

.msg-content em {
  color: #a14c1d;
  font-style: italic;
}

.msg-content strong {
  font-weight: 600;
  color: #000;
}

.msg-content p {
  margin-bottom: 8px;
}

.msg-content p:last-child {
  margin-bottom: 0;
}

.chat-image {
  margin-top: 10px;
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  display: block;
}

/* Поле ввода */
.input-container {
  padding: 12px 20px 24px;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, rgba(251, 250, 248, 0) 0%, rgba(251, 250, 248, 1) 25%);
}

.input-box {
  width: 100%;
  max-width: 720px;
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity 0.2s, border-color 0.2s;
}

.input-box.locked {
  background: #f7f4ee;
  cursor: pointer;
}

.input-box:focus-within:not(.locked) {
  border-color: #d1c6b6;
}

textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.94rem;
  line-height: 1.5;
  max-height: 160px;
  height: 24px;
  background: transparent;
}

textarea:disabled {
  cursor: not-allowed;
  color: var(--text-muted);
}

.input-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.icon-action-btn {
  background: none;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.icon-action-btn:hover {
  background: #f0ebe4;
}

.char-count {
  font-size: 0.75rem;
  color: #a89f91;
}

.send-btn {
  background: var(--claude-accent);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.send-btn:disabled {
  background: #dcd4c9;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  aside {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  aside.open {
    transform: translateX(0);
  }
  .mobile-menu-btn {
    display: block;
  }
}
