@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --coral: #DD5D32;
  --teal: #538D95;
  --ink: #111113;
  --paper: #FBF8F5;
  --grey: #6B6B70;
  --white: #FFFFFF;

  --gradient: linear-gradient(120deg, var(--coral), var(--teal));
  --border: #E4DFD6;
  --border-hover: #E9BBA6;
  --danger: #B3261E;

  --radius: 10px;
  --font-display: 'Space Grotesk', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --grey-canvas: #A8A6A0;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse 900px 600px at 15% -10%, rgba(221, 93, 50, 0.14), transparent 60%),
    radial-gradient(ellipse 900px 700px at 90% 105%, rgba(83, 141, 149, 0.16), transparent 60%),
    radial-gradient(ellipse 1400px 900px at 50% 30%, #17171B, #0A0A0B 75%);
  background-attachment: fixed;
  color: #E9E7E2;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--coral); }

:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.rail {
  width: 68px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rail:hover {
  width: 68px;
  overflow-y: auto;
  overflow-x: hidden;
}

.rail-mark {
  width: 32px;
  height: 32px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rail-icon {
  width: 42px;
  height: 42px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 18px;
  position: relative;
  color: #B8B8BE;
  transition: color 0.15s ease, background 0.15s ease, transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  flex-shrink: 0;
}

.rail-icon:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--white);
  transform: scale(1.18);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.rail-icon.active {
  color: var(--white);
  background: rgba(221, 93, 50, 0.18);
}

/* Revealed-on-hover section: collapses to nothing by default */
.rail-inbox-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.rail-expand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: max-height 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, transform 0.22s ease;
}

.rail-inbox-group:hover .rail-expand,
.rail-inbox-group:focus-within .rail-expand {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.rail-divider {
  width: 26px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 0;
  flex-shrink: 0;
}

/* Per-network icon — no background chip, just the PNG, with the zoom-focus hover */
.rail-icon.network {
  background: transparent;
  padding: 8px;
}
.rail-icon.network:hover {
  background: transparent;
}
.icon-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 0 transparent);
  transition: filter 0.18s ease;
}
.rail-icon:hover .icon-img {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}
/* Mono icons (line art like the inbox glyph) get inverted to white to sit on the dark rail */
.icon-img.icon-mono {
  filter: invert(1);
}
.rail-icon:hover .icon-img.icon-mono {
  filter: invert(1) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.badge {
  position: absolute;
  top: 0px;
  right: 0px;
  background: var(--coral);
  color: white;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.badge.show { display: flex; }

/* ---------- Content ---------- */
.content {
  flex: 1;
  min-width: 0;
  padding: 40px 32px;
  max-width: 880px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  color: #F3F1EC;
}

.subhead {
  color: var(--grey-canvas);
  margin: 0 0 28px;
  font-size: 15px;
}

h2 {
  font-family: var(--font-body);
  font-size: 13px;
  margin: 32px 0 10px;
  color: var(--grey-canvas);
  font-weight: 600;
}
.card h2, .row h2 {
  color: var(--grey);
}

/* ---------- Cards & rows ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  background: var(--white);
  color: var(--ink);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--white);
  color: var(--ink);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

a.row {
  color: inherit;
  display: flex;
}

a.row:hover, .row.hoverable:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.row-empty {
  color: var(--grey);
  font-size: 14px;
  padding: 12px 14px;
}

/* network pill */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(83, 141, 149, 0.12);
  color: var(--teal);
  white-space: nowrap;
}
.pill.coral { background: rgba(221, 93, 50, 0.12); color: var(--coral); }
.pill.muted { background: #EFEBE3; color: var(--grey); }

/* avatar */
.avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
}
.avatar.tint-coral { background: var(--coral); }
.avatar.tint-teal { background: var(--teal); }
.avatar.tint-ink { background: var(--ink); }

/* conversation row */
.conv-row {
  align-items: center;
  gap: 12px;
}
.conv-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conv-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-preview {
  font-size: 13px;
  color: var(--grey);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--coral);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.12s ease;
}
.btn:hover { opacity: 0.88; color: white; }
.btn.secondary { background: var(--white); color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { border-color: var(--border-hover); color: var(--ink); }
.btn.danger { background: var(--danger); }

/* ---------- Forms ---------- */
input[type=text], input[type=password], input[type=email], input[type=datetime-local], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--white);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--teal);
}
textarea { min-height: 100px; resize: vertical; }
label { font-size: 13px; color: var(--grey); font-weight: 500; }

/* ---------- Status text ---------- */
.status-ok { color: #3E7A4A; font-weight: 600; }
.status-error { color: var(--danger); font-weight: 600; }
.status-pending { color: var(--grey); font-weight: 600; }

/* ---------- Collapsible source groups (inbox) ---------- */
details.source-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--white);
  color: var(--ink);
  overflow: hidden;
}
details.source-group summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
details.source-group summary::-webkit-details-marker { display: none; }
details.source-group summary::after {
  content: '+';
  color: var(--grey);
  font-weight: 400;
  font-size: 18px;
}
details.source-group[open] summary::after { content: '–'; }
details.source-group summary .count {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  color: var(--grey);
  margin-left: auto;
  margin-right: 12px;
}
.source-group-body { padding: 0 12px 12px; }
.overflow-note {
  font-size: 13px;
  color: var(--grey);
  padding: 8px 4px 2px;
}

.two-col { display: flex; gap: 24px; }
.two-col .col { flex: 1; min-width: 0; }

.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 8px;
  background: var(--white);
  border: 1px solid var(--border);
}
.msg-bubble.mine {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
  margin-left: auto;
}

.thread-header, .panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  position: relative;
}
.panel-title { font-size: 18px; margin: 0 0 2px; font-family: var(--font-display); }

.thread {
  margin-bottom: 20px;
}

.composer textarea {
  border: none;
  padding: 4px;
}
.composer textarea:focus { border: none; outline: none; }
.composer-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ---------- Inbox split view ---------- */
body.inbox-page .content { max-width: 1120px; }

.inbox-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.inbox-list {
  flex: 1 1 420px;
  max-width: 460px;
  min-width: 0;
}
.thread-panel {
  flex: 1 1 500px;
  min-width: 0;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  padding: 20px;
}
.panel-placeholder {
  color: var(--grey);
  font-size: 14px;
  padding: 60px 20px;
  text-align: center;
}
.panel-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -6px;
  right: 0;
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--grey);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: background 0.12s ease, color 0.12s ease;
}
.panel-close:hover {
  background: var(--border);
  color: var(--ink);
}
.panel-header { padding-right: 36px; }

@media (max-width: 900px) {
  .inbox-layout { flex-direction: column; }
  .inbox-list { max-width: none; }
  .thread-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    max-height: 100vh;
    border-radius: 0;
    display: none;
  }
  .thread-panel.open { display: block; }
}

.muted-tag {
  font-size: 11px;
  color: var(--grey);
}

code, pre {
  background: #F0ECE3;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
}

@media (max-width: 600px) {
  .two-col { flex-direction: column; }
  .content { padding: 20px 16px; }
  .rail { width: 56px; }
}

/* ---------- Home: dark hero ---------- */
/* Home's centered hero column width (background is now the app-wide default) */
body.dark-hero .content { max-width: 640px; margin: 0 auto; }

.hero-greeting {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  color: white;
  letter-spacing: -0.01em;
  margin-top: 24px;
}
.hero-sub {
  color: rgba(255, 255, 255, 0.5);
  margin: 4px 0 32px;
  font-size: 15px;
}
.hero-section-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  margin: 28px 0 10px;
}
.hero-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  color: inherit;
  transition: transform 0.12s ease, background 0.12s ease;
}
a.hero-card:hover {
  background: rgba(255, 255, 255, 0.075);
  transform: translateY(-1px);
}
.hero-card-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.hero-card-body { flex: 1; min-width: 0; }
.hero-card-title {
  color: white;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-card-desc {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.hero-card-actions .btn { padding: 6px 12px; font-size: 12px; }
.hero-empty {
  color: rgba(255, 255, 255, 0.35);
  font-size: 14px;
  padding: 10px 2px 2px;
}
.ask-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px 14px 12px 18px;
  margin-top: 36px;
}
.ask-bar input {
  background: transparent;
  border: none;
  color: white;
  flex: 1;
  padding: 0;
  font-size: 14px;
}
.ask-bar input::placeholder { color: rgba(255, 255, 255, 0.4); }
.ask-bar input:focus { border: none; outline: none; }
.ask-bar button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
