:root {
  --paper: #f6f2eb;
  --paper-2: #efe8dc;
  --ink: #1f2937;
  --ink-muted: #5b6b7a;
  --accent: #c86b4a;
  --accent-2: #2f6f6d;
  --panel: #ffffff;
  --line: rgba(31, 41, 55, 0.12);
}

body {
  font-family: 'Sora', ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  background: radial-gradient(1400px 600px at 90% -10%, #fde8d5 0%, rgba(253, 232, 213, 0) 60%),
              radial-gradient(900px 500px at -10% 10%, #d8f0ef 0%, rgba(216, 240, 239, 0) 55%),
              var(--paper);
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
}

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

.sidebar {
  background: linear-gradient(180deg, var(--paper-2), #f9f5ef 75%);
  border-right: 1px solid var(--line);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 6px;
  flex: 1;
}

.chat-item {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  transition: all 160ms ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-item:hover {
  border-color: rgba(31, 41, 55, 0.18);
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.08);
}

.chat-item.is-active {
  border-color: rgba(200, 107, 74, 0.6);
  background: #fff6ef;
  box-shadow: inset 0 0 0 1px rgba(200, 107, 74, 0.2);
}

.chat-item-title {
  font-weight: 600;
  font-size: 0.86rem;
}

.chat-title-input {
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  width: 100%;
  border: 1px solid rgba(31, 41, 55, 0.18);
  border-radius: 8px;
  padding: 2px 6px;
  background: #ffffff;
  color: var(--ink);
}

.chat-title-input:focus {
  outline: none;
  border-color: rgba(200, 107, 74, 0.6);
  box-shadow: 0 0 0 2px rgba(200, 107, 74, 0.12);
}

.chat-item-meta {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

.chat-item-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.chat-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-item-edit,
.chat-item-delete {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.9);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all 150ms ease;
}

.chat-item-edit {
  color: var(--accent-2);
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
  pointer-events: auto;
  border-color: rgba(185, 28, 28, 0.25);
  box-shadow: 0 6px 12px rgba(185, 28, 28, 0.12);
}

.chat-item:hover .chat-item-edit {
  opacity: 1;
  pointer-events: auto;
  border-color: rgba(47, 111, 109, 0.25);
  box-shadow: 0 6px 12px rgba(47, 111, 109, 0.12);
}

.chat-item-edit:hover {
  background: rgba(47, 111, 109, 0.12);
  border-color: rgba(47, 111, 109, 0.45);
}

.chat-item-delete:hover {
  background: #fee2e2;
  border-color: rgba(185, 28, 28, 0.45);
}

.chat-item-edit svg,
.chat-item-delete svg {
  width: 14px;
  height: 14px;
}

.main-panel {
  padding: 28px clamp(18px, 4vw, 48px);
  height: 100vh;
  overflow-y: auto;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.hero-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hero-sub {
  color: var(--ink-muted);
  font-size: 0.95rem;
  max-width: 54ch;
}

.chat-panel {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 20px 20px 24px;
  box-shadow: 0 20px 50px rgba(31, 41, 55, 0.08);
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(47, 111, 109, 0.12);
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(84vw, 320px);
    height: 100dvh;
    z-index: 40;
    border-right: 1px solid var(--line);
    border-bottom: none;
    transform: translateX(-105%);
    transition: transform 200ms ease;
    box-shadow: 0 20px 50px rgba(31, 41, 55, 0.25);
  }

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

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

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

  .mobile-only-inline {
    display: inline-flex;
  }

  .main-panel {
    height: auto;
    min-height: 100dvh;
    padding: 16px 14px 22px;
  }

  .hero {
    margin-bottom: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .hero .flex.gap-2.justify-end {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .chat-panel {
    padding: 14px 12px 18px;
    border-radius: 14px;
  }
}
