/* =====================================================
   Chat portfolio — Crocker / AI
   ===================================================== */

:root {
  --bg:        #1a1916;
  --bg-2:      #221f1c;
  --surface:   #2a2724;
  --surface-2: #34302c;
  --ink:       #ede9dd;
  --ink-2:     #c8c3b5;
  --mute:      #8a8579;
  --mute-2:    #5a564d;
  --hairline:  rgba(237, 233, 221, 0.08);
  --hairline-2: rgba(237, 233, 221, 0.16);

  --accent:    #e8856b;
  --accent-2:  #f4b88e;
  --accent-faint: rgba(232, 133, 107, 0.12);

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --sidebar-w: 280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { background: var(--bg); }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  font-size: 14.5px;
}
a { color: inherit; }

button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input { font: inherit; }

/* ===== APP SHELL ===== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
}

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

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 280ms cubic-bezier(.2,.7,.2,1);
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 84vw;
    max-width: 320px;
    z-index: 30;
    transform: translateX(-100%);
    box-shadow: 0 0 80px rgba(0,0,0,0.5);
  }
  .sidebar.is-open { transform: translateX(0); }
}

.sb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--hairline);
}
.sb-toggle, .sb-new {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  transition: background 150ms, color 150ms;
}
.sb-toggle:hover, .sb-new:hover { background: var(--surface); color: var(--ink); }
.sb-logo {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
}
.sb-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}
.sb-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.sb-section { flex: 1; overflow-y: auto; padding: 16px 8px; min-height: 0; }
.sb-section--alt {
  flex: 0 0 auto;
  border-top: 1px solid var(--hairline);
  padding: 12px 8px;
}
.sb-section-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  padding: 4px 10px;
  margin-bottom: 8px;
}

.sb-altview {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 150ms, color 150ms, border-color 150ms;
  border: 1px solid var(--hairline);
  background: var(--bg-2);
}
.sb-altview:hover {
  background: var(--accent-faint);
  color: var(--accent-2);
  border-color: var(--accent);
}
.sb-altview > svg:first-child {
  flex: 0 0 auto;
  stroke: currentColor;
  opacity: 0.85;
}
.sb-altview-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.sb-altview-title {
  font-size: 13px; font-weight: 600; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-altview-sub {
  font-size: 10.5px; color: var(--mute); line-height: 1.2; letter-spacing: 0.02em;
}
.sb-altview:hover .sb-altview-sub { color: var(--accent); }
.sb-altview-arr { flex: 0 0 auto; opacity: 0.5; stroke: currentColor; }
.sb-altview:hover .sb-altview-arr { opacity: 1; }

.sb-list { display: flex; flex-direction: column; gap: 2px; }
.sb-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13.5px;
  color: var(--ink-2);
  transition: background 150ms, color 150ms;
}
.sb-item:hover { background: var(--surface); color: var(--ink); }
.sb-item.is-active { background: var(--surface); color: var(--ink); }
.sb-item-title {
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-item-time {
  font-size: 10.5px;
  color: var(--mute);
  letter-spacing: 0.02em;
}

.sb-foot {
  border-top: 1px solid var(--hairline);
  padding: 12px;
}
.sb-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 8px;
}
.sb-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
}
.sb-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 30%;
}
.sb-profile-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.sb-profile-role { font-size: 11px; color: var(--mute); line-height: 1.2; margin-top: 1px; }

/* ===== CHAT MAIN ===== */

.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

.chat-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(26,25,22,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 5;
}
.chat-menu {
  width: 32px; height: 32px;
  display: none;
  border-radius: 8px;
  color: var(--ink-2);
  align-items: center; justify-content: center;
}
.chat-menu:hover { background: var(--surface); color: var(--ink); }
@media (max-width: 820px) { .chat-menu { display: flex; } }

.chat-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-model {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.chat-status {
  font-size: 11px;
  color: var(--mute);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.chat-status .pulse {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.4); opacity: 0.6; } }

.chat-resume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.chat-resume:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.chat-lang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  margin-left: 6px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--mute);
  text-decoration: none;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.chat-lang:hover {
  color: var(--ink);
  border-color: var(--ink-2);
  background: var(--surface);
}

/* ===== CHAT THREAD ===== */

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0 24px;
  scroll-behavior: smooth;
}

.msg-row {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 24px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  animation: msgIn 400ms cubic-bezier(.2,.7,.2,1) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-2);
  margin-top: 4px;
  overflow: hidden;
}
.msg-row.is-ai .msg-avatar {
  background: var(--accent-faint);
  color: var(--accent);
  border-color: var(--accent-faint);
}
.msg-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 28%;
}

.msg-body { min-width: 0; }
.msg-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--mute);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.msg-row.is-ai .msg-name { color: var(--accent); }

.msg-content {
  font-size: 14.5px;
  line-height: 1.62;
  color: var(--ink);
}
.msg-content p { margin: 0 0 12px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { font-weight: 600; color: var(--ink); }
.msg-content em { font-style: italic; color: var(--accent-2); }
.msg-content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
}
.msg-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.msg-content ol, .msg-content ul { margin: 0 0 12px; padding-left: 22px; }
.msg-content li { margin-bottom: 6px; line-height: 1.55; }
.msg-content .num-list { padding-left: 22px; }
.msg-content .role-list {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 12px 16px;
  line-height: 1.6;
  margin-bottom: 12px;
}

/* card */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 10px 0 14px;
  transition: border-color 200ms, transform 250ms;
}
.card:hover { border-color: var(--hairline-2); }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.card-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-faint);
  padding: 3px 8px;
  border-radius: 999px;
}
.card-org {
  font-size: 11.5px;
  color: var(--mute);
  letter-spacing: 0.02em;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.card-desc {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 10px;
}
.card-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--mute);
  padding-top: 8px;
  border-top: 1px dashed var(--hairline);
}

/* partners list inside message */
.partners-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 10px;
}
.partner {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

/* stack grid inside message */
.stack-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 12px 0;
}
@media (min-width: 600px) { .stack-grid { grid-template-columns: 1fr 1fr; } }
.stack-box {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 12px 14px;
}
.stack-h {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.stack-body {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* contact grid */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 10px 0;
}
@media (min-width: 600px) { .contact-grid { grid-template-columns: 1fr 1fr; } }
.contact-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  text-decoration: none;
  transition: background 150ms, border-color 150ms;
}
.contact-pill:hover { background: var(--surface-2); border-color: var(--hairline-2); }
.cp-k {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}
.cp-v {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
}
.contact-pill:hover .cp-v { color: var(--accent); }

/* action chips */
.msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.chip {
  font-size: 12.5px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-2);
  transition: background 150ms, border-color 150ms, color 150ms, transform 150ms;
}
.chip:hover {
  background: var(--accent-faint);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.inline-chip {
  display: inline-block;
  font-size: inherit;
  padding: 2px 9px;
  background: var(--accent-faint);
  border: 1px solid var(--accent-faint);
  border-radius: 999px;
  color: var(--accent);
  transition: background 150ms;
  margin: 0 2px;
}
.inline-chip:hover { background: var(--accent); color: var(--bg); }

/* typing indicator */
.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.typing span {
  width: 6px; height: 6px;
  background: var(--mute);
  border-radius: 50%;
  animation: blink 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* caret while typing */
.caret {
  display: inline-block;
  width: 6px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: caretBlink 1s steps(2) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

/* ===== INPUT AREA ===== */

.chat-input-wrap {
  border-top: 1px solid var(--hairline);
  padding: 12px 24px 16px;
  background: var(--bg);
}

.chat-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
.chat-suggestions .sg {
  font-size: 12.5px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-2);
  transition: background 150ms, color 150ms, border-color 150ms, transform 150ms;
}
.chat-suggestions .sg:hover {
  background: var(--accent-faint);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.chat-input {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: 14px;
  transition: border-color 200ms, box-shadow 200ms;
}
.chat-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-faint);
}
.chat-attach {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--mute);
  border-radius: 8px;
}
.chat-attach:hover { color: var(--ink); background: var(--surface-2); }
#chat-text {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 4px;
  color: var(--ink);
  outline: none;
  font-size: 14px;
}
#chat-text::placeholder { color: var(--mute); }
.chat-send {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 150ms, transform 150ms, background 200ms;
}
.chat-send:hover { transform: translateY(-1px); }
.chat-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.chat-foot {
  max-width: 760px;
  margin: 8px auto 0;
  font-size: 10.5px;
  color: var(--mute);
  text-align: center;
  letter-spacing: 0.02em;
}

/* mobile overlay when sidebar open */
.sb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms;
}
.sb-overlay.is-on { opacity: 1; pointer-events: auto; }

::selection { background: var(--accent); color: var(--bg); }

/* scrollbar */
.chat-thread::-webkit-scrollbar,
.sb-section::-webkit-scrollbar { width: 6px; }
.chat-thread::-webkit-scrollbar-thumb,
.sb-section::-webkit-scrollbar-thumb { background: var(--hairline-2); border-radius: 3px; }
