/* OpenClaw Operator Console — minimal CSS */

/* Mobile console-drawer (settings): hidden on desktop, off-canvas on mobile.
   Uses its own body class (console-drawer-open) so it's independent of
   the primary-nav sidebar. */
.console-drawer { display: none; }
#drawer-backdrop { display: none; }

/* Mobile sidebar toggle (primary nav) */
.hamburger {
  display: none;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  line-height: 0;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-size: 0; /* hide any text/icon glyph to avoid empty box rendering */
}
.hamburger:focus,
.hamburger:hover {
  outline: none;
  background: var(--hover);
  border-color: var(--accent);
  color: var(--text);
}

/* Console-local hamburger for settings drawer */
.console-hamburger {
  display: none;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  line-height: 0;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-size: 0;
}
.console-hamburger:focus,
.console-hamburger:hover { outline: none; background: var(--hover); border-color: var(--accent); color: var(--text); }

/* Hamburger icon built from spans for better control/animation */
.hamburger > span,
.console-hamburger > span {
  display: block;
  width: 24px;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.hamburger > span + span,
.console-hamburger > span + span { margin-top: 5px; }
/* Animate to X when open (targets the 3 visible bars) */
body.sidebar-open .hamburger > span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
body.sidebar-open .hamburger > span:nth-child(2) { opacity: 0; }
body.sidebar-open .hamburger > span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

body.sidebar-open .console-hamburger > span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
body.sidebar-open .console-hamburger > span:nth-child(2) { opacity: 0; }
body.sidebar-open .console-hamburger > span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* Full-screen backdrop for mobile sidebar */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(1px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 40;
}

/* Show when sidebar open */
body.sidebar-open .backdrop {
  opacity: 1;
  visibility: visible;
}

/* Scroll-to-bottom floating action button */
.scroll-bottom-btn {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 0.75rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4.5rem);
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: 21px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}
.scroll-bottom-btn:hover { opacity: 0.92; }
@media (min-width: 768px) {
  .scroll-bottom-btn { display: none !important; }
}

/* Mobile off-canvas behavior */
@media (max-width: 767.98px) {
  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    right: calc(env(safe-area-inset-right, 0px) + 0.5rem);
    left: auto;
    z-index: 100;
  }

  .console-drawer {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 300px;
    max-width: 85vw;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 70;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.console-drawer-open .console-drawer { transform: translateX(0); }
  body.console-drawer-open #drawer-backdrop { display: block; opacity: 1; visibility: visible; }
  body.console-drawer-open { overflow: hidden; }

  /* Console header hamburger for settings — positioned RIGHT to avoid title overlap */
  .console-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    right: calc(env(safe-area-inset-right, 0px) + 0.5rem);
    left: auto;
    z-index: 95;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Prevent background scroll when menu open */
  body.sidebar-open {
    overflow: hidden;
  }

  /* Main content padding on mobile */
  .main {
    padding: 1rem;
    padding-top: calc(env(safe-area-inset-top, 0px) + 3rem); /* create space under fixed hamburger so it doesn't cover header */
  }
}

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-sidebar: #0f3460;
  --text: #e0e0e0;
  --text-muted: #a8bbc8;
  --accent: #29bde0;
  --green: #3dd68c;
  --red: #f15f50;
  --orange: #f39c12;
  --yellow: #f1c40f;
  --gray: #9badb0;
  --border: #2c3e50;
  --hover: #1a3a5c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--bg-sidebar);
  padding: 1rem 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
.sidebar .brand {
  padding: 0.5rem 1rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.sidebar nav a {
  display: flex;
  padding: 0.6rem 1.2rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;

  align-items: center;
  min-height: 44px;}
.sidebar nav a:hover, .sidebar nav a.active {
  background: var(--hover);
  color: var(--text);
  border-left-color: var(--accent);
}
.sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.sidebar .sidebar-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.sidebar .sidebar-footer a:hover { color: var(--text); }
.logout-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 0.75rem; padding: 0; text-decoration: none;

  display: inline-flex;
  align-items: center;
  min-height: 44px;}
.logout-btn:hover { color: var(--text); text-decoration: underline; }

/* Main content */
.main {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

h1 { font-size: 1.5rem; margin-bottom: 1.2rem; font-weight: 600; }
h2 { font-size: 1.15rem; margin-bottom: 0.8rem; font-weight: 600; color: var(--text-muted); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}
.card .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.3rem; }
.card .value { font-size: 1.6rem; font-weight: 700; }
.card .sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

/* Tables */
.table-wrap { overflow-x: auto; margin-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; padding: 0.6rem 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); }
td { padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--border); }
tr:hover td { background: rgba(255,255,255,0.02); }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* Badges */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 3px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-ok, .badge-active, .badge-read { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-limited { background: rgba(243,156,18,0.15); color: var(--orange); }
.badge-error, .badge-denied, .badge-expired { background: rgba(231,76,60,0.15); color: var(--red); }
.badge-write { background: rgba(243,156,18,0.15); color: var(--orange); }
.badge-revoked, .badge-inactive, .badge-none { background: rgba(127,140,141,0.15); color: var(--gray); }
.badge-unreachable { background: rgba(231,76,60,0.15); color: var(--red); }
.badge-low { background: rgba(46,204,113,0.1); color: var(--green); }
.badge-medium { background: rgba(241,196,15,0.1); color: var(--yellow); }
.badge-high { background: rgba(243,156,18,0.15); color: var(--orange); }
.badge-critical { background: rgba(231,76,60,0.15); color: var(--red); }

/* Sections */
.section { margin-bottom: 2rem; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.detail-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem 1rem; }
.detail-item .label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.detail-item .val { font-size: 1rem; margin-top: 0.2rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;

  min-height: 44px;}
.btn:hover { background: var(--hover); border-color: var(--accent); }
.btn-exec { border-color: var(--orange); color: var(--orange); }
.btn-exec:hover { background: rgba(243,156,18,0.1); }
.btn-sm { padding: 0.55rem 0.7rem; font-size: 0.75rem; 
  min-height: 44px;}

/* Messages */
.messages { margin-bottom: 1rem; }
.msg { padding: 0.6rem 1rem; border-radius: 4px; margin-bottom: 0.5rem; font-size: 0.85rem; }
.msg-success { background: rgba(46,204,113,0.1); border: 1px solid var(--green); color: var(--green); }
.msg-error { background: rgba(231,76,60,0.1); border: 1px solid var(--red); color: var(--red); }
.msg-warning { background: rgba(243,156,18,0.1); border: 1px solid var(--orange); color: var(--orange); }
.msg-info { background: rgba(0,180,216,0.1); border: 1px solid var(--accent); color: var(--accent); }

/* Provider grid */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.8rem; margin-bottom: 1.5rem; }
.provider-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem; text-align: center; }
.provider-card .name { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.provider-card .status { font-size: 1.1rem; font-weight: 700; margin-top: 0.3rem; }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* ==========================================================================
   Engine Console — terminal-like layout (Phase 2)
   ========================================================================== */

/* When .main-console is on the .main container, fill viewport height */
.main-console {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  height: 100vh;
}

/* Console header bar */
.console-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 40px;
}
.console-header .console-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}
.console-header select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
}
.console-header .spacer { flex: 1; }

/* Compact header on small screens */
@media (max-width: 767.98px) {
  .console-header .advanced-controls { display: none; }
  #ws-status.badge { font-size: 0; padding: 0; width: 10px; height: 10px; border-radius: 50%; }
  #ws-status.badge-ok { background: var(--green); }
  #ws-status.badge-error, #ws-status.badge-unreachable { background: var(--red); }
  #ws-status.badge-limited, #ws-status.badge-medium, #ws-status.badge-high, #ws-status.badge-critical { background: var(--orange); }
  /* Reduce header height and ensure brand + status remain visible */
  .console-header { position: sticky; top: 0; z-index: 50; }
  /* Reserve space for the fixed hamburger and center title */
  .header-title { margin: 0 56px; text-align: center; }
  /* Ensure primary navbar hamburger at top-right doesn't overlap the console one */
  #hamburger { right: calc(env(safe-area-inset-right, 0px) + 0.5rem); }
}

/* Stream output area */
.console-stream {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 1rem;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  scroll-behavior: smooth;
}
@media (max-width: 767.98px) {
  .console-stream pre, .console-stream code, .stream-response .md-code {
    white-space: pre-wrap; /* allow wrapping on mobile */
    word-wrap: break-word;
    overflow-x: auto;
    max-height: 16rem; /* clamp tall blocks */
    font-size: 0.9em; /* slightly smaller for readability */
  }
}

/* Sticky composer bar with safe-area padding */
.composer-bar {
  position: sticky;
  bottom: 0;
  padding: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  z-index: 45;
}
.composer-bar textarea {
  flex: 1;
  max-height: 8rem;
  resize: none;
}
.composer-bar .upload-btn {
  width: 44px;
  height: 44px;
}
.composer-bar .send-btn {
  min-width: 90px;
  height: 44px;
}

/* Individual stream entries */
.stream-entry {
  margin-bottom: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(44, 62, 80, 0.4);
}
.stream-entry:last-child { border-bottom: none; }

.stream-entry .stream-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.stream-entry .stream-meta .stream-time {
  color: var(--gray);
}

/* Prompt echo in stream */
.stream-prompt {
  color: var(--accent);
  white-space: pre-wrap;
  word-break: break-word;
}
.stream-prompt::before {
  content: "> ";
  color: var(--green);
  font-weight: 700;
}

/* Response text in stream */
.stream-response {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  padding: 0.3rem 0 0.3rem 0.8rem;
  border-left: 2px solid var(--border);
}

/* Response wrapper with copy button */
.stream-response-wrap {
  position: relative;
  padding-right: 7rem;  /* reserve space for Copy + Copy All buttons */
}
.copy-btn {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
  z-index: 2;
  font-family: inherit;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);

  min-height: 32px;
  min-width: 44px;}
.stream-response-wrap:hover .copy-btn,
.copy-btn:focus {
  opacity: 1;
}
.copy-btn:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--accent);
}
.copy-btn-all {
  right: 3.5rem;
}
.copy-btn-prompt {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.5rem;
  opacity: 0.5;
  font-size: 0.6rem;
  padding: 0.1rem 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.copy-btn-prompt:hover {
  opacity: 1;
  background: var(--hover);
  color: var(--text);
  border-color: var(--accent);
}
/* Turn break separator between multi-turn responses */
.stream-response-break {
  border-top: 1px dashed var(--border);
  margin: 0.4rem 0;
  padding-top: 0.3rem;
}
.stream-response-break .break-time {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Markdown rendering in responses */
.stream-response .md-code {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  margin: 0.3rem 0;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
}
.stream-response .md-inline {
  background: rgba(0, 180, 216, 0.1);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}
.stream-response .md-heading {
  display: block;
  margin: 0.3rem 0 0.1rem;
  color: var(--accent);
}
.stream-response .md-bullet {
  display: block;
  padding-left: 0.5rem;
}

/* History trace steps in expanded view */
.history-trace {
  padding-left: 0.4rem;
  border-left: 2px solid var(--border);
}
.history-trace .trace-step {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.1rem 0 0.1rem 0.4rem;
  line-height: 1.4;
}

/* Work trace timeline — live incremental progress */
.work-timeline {
  margin: 0.3rem 0;
  padding-left: 0.4rem;
  border-left: 2px solid var(--border);
}
.work-timeline .tl-entry {
  font-size: 0.73rem;
  padding: 0.15rem 0 0.15rem 0.4rem;
  line-height: 1.5;
  transition: opacity 0.2s, color 0.2s;
}
.work-timeline .tl-entry.tl-active {
  color: var(--accent);
}
.work-timeline .tl-entry.tl-done {
  color: var(--text-muted);
  opacity: 0.6;
}
.work-timeline .tl-entry.tl-blocked {
  color: var(--orange);
}
.interrupted-card {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: rgba(210, 153, 34, 0.08);
  border: 1px solid var(--orange, #d29922);
  border-left: 3px solid var(--orange, #d29922);
  border-radius: 4px;
}
.interrupted-header {
  font-weight: 600;
  color: var(--orange, #d29922);
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}
.interrupted-prompt {
  font-size: 0.82rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 0.6rem;
  max-height: 120px;
  overflow-y: auto;
}
.interrupted-actions button {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.interrupted-actions .interrupted-resume {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.interrupted-actions .interrupted-resume:hover {
  background: var(--accent); color: var(--bg);
}
.interrupted-actions .interrupted-dismiss:hover {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.stream-image-wrap {
  margin: 0.5rem 0 0.75rem;
  display: inline-block;
  max-width: 100%;
}
.stream-image {
  display: block;
  max-width: 500px;
  max-height: 500px;
  width: auto;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  cursor: zoom-in;
}
.stream-image-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  max-width: 500px;
  word-break: break-all;
}
@media (max-width: 767.98px) {
  .stream-image { max-width: 100%; }
  .stream-image-caption { max-width: 100%; }
}

.email-notice {
  margin: 0.4rem 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  background: rgba(62, 139, 216, 0.08);
  border-left: 2px solid var(--accent);
  border-radius: 0 3px 3px 0;
  color: var(--text);
}
.email-notice .email-pk { color: var(--text-muted); font-size: 0.72rem; }

.hint-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.hint-input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}
.hint-input:focus {
  outline: none;
  border-color: var(--accent);
}
.hint-send-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.hint-send-btn:hover { opacity: 0.9; }
.hint-msg {
  margin: 0.3rem 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(0, 180, 216, 0.08);
  border-left: 2px solid var(--accent);
  border-radius: 0 3px 3px 0;
}

.feedback-wrap {
  margin: 0.5rem 0 1rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
}
.feedback-label { margin-right: 0.5rem; }
.feedback-btn {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.2rem 0.5rem; cursor: pointer; font-size: 1rem;
  margin: 0 0.15rem;
}
.feedback-btn:hover, .feedback-btn.selected {
  background: var(--accent); color: var(--bg);
}
.feedback-form { margin-top: 0.5rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.feedback-form textarea {
  flex: 1 1 100%; min-height: 2.5rem; max-width: 500px;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.3rem 0.5rem; font-size: 0.8rem;
}
.feedback-submit, .feedback-cancel {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.25rem 0.6rem; cursor: pointer; font-size: 0.75rem;
}
.feedback-submit:hover { border-color: var(--accent); color: var(--accent); }
.feedback-done { color: var(--green); }
.feedback-err { color: var(--red); }

.work-timeline .tl-entry.tl-replay {
  opacity: 0.5;
  font-style: italic;
  border-left: 2px solid var(--border);
  padding-left: 0.5rem;
}
.work-timeline .tl-icon {
  margin-right: 0.3rem;
  display: inline-block;
  width: 1em;
  text-align: center;
}
.work-timeline .tl-phase {
  font-weight: 600;
  text-transform: capitalize;
}
.work-timeline .tl-detail {
  color: var(--text-muted);
  font-style: italic;
}
.work-timeline .tl-elapsed {
  color: var(--gray);
  font-size: 0.72rem;
  margin-left: 0.3rem;
}
.work-timeline .blocked-cat {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.6rem;
  color: var(--orange);
}
.work-timeline .blocked-action {
  color: var(--text-muted);
  font-size: 0.68rem;
}
/* Collapsed state — hide entries, show expand toggle */
.work-timeline.tl-collapsed .tl-entry {
  display: none;
}
.work-timeline .tl-expand {
  font-size: 0.68rem;
  color: var(--gray);
  cursor: pointer;
  padding: 0.1rem 0.4rem;
}
.work-timeline .tl-expand:hover {
  color: var(--accent);
  text-decoration: underline;
}
/* When expanded after collapse, show entries again */
.work-timeline:not(.tl-collapsed) .tl-entry {
  display: block;
}

/* Cancel button */
.cancel-btn {
  padding: 0.5rem 1rem;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  transition: all 0.15s;
}
.cancel-btn:hover {
  background: rgba(231, 76, 60, 0.2);
}

/* Status messages */
.stream-status {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
}
.stream-status.status-ok { color: var(--green); font-style: normal; }
.stream-status.status-error { color: var(--red); font-style: normal; }
.stream-status.status-running { color: var(--orange); }

/* Expandable history entries */
.stream-expandable {
  cursor: pointer;
}
.stream-expandable:hover {
  background: rgba(255, 255, 255, 0.02);
}
.stream-expandable .expand-hint {
  color: var(--gray);
  font-size: 0.6rem;
  font-style: italic;
  opacity: 0;
  transition: opacity 0.15s;
}
.stream-expandable:hover .expand-hint {
  opacity: 1;
}
.stream-expandable .stream-detail {
  display: none;
}
.stream-expandable.expanded .stream-detail {
  display: block;
  margin-top: 0.4rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.stream-expandable.expanded .stream-preview {
  display: none;
}
.stream-expandable.expanded .expand-hint {
  opacity: 1;
}
.stream-expandable.expanded .expand-hint::after {
  content: " (click to collapse)";
}
.stream-expandable:not(.expanded) .expand-hint::after {
  content: "";
}
.stream-detail-section {
  margin-bottom: 0.4rem;
}
.stream-detail-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 0.15rem;
}

/* Attachment display */
.stream-attachment .attachment-preview {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.3rem;
}
.attachment-thumb {
  max-width: 180px;
  max-height: 120px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s;
}
.attachment-thumb:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}
.attachment-name {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Upload button */
.upload-btn {
  padding: 0.5rem 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
}
.upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* System/info messages */
.stream-system {
  color: var(--gray);
  font-size: 0.75rem;
}

/* Prompt input area */
.console-input {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-top: 2px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
@media (max-width: 767.98px) {
  .console-input {
    position: sticky;
    bottom: 0;
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
    z-index: 45;
  }
}
.console-input textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  min-height: 48px;
  max-height: 200px;
  outline: none;
  transition: border-color 0.15s;
}
.console-input textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 180, 216, 0.2);
}
.console-input textarea::placeholder {
  color: var(--gray);
}
.console-input .send-btn{
  padding: 0.6rem 1.4rem;
  background: rgba(0, 180, 216, 0.1);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  min-height: 48px;
  letter-spacing: 0.3px;

  min-width: 80px;}
.console-input .send-btn:hover:not(:disabled) {
  background: rgba(0, 180, 216, 0.2);
  color: #fff;
}
.console-input .send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: transparent;
}

/* Tasks drawer toggle */
.drawer-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: all 0.15s;
}
.drawer-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Tasks drawer (slides up from bottom or right side) */
.tasks-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.tasks-drawer.open {
  max-height: 200px;
  overflow-y: auto;
}
.tasks-drawer table {
  font-size: 0.78rem;
}
.tasks-drawer th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.tasks-drawer .drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}
.tasks-drawer .drawer-header h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

/* ==========================================================================
   Inline Approval Cards
   ========================================================================== */

.approval-card {
  background: var(--bg);
  border: 1px solid var(--orange);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  margin: 0.5rem 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
.approval-card.risk-critical {
  border-color: var(--red);
}
.approval-card.risk-high {
  border-color: var(--orange);
}
.approval-card.risk-medium {
  border-color: var(--yellow);
}
.approval-card.approval-danger {
  border-color: var(--red);
  border-width: 2px;
  background: rgba(231, 76, 60, 0.08);
  box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.15);
}
.approval-card.approval-danger .approval-title {
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.approval-card .approval-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.approval-card .approval-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
.approval-card .approval-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.approval-card .approval-body {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}
.approval-card .approval-action {
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg-card);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  margin: 0.3rem 0;
  font-family: 'SF Mono', 'Consolas', monospace;
  word-break: break-word;
}

.approval-card .approval-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.approval-card .approval-btn {
  padding: 0.35rem 1rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.approval-btn-approve {
  background: rgba(46, 204, 113, 0.15);
  color: var(--green);
  border-color: var(--green);
}
.approval-btn-approve:hover {
  background: rgba(46, 204, 113, 0.3);
}
.approval-btn-deny {
  background: rgba(231, 76, 60, 0.1);
  color: var(--red);
  border-color: var(--red);
}
.approval-btn-deny:hover {
  background: rgba(231, 76, 60, 0.25);
}
.approval-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Resolved state */
.approval-card.resolved {
  opacity: 0.7;
  border-style: dashed;
}
.approval-card.resolved .approval-controls {
  display: none;
}
.approval-card .approval-decision {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.4rem;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  display: inline-block;
}
.approval-decision.decision-approve {
  background: rgba(46, 204, 113, 0.15);
  color: var(--green);
}
.approval-decision.decision-deny {
  background: rgba(231, 76, 60, 0.15);
  color: var(--red);
}


/* Accessibility helpers */
.skip-nav {
  position: absolute;
  left: 0;
  top: -40px;
  background: var(--accent);
  color: #001219;
  padding: 0.5rem 1rem;
  z-index: 1000;
  text-decoration: none;
  border-radius: 0 0 4px 0;
}
.skip-nav:focus-visible { top: 0; }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}


/* Responsive breakpoints */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .detail-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .console-input { flex-direction: column; align-items: stretch; }
  .console-input .send-btn { width: 100%; }
}
@media (max-width: 480px) {
  .main { padding: 1rem; }
  .sidebar { width: 100%; }
  .sidebar nav a { padding: 0.5rem 0.8rem; }
  .console-header { padding: 0.5rem; gap: 0.5rem; }
  .console-stream { padding: 0.6rem; }
  .stream-response-wrap { padding-right: 6rem; }
}
