:root {
  --bg: #ffffff;
  --bubble-bg: #ffffff;
  --bubble-text: #1c1e21;
  --meta: #8a8f98;
  --success: #2fb66a;
  --failed: #e5484d;
  --running: #3b82f6;
  --queued: #9aa0a6;
  --composer-bg: #ffffff;
  --border: #e5e7eb;
  --navy: #1e2a4a;
  --navy-light: #2a3a63;
  --accent: #f5a623;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--bubble-text);
}

.phone {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ---- App bar ---- */
.appbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}
.appbar-main { font-size: 18px; font-weight: 700; }
.appbar-sub { font-size: 12px; color: #b9c2d8; margin-top: 2px; }
.appbar-right { display: flex; align-items: center; gap: 6px; }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--failed); display: inline-block;
}
.conn-dot.ok { background: var(--success); }
.conn-text { font-size: 11px; color: #cfd6e6; margin-right: 4px; }
.icon-btn {
  background: none; border: none; color: #cfd6e6;
  font-size: 18px; padding: 2px 4px; cursor: pointer;
}

/* ---- Panels / tabs ---- */
.panels { flex: 1; overflow-y: auto; padding: 14px; }
.panel { display: none; }
.panel.active { display: block; }

.tabbar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--composer-bg);
}
.tab {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--meta);
}
.tab.active { color: var(--navy); font-weight: 700; }
.tab-icon { font-size: 18px; }

/* ---- Pipeline banner (on search home): vertical pipe graphic, tap-anywhere ---- */
.pipeline-banner {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-radius: 14px;
  padding: 4px 0 10px;
  margin: 4px 0 14px;
  cursor: pointer;
}
.pipeline-banner img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---- Search ---- */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input {
  flex: 1; border: 1px solid var(--border); border-radius: 20px;
  padding: 10px 14px; font-size: 14px; background: var(--bubble-bg); color: var(--bubble-text);
}
.search-bar button {
  border: none; border-radius: 20px; padding: 0 18px;
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 600;
}
.empty-state { text-align: center; color: var(--meta); font-size: 13px; padding: 40px 10px; }

.result-list { display: flex; flex-direction: column; gap: 8px; }
.result-card {
  background: var(--bubble-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px;
}
.result-top { display: flex; justify-content: space-between; align-items: center; }
.result-name { font-weight: 700; font-size: 13px; }
.result-score { font-size: 11px; color: var(--meta); }
.result-owner { font-size: 11px; color: var(--meta); margin: 2px 0 6px; }
.result-content { font-size: 13px; line-height: 1.4; color: var(--bubble-text); }
.save-btn {
  border: none; background: none; font-size: 16px; color: var(--meta); cursor: pointer;
}
.save-btn.saved { color: var(--accent); }

/* ---- Pipeline secondary screen (slide-in) ---- */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 10;
}
.screen-overlay.open { transform: translateX(0); }

.subheader {
  background: var(--navy);
  color: #fff;
  padding: 14px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
}
.back-btn { font-size: 26px; line-height: 1; }
.subheader-title { font-size: 16px; font-weight: 700; }

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--meta);
  background: var(--bubble-bg);
  border-bottom: 1px solid var(--border);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47,182,106,0.5); }
  70% { box-shadow: 0 0 0 6px rgba(47,182,106,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,182,106,0); }
}

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.divider {
  align-self: center;
  font-size: 11px;
  color: var(--meta);
  background: rgba(0,0,0,0.04);
  padding: 3px 10px;
  border-radius: 10px;
  margin: 10px 0 4px;
}

.row { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff; background: var(--queued);
}
.state-success .avatar { background: var(--success); }
.state-failed .avatar { background: var(--failed); }
.state-running .avatar { background: var(--running); }
.state-queued .avatar { background: var(--queued); }

.bubble-col { display: flex; flex-direction: column; gap: 2px; }
.bubble {
  background: var(--bubble-bg); border: 1px solid var(--border); border-left: 4px solid var(--queued);
  border-radius: 14px; padding: 8px 12px; font-size: 14px; line-height: 1.35;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.state-success .bubble { border-left-color: var(--success); }
.state-failed .bubble { border-left-color: var(--failed); }
.state-running .bubble { border-left-color: var(--running); }
.state-queued .bubble { border-left-color: var(--queued); }

.task-label { font-weight: 600; }
.state-badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px;
  border-radius: 8px; margin-left: 6px; color: #fff;
}
.state-success .state-badge { background: var(--success); }
.state-failed .state-badge { background: var(--failed); }
.state-running .state-badge { background: var(--running); }
.state-queued .state-badge { background: var(--queued); }

.meta-line { font-size: 11px; color: var(--meta); padding-left: 4px; }
