/* =========================
   Hyperlex layout + theming
   ========================= */

html {
  scroll-behavior: smooth;
}

.hx-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
               "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

/* ---------- LIGHT THEME ---------- */

.hx-app[data-theme="light"] {
  --hx-color-bg:            #f3f4f6;
  --hx-color-surface:       #ffffff;
  --hx-color-surface-alt:   #eef2ff;
  --hx-color-sidebar:       #ffffff;

  --hx-color-border-subtle: #e5e7eb;
  --hx-color-border-strong: #cbd5f5;

  --hx-color-text:          #0f172a;
  --hx-color-text-soft:     #374151;
  --hx-color-text-muted:    #6b7280;

  --hx-color-accent:        #2563eb;
  --hx-color-accent-soft:   rgba(37, 99, 235, 0.08);
  --hx-color-accent-strong: #1d4ed8;

  --hx-shadow-soft:         0 1px 3px rgba(15, 23, 42, 0.16);
}

/* ---------- DARK THEME ---------- */

.hx-app[data-theme="dark"] {
  --hx-color-bg:            #020617;
  --hx-color-surface:       #020617;
  --hx-color-surface-alt:   #0b1120;
  --hx-color-sidebar:       #020617;

  --hx-color-border-subtle: #1e293b;
  --hx-color-border-strong: #334155;

  --hx-color-text:          #e5e7eb;
  --hx-color-text-soft:     #e5e7eb;
  --hx-color-text-muted:    #9ca3af;

  --hx-color-accent:        #3b82f6;
  --hx-color-accent-soft:   rgba(59, 130, 246, 0.16);
  --hx-color-accent-strong: #2563eb;

  --hx-shadow-soft:         0 1px 3px rgba(0, 0, 0, 0.7);
}

.hx-app {
  background: var(--hx-color-bg);
  color: var(--hx-color-text);
}

/* =========================
   HEADER
   ========================= */

.hx-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--hx-color-surface);
  border-bottom: 1px solid var(--hx-color-border-subtle);
  gap: 1rem;
  flex-wrap: wrap;
}

.hx-header__title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.hx-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hx-logo {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--hx-color-text);
  text-decoration: none;
}

.hx-header-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  font-size: 0.85rem;
}

.hx-header-nav a {
  color: var(--hx-color-text-soft);
  text-decoration: none;
  padding: 0.25rem 0;
}

.hx-header-nav a:hover,
.hx-header-nav a:focus {
  color: var(--hx-color-accent);
}

.hx-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.hx-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hx-chat-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.hx-chip {
  border-radius: 999px;
  border: 1px solid var(--hx-color-border-subtle);
  background: var(--hx-color-surface);
  color: var(--hx-color-text-soft);
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}

.hx-chip--ghost {
  background: transparent;
}

.hx-btn-small,
.hx-btn--sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

.hx-link-button--header {
  font-size: 0.85rem;
  color: var(--hx-color-text);
}

.hx-app .hx-show-auth {
  display: none;
}

.hx-app.hx-authenticated .hx-show-auth {
  display: flex;
}

.hx-app.hx-authenticated .hx-show-unauth {
  display: none;
}

.hx-app.hx-unauthenticated #panel {
  display: none;
}

.hx-app.hx-authenticated #hx-landing {
  display: none;
}

.hx-app.hx-authenticated #panel {
  display: block;
}

.hx-landing {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 1.5rem 3rem;
}

.hx-section {
  padding: 2.5rem 0;
  max-width: 960px;
  margin: 0 auto;
  line-height: 1.65;
}

.hx-section-hero {
  padding-top: 1rem;
}

.hx-section h1,
.hx-section h2,
.hx-section h3 {
  margin: 0 0 1rem 0;
  font-weight: 600;
}

.hx-section p {
  margin: 0 0 1rem 0;
}

.hx-hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem;
  align-items: start;
}

.hx-eyebrow {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--hx-color-text-muted);
}

.hx-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0 1rem;
}

.hx-hero-note,
.hx-cta-note {
  font-size: 0.9rem;
  color: var(--hx-color-text-muted);
}

.hx-auth-card {
  align-self: stretch;
}

.hx-auth-card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.hx-auth-note {
  font-size: 0.85rem;
  color: var(--hx-color-text-muted);
}

.hx-section-cards .hx-card-grid {
  margin-top: 1.5rem;
}

.hx-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.hx-section-muted {
  background: var(--hx-color-surface-alt);
  border-radius: 1rem;
  padding: 2.5rem;
}

.hx-section-cta {
  text-align: center;
}

.hx-section-cta button {
  margin-top: 1rem;
}

.hx-contact a {
  color: var(--hx-color-accent);
  text-decoration: none;
}

.hx-footer {
  border-top: 1px solid var(--hx-color-border-subtle);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--hx-color-text-muted);
}

@media (max-width: 768px) {
  .hx-header-nav {
    width: 100%;
    justify-content: center;
  }

  .hx-header-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* =========================
   MAIN LAYOUT
   ========================= */

.hx-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1rem 1.5rem 1.5rem;
  align-items: flex-start;
}

/* =========================
   SIDEBAR
   ========================= */

.hx-sidebar {
  background: var(--hx-color-sidebar);
  border-radius: 0.75rem;
  border: 1px solid var(--hx-color-border-subtle);
  box-shadow: var(--hx-shadow-soft);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.hx-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hx-sidebar__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--hx-color-text-soft);
}

.hx-icon-button {
  border-radius: 999px;
  border: 1px solid var(--hx-color-border-subtle);
  background: transparent;
  padding: 0.1rem 0.45rem;
  font-size: 0.85rem;
  color: var(--hx-color-text-muted);
  cursor: pointer;
}

/* Search row */

.hx-sidebar__search {
  display: flex;
  gap: 0.35rem;
}

.hx-sidebar__search input {
  flex: 1 1 auto;
  border-radius: 999px;
  border: 1px solid var(--hx-color-border-subtle);
  padding: 0.32rem 0.6rem;
  font-size: 0.8rem;
  background: var(--hx-color-surface);
  color: var(--hx-color-text);
}

.hx-sidebar__search input::placeholder {
  color: var(--hx-color-text-muted);
}

/* Conversation list */

.hx-conversation-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  padding-right: 0.15rem;
}

/* Conversation item */

.hx-conversation {
  border-radius: 0.55rem;
  border: 1px solid transparent;
  background: var(--hx-color-surface);
  padding: 0.45rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  cursor: pointer;
  text-align: left;
}

.hx-conversation:hover {
  border-color: var(--hx-color-border-strong);
}

.hx-conversation--active {
  background: var(--hx-color-accent-soft);
  border-color: var(--hx-color-accent);
}

/* Conversation header: title + time */

.hx-conversation__header {
  display: flex;
  flex-direction: column;   /* was row */
  align-items: stretch;
  gap: 0.15rem;
}

.hx-conversation__title {
  flex: 0 0 auto;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--hx-color-text);
}

.hx-conversation__time {
  align-self: flex-end;     /* right align within the card */
  margin-left: 0;           /* remove previous margin */
  margin-top: 0;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--hx-color-text-muted);
}

/* Meta row (icons, etc.) */

.hx-conversation__meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.1rem;
}

/* Pager */

.hx-sidebar__pager {
  border-top: 1px solid var(--hx-color-border-subtle);
  padding-top: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--hx-color-text-muted);
}

.hx-link-button {
  border: none;
  background: none;
  color: var(--hx-color-text-soft);
  font-size: 0.75rem;
  padding: 0;
  cursor: pointer;
}

/* =========================
   RIGHT COLUMN
   ========================= */

.hx-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Generic card */

.hx-card {
  background: var(--hx-color-surface);
  border-radius: 0.75rem;
  border: 1px solid var(--hx-color-border-subtle);
  box-shadow: var(--hx-shadow-soft);
  padding: 0.8rem 1rem;
}

/* Input card */

.hx-card--input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hx-card--input textarea {
  width: 100%;
  resize: vertical;
  min-height: 130px;
  border-radius: 0.55rem;
  border: 1px solid var(--hx-color-border-subtle);
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
  background: var(--hx-color-surface-alt);
  color: var(--hx-color-text);
}

.hx-card--input textarea::placeholder {
  color: var(--hx-color-text-muted);
}

.hx-card__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Buttons */

.hx-btn {
  border-radius: 0.55rem;
  border: 1px solid transparent;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.hx-btn--sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
}

.hx-btn--primary {
  background: var(--hx-color-accent);
  color: #ffffff;
}

.hx-btn--secondary {
  background: var(--hx-color-surface);
  border-color: var(--hx-color-border-subtle);
  color: var(--hx-color-text-soft);
}

/* =========================
   ARTICLE / TEXT
   ========================= */

.hx-article {
  max-width: 78ch;
  font-size: 1rem;
  line-height: 1.6;
}

.hx-article h1,
.hx-article h2,
.hx-article h3 {
  font-weight: 600;
  margin-top: 1.6em;
  margin-bottom: 0.6em;
}

.hx-article h1 { font-size: 1.55rem; }
.hx-article h2 { font-size: 1.35rem; }
.hx-article h3 { font-size: 1.15rem; }

.hx-article p {
  margin: 0 0 0.85em 0;
}

.hx-article ul,
.hx-article ol {
  margin: 0.4em 0 1em 1.3em;
  padding: 0;
}

.hx-article li {
  margin-bottom: 0.35em;
}
