/* Meus App — chat shell */

.app {
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sb-head {
  padding: 14px 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
}
.sb-logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  display: grid;
  place-items: center;
  color: white;
  font-size: 12px;
  font-weight: 700;
}
.sb-icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid; place-items: center;
  transition: all 0.12s;
}
.sb-icon-btn:hover { background: var(--sidebar-hover); color: var(--text); }
.sb-icon-btn svg { width: 15px; height: 15px; }

.sb-new {
  margin: 4px 8px 12px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.12s;
}
.sb-new:hover { background: var(--sidebar-hover); }
.sb-new svg { width: 14px; height: 14px; }

.sb-search {
  margin: 0 8px 12px;
  position: relative;
}
.sb-search input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1px solid transparent;
  background: var(--sidebar-hover);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: all 0.12s;
}
.sb-search input:focus { border-color: var(--border-strong); background: var(--bg); }
.sb-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 13px; height: 13px; color: var(--text-subtle); }

.sb-scroll { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.sb-group-label {
  font-size: 11px;
  color: var(--text-subtle);
  padding: 12px 10px 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.sb-item {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}
.sb-item:hover { background: var(--sidebar-hover); }
.sb-item.active { background: var(--sidebar-hover); font-weight: 500; }
.sb-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-item .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex-shrink: 0; opacity: 0; }
.sb-item.active .dot { opacity: 1; }

.sb-foot {
  border-top: 1px solid var(--border);
  padding: 10px 8px;
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.sb-user:hover { background: var(--sidebar-hover); }
.sb-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { font-size: 13px; font-weight: 500; }
.sb-user-plan { font-size: 11px; color: var(--text-muted); }

/* ── Main chat column ────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.topbar {
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
}
.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-model {
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--canvas);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.topbar-model svg { width: 10px; height: 10px; }
.topbar-spacer { flex: 1; }
.topbar-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.12s;
}
.topbar-btn:hover { background: var(--canvas); color: var(--text); }
.topbar-btn svg { width: 14px; height: 14px; }

/* Chat scroll region */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 20px;
}
.chat-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

.msg {
  padding: 16px 0;
  display: flex;
  gap: 14px;
}
.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
}
.msg-avatar.user {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
}
.msg-avatar.assistant {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
}
.msg-body { flex: 1; min-width: 0; padding-top: 2px; }
.msg-role { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.msg-content {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
}
.msg-content p { margin: 0 0 12px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--canvas);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.msg-content pre {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 10px 0;
  line-height: 1.55;
}
.msg-content pre code {
  background: transparent;
  padding: 0;
  border: 0;
}
.msg-content ul, .msg-content ol { margin: 8px 0; padding-left: 22px; }
.msg-content li { margin: 4px 0; }
.msg-content strong { font-weight: 600; }

.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-action {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid; place-items: center;
  transition: all 0.1s;
}
.msg-action:hover { background: var(--canvas); color: var(--text); }
.msg-action svg { width: 14px; height: 14px; }

/* Tool call cards inside chat */
.tool-card {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--canvas);
}
.tool-card-head {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.tool-card-icon {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid; place-items: center;
}
.tool-card-icon svg { width: 12px; height: 12px; }
.tool-card-name { font-weight: 500; color: var(--text); }
.tool-card-arg { color: var(--text-muted); font-family: var(--font-mono); }
.tool-card-status { margin-left: auto; color: var(--success); font-size: 11px; display: flex; align-items: center; gap: 4px; }
.tool-card-status svg { width: 12px; height: 12px; }
.tool-card-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.55;
}

/* Attachment chips inside message */
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
  color: var(--text);
  margin-right: 6px;
  margin-bottom: 6px;
}
.attach-chip svg { width: 12px; height: 12px; color: var(--text-muted); }

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

/* Composer */
.composer-wrap {
  padding: 8px 24px 20px;
  background: var(--bg);
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  padding: 8px 8px 8px 16px;
  transition: border-color 0.15s;
}
.composer:focus-within { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.composer-attaches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 4px;
}
.composer-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 0 4px;
  min-height: 24px;
  max-height: 180px;
}
.composer-textarea::placeholder { color: var(--text-subtle); }
.composer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.composer-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  display: flex; align-items: center; gap: 5px;
  transition: all 0.12s;
}
.composer-btn:hover { background: var(--canvas); color: var(--text); }
.composer-btn svg { width: 15px; height: 15px; }
.composer-btn.icon { width: 32px; padding: 0; justify-content: center; }
.composer-send {
  margin-left: auto;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  display: grid; place-items: center;
  transition: all 0.12s;
}
.composer-send:hover { background: var(--accent-hover); }
.composer-send:disabled { background: var(--border-strong); cursor: not-allowed; }
.composer-send svg { width: 15px; height: 15px; }

.composer-hint {
  max-width: 760px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
}
.composer-hint a { color: var(--accent-text); text-decoration: none; }

/* Empty state */
.empty {
  max-width: 720px;
  margin: 0 auto;
  padding: 60px 24px 20px;
  text-align: center;
}
.empty-logo {
  width: 44px; height: 44px;
  margin: 0 auto 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
  font-size: 20px;
  box-shadow: var(--shadow-xl);
}
.empty-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.empty-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.empty-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
}
.suggest {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.suggest:hover { border-color: var(--border-strong); background: var(--canvas); transform: translateY(-1px); }
.suggest-title { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.suggest-sub { font-size: 12px; color: var(--text-muted); }

/* ── Right activity panel ────────────────────────────────────── */
.activity {
  background: var(--sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.activity-tabs {
  display: flex;
  padding: 8px 12px 0;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  height: 48px;
  align-items: center;
}
.activity-tab {
  padding: 6px 12px;
  border-radius: 6px 6px 0 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.12s;
  position: relative;
  margin-bottom: -1px;
}
.activity-tab:hover { color: var(--text); }
.activity-tab.active { color: var(--text); }
.activity-tab.active::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px; bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
.activity-tab svg { width: 13px; height: 13px; }
.activity-tab .count {
  background: var(--sidebar-hover);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
}

.activity-scroll { flex: 1; overflow-y: auto; padding: 12px; }

/* Timeline entry */
.tl-entry {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: 12px;
  position: relative;
}
.tl-rail {
  width: 20px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  position: relative;
}
.tl-rail::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0; bottom: -6px;
  width: 1px;
  background: var(--border);
  transform: translateX(-50%);
}
.tl-entry:last-child .tl-rail::before { display: none; }
.tl-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sidebar);
  border: 1.5px solid var(--border-strong);
  z-index: 1;
  display: grid; place-items: center;
  color: var(--text-muted);
}
.tl-dot.done { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.tl-dot.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  animation: pulse-ring 2s infinite;
}
.tl-dot svg { width: 9px; height: 9px; }
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

.tl-content { flex: 1; min-width: 0; padding-top: 1px; padding-bottom: 8px; }
.tl-title {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
}
.tl-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-nested {
  margin-top: 6px;
  padding: 6px 10px;
  border-left: 2px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.tl-nested div { padding: 2px 0; }

.tl-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-subtle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 8px 0 6px;
  padding: 0 4px;
}

/* Todo card */
.todo-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
  margin-bottom: 12px;
}
.todo-head {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--canvas);
}
.todo-head-title { font-size: 12px; font-weight: 600; flex: 1; }
.todo-head-count { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.todo-list { padding: 6px 0; }
.todo-item {
  padding: 6px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
}
.todo-check {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
  margin-top: 1px;
  display: grid; place-items: center;
}
.todo-check.done { background: var(--accent); border-color: var(--accent); color: white; }
.todo-check.active { border-color: var(--accent); }
.todo-check svg { width: 8px; height: 8px; }
.todo-item.done .todo-text { color: var(--text-muted); text-decoration: line-through; }
.todo-item.active .todo-text { color: var(--accent-text); font-weight: 500; }
.todo-text { flex: 1; line-height: 1.4; }
.todo-progress {
  height: 3px;
  background: var(--canvas);
}
.todo-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* Stats footer in activity */
.act-stats {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  font-size: 11px;
}
.stat-block { text-align: center; }
.stat-val { font-weight: 600; color: var(--text); font-size: 13px; }
.stat-label { color: var(--text-muted); margin-top: 2px; }

/* Utility */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
