/**
 * frago GUI Global Styles
 *
 * Based on GitHub Dark design style, supports dark/light theme switching
 */

@tailwind base;
@tailwind components;
@tailwind utilities;

/* === CSS Variables - Dark Theme (Default) === */
/* Based on Next.js-inspired design language from FRONTEND_STYLE_GUIDE.md */
:root {
  /* Background color scale - Enhanced differentiation */
  --bg-primary: #000000;
  --bg-secondary: #0D0D0D;
  --bg-tertiary: #171717;
  --bg-card: #0D0D0D;
  --bg-base: #0D0D0D;
  --bg-subtle: #1F1F1F;
  --bg-hover: #1F1F1F;
  --bg-elevated: #262626;

  /* Text color scale */
  --text-primary: #FFFFFF;
  --text-secondary: #ADADAD;
  --text-muted: #888888;
  --text-link: #EDEDED;
  --text-on-accent: #0A0A0A;

  /* Accent colors - High contrast monochrome */
  --accent-primary: #EDEDED;
  --accent-secondary: #FFFFFF;
  --accent-muted: #888888;
  --accent-success: #3fb950;
  --accent-warning: #d29922;
  --accent-error: #f85149;

  /* Border colors - Enhanced visibility */
  --border-color: #262626;
  --border-muted: #171717;
  --border-primary: #EDEDED;
  --shadow-color: rgba(0, 0, 0, 0.6);

  /* Status badge backgrounds */
  --status-running-bg: rgba(210, 153, 34, 0.15);
  --status-completed-bg: rgba(63, 185, 80, 0.15);
  --status-error-bg: rgba(248, 81, 73, 0.15);

  /* Spacing system (8px grid, fixed values) */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Font scale - set by JS based on screen resolution (1080p = 1.0) */
  --font-scale: 1;

  /* Fonts - responsive sizing (1080p baseline, scaled by --font-scale) */
  --font-size-xs: calc(11px * var(--font-scale));
  --font-size-sm: calc(12px * var(--font-scale));
  --font-size-base: calc(13px * var(--font-scale));
  --font-size-md: calc(14px * var(--font-scale));
  --font-size-lg: calc(16px * var(--font-scale));
  --font-size-xl: calc(18px * var(--font-scale));
  --font-size-2xl: calc(24px * var(--font-scale));
  --font-family: 'Geist Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;

  /* Platform-adaptive font weights (overridden by Python injection) */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 600;

  /* Transition animations */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Layout dimensions (fixed values) */
  --bottom-nav-height: 48px;
  --status-height: 28px;

  /* Sidebar layout dimensions */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 56px;
}

/* === Light Theme === */
/* Black & white minimal style with black accent */
[data-theme='light'] {
  --bg-primary: #FFFFFF;
  --bg-secondary: #FAFAFA;
  --bg-tertiary: #F5F5F5;
  --bg-card: #FFFFFF;
  --bg-base: #FFFFFF;
  --bg-subtle: #E5E5E5;
  --bg-hover: #F0F0F0;
  --bg-elevated: #E8E8E8;

  --text-primary: #0A0A0A;
  --text-secondary: #666666;
  --text-muted: #888888;
  --text-link: #0A0A0A;
  --text-on-accent: #FFFFFF;

  --accent-primary: #0A0A0A;
  --accent-secondary: #000000;
  --accent-muted: #888888;
  --accent-success: #1a7f37;
  --accent-warning: #9a6700;
  --accent-error: #cf222e;

  --border-color: #E5E5E5;
  --border-muted: #EBEBEB;
  --border-primary: #0A0A0A;
  --shadow-color: rgba(0, 0, 0, 0.1);

  /* Status badge backgrounds */
  --status-running-bg: rgba(154, 103, 0, 0.12);
  --status-completed-bg: rgba(26, 127, 55, 0.12);
  --status-error-bg: rgba(207, 34, 46, 0.12);
}

/* Light theme task input overrides */
[data-theme='light'] .task-input-wrapper {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08), 0 -1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme='light'] .task-input-wrapper:focus-within {
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12), 0 -1px 3px rgba(0, 0, 0, 0.08);
}

/* === Base Reset === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Platform-specific font rendering optimization */
[data-platform='windows'],
[data-platform='linux'] {
  -webkit-font-smoothing: subpixel-antialiased;
}

#root {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 2px;
  height: 2px;
}

::-webkit-scrollbar:hover {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 1px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* === Utility Classes === */
.font-mono {
  font-family: var(--font-mono);
}

/* === Link Styles === */
a:not(.btn):not(.nav-tab) {
  color: var(--text-link);
  text-decoration: none;
  text-underline-offset: 4px;
  transition: text-decoration var(--transition-normal);
}

a:not(.btn):not(.nav-tab):hover {
  text-decoration: underline;
}

/* === Icon Sizes === */
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }

/* === Status Colors === */
.status-running {
  color: var(--accent-warning);
}

.status-completed {
  color: var(--accent-success);
}

.status-error,
.status-cancelled {
  color: var(--accent-error);
}

/* === Layout Components === */
.bottom-nav {
  height: var(--bottom-nav-height);
  padding-top: 6px;
  background: var(--bg-secondary);
  display: flex;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.bottom-nav-item:hover {
  color: var(--text-secondary);
}

.bottom-nav-item.active {
  color: var(--accent-primary);
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
}

/* === Version Banner === */
.main-layout-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.version-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--accent-primary-10);
  border-bottom: 1px solid var(--accent-primary-20);
  font-size: 13px;
  flex-shrink: 0;
}

.version-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.version-banner-text {
  color: var(--text-primary);
}

.version-banner-command {
  padding: 2px 8px;
  background: var(--accent-primary-20);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.version-banner-dismiss {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.version-banner-dismiss:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.version-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-banner-update-btn {
  padding: 4px 12px;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}

.version-banner-update-btn:hover {
  opacity: 0.9;
}

/* === Update Modal === */
.update-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.update-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  min-width: 400px;
  max-width: 500px;
  box-shadow: 0 8px 32px var(--shadow-color);
}

.update-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 20px 0;
}

.update-modal-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.update-modal-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.update-modal-progress-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.update-modal-progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}

.update-modal-message {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 8px 0;
}

.update-modal-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

.update-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.update-modal-close-btn {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.update-modal-close-btn:hover {
  background: var(--bg-hover);
}

/* === Main Layout === */
.main-layout {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.sidebar.collapsed .sidebar-header {
  padding: 16px 12px;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--accent-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-accent);
  font-weight: 700;
  font-size: var(--font-size-md);
  flex-shrink: 0;
}

.sidebar-title {
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  justify-content: flex-start;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.sidebar.collapsed .sidebar-menu-item {
  padding: 12px;
  justify-content: center;
}

.sidebar-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-menu-item.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

.sidebar-menu-icon {
  flex-shrink: 0;
}

.sidebar-menu-label {
  font-size: var(--font-size-md);
  font-weight: 400;
  white-space: nowrap;
}

.sidebar-menu-item.active .sidebar-menu-label {
  font-weight: 500;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.sidebar.collapsed .sidebar-footer {
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-footer-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Star button specific styles */
.sidebar-footer-btn.star-btn {
  transition: all 0.2s ease;
}

.sidebar-footer-btn.star-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sidebar-footer-btn.star-btn.disabled:hover {
  background: transparent;
  color: var(--text-muted);
}

.collapse-icon {
  transition: transform 0.2s ease;
}

.collapse-icon.collapsed {
  transform: rotate(180deg);
}

/* === Dashboard === */
.dashboard-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.dashboard-header p {
  font-size: var(--font-size-md);
  color: var(--text-secondary);
}

.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.dashboard-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.dashboard-card.clickable {
  cursor: pointer;
}

.dashboard-card-icon-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dashboard-card-icon.success {
  background: rgba(63, 185, 80, 0.15);
}

.dashboard-card-icon.error {
  background: rgba(248, 81, 73, 0.15);
}

.dashboard-card-icon.info {
  background: rgba(88, 166, 255, 0.15);
}

.dashboard-card-icon.warning {
  background: rgba(210, 153, 34, 0.15);
}

.dashboard-card-icon.purple {
  background: rgba(139, 92, 246, 0.15);
}

.dashboard-card-icon-label {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.dashboard-card-value {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dashboard-card-label {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
}

.dashboard-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dashboard-section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-section-title-only {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.dashboard-view-all-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-base);
}

.dashboard-activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dashboard-activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.dashboard-activity-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

.dashboard-activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dashboard-activity-dot.completed {
  background: var(--accent-success);
}

.dashboard-activity-dot.running {
  background: var(--accent-warning);
}

.dashboard-activity-dot.error {
  background: var(--accent-error);
}

.dashboard-activity-dot.default {
  background: var(--text-muted);
}

.dashboard-activity-content {
  flex: 1;
  min-width: 0;
}

.dashboard-activity-title {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-activity-time {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.dashboard-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

/* Full-width Dashboard Card */
.dashboard-card-full {
  grid-column: 1 / -1;
}

/* Activity Overview Line Chart */
.activity-chart-container {
  width: 100%;
  margin-bottom: 24px;
}

.activity-line-chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid-line {
  stroke: var(--border-color);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-axis-line {
  stroke: var(--text-muted);
  stroke-width: 1;
}

.chart-line {
  stroke: var(--accent-primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: var(--accent-primary);
  opacity: 0.15;
}

.chart-point {
  fill: var(--accent-primary);
  stroke: var(--bg-primary);
  stroke-width: 2;
  transition: r 0.2s ease;
}

.chart-point:hover {
  r: 6;
}

.chart-axis-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
}

.chart-axis-title {
  fill: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
}

/* Activity Stats Grid */
.activity-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 16px;
}

.activity-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--bg-tertiary);
  border-radius: 12px;
}

.activity-stat-value {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
}

.activity-stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.dashboard-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-primary);
  text-align: left;
}

.dashboard-action-label {
  font-size: var(--font-size-md);
}

.dashboard-loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Icon color utilities */
.text-success {
  color: var(--accent-success);
}

.text-error {
  color: var(--accent-error);
}

.text-warning {
  color: var(--accent-warning);
}

.text-info {
  color: #58a6ff;
}

.text-purple {
  color: #8b5cf6;
}

.text-muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent-primary);
}

/* Page scroll container - scrollbar at edge, content has padding */
.page-scroll {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  padding: var(--spacing-md);
}

.status-bar {
  height: var(--status-height);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-md);
  border-top: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* === Card Styles === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  transition: border-color var(--transition-fast),
              background var(--transition-fast),
              box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* === Button Base === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 8px 16px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-normal);
  -webkit-app-region: no-drag;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

.btn-primary:hover {
  background: var(--accent-secondary);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-warning {
  background: var(--accent-warning);
  color: white;
}

.btn-warning:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--accent-error);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.1);
}


/* === Empty State === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: var(--spacing-2xl);
}

.empty-state-icon {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.empty-state-description {
  font-size: var(--font-size-base);
  max-width: 300px;
}

/* === Toast === */
.toast-container {
  position: fixed;
  bottom: calc(var(--status-height) + var(--bottom-nav-height) + var(--spacing-md));
  right: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  box-shadow: 0 4px 12px var(--shadow-color);
  animation: slideIn 0.2s ease;
}

.toast-success {
  border-left: 3px solid var(--accent-success);
}

.toast-error {
  border-left: 3px solid var(--accent-error);
}

.toast-warning {
  border-left: 3px solid var(--accent-warning);
}

.toast-info {
  border-left: 3px solid var(--accent-primary);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* === Loading Spinner === */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === Task Card V2 === */
.task-card-v2 {
  display: flex;
  align-items: stretch;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.task-card-v2:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.task-card-v2:hover .task-arrow {
  color: var(--accent-primary);
}

/* Status badge */
.task-status-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--font-size-base);
}

.task-status-badge.running {
  background: var(--status-running-bg);
  color: var(--accent-warning);
  animation: badge-pulse 2s infinite;
}

.task-status-badge.completed {
  background: var(--status-completed-bg);
  color: var(--accent-success);
}

.task-status-badge.error {
  background: var(--status-error-bg);
  color: var(--accent-error);
}

.task-status-badge.cancelled {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Main content area */
.task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-sm);
}

.task-title {
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-time {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Progress bar */
.task-progress {
  padding: var(--spacing-xs) 0;
}

.task-progress-bar {
  height: 3px;
  background: var(--bg-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.task-progress-fill {
  height: 100%;
  width: 30%;
  background: var(--accent-warning);
  border-radius: 2px;
  animation: progress-slide 1.5s ease-in-out infinite;
}

@keyframes progress-slide {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 50%; }
  100% { transform: translateX(400%); width: 30%; }
}

/* Bottom metadata */
.task-footer {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-xs);
}

.task-status-label {
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-xs);
}

.task-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.task-stat-icon {
  font-size: var(--font-size-xs);
}

/* Right arrow */
.task-arrow {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: var(--font-size-md);
  font-weight: 300;
  transition: color var(--transition-fast);
}

/* === Step List === */
.step-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* New step card */
.step-item-new {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-primary);
}

.step-item-new:hover {
  background: var(--bg-secondary);
}

/* Legacy step style (preserved for compatibility) */
.step-item {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.step-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 4px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-mono);
}

.step-icon.user {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

.step-icon.assistant {
  background: var(--accent-success);
  color: var(--text-on-accent);
}

.step-icon.tool {
  background: var(--accent-warning);
  color: var(--text-on-accent);
}

.step-content {
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
  word-break: break-word;
  line-height: 1.5;
}

.step-tool-name {
  margin-right: var(--spacing-sm);
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  font-size: var(--font-size-sm);
}

.step-content code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 3px;
}

/* === Search Box === */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: var(--spacing-md);
  margin-bottom: 0;
  transition: border-color var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--accent-primary);
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  flex: 1;
  padding: 10px 12px 10px 36px;
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.search-clear:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

/* === Task Input === */
.task-input-area {
  flex-shrink: 0;
  background: transparent;
  margin-top: auto;
  padding: var(--spacing-md);
}

.task-input-wrapper {
  position: relative;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3), 0 -1px 3px rgba(0, 0, 0, 0.2);
}

.task-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4), 0 -1px 3px rgba(0, 0, 0, 0.2);
}

.task-input {
  width: 100%;
  min-height: 120px;
  max-height: 200px;
  padding: var(--spacing-md);
  padding-right: 48px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: 1.5;
}

.task-input::placeholder {
  color: var(--text-muted);
}

.task-input-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
}

.task-input-btn.visible {
  opacity: 1;
  transform: scale(1);
}

.task-input-btn:hover {
  background: var(--accent-secondary);
}

.task-input-btn:disabled {
  cursor: not-allowed;
}

.task-input-btn:disabled.visible {
  opacity: 0.5;
}

.task-input-btn .spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

/* === Directory Autocomplete === */
.directory-autocomplete {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

.directory-autocomplete-item {
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.directory-autocomplete-item:hover,
.directory-autocomplete-item.selected {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.directory-autocomplete-item .truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.directory-autocomplete-empty {
  padding: var(--spacing-md);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* === Text Utilities === */
.text-scaled-xs { font-size: var(--font-size-xs) !important; }
.text-scaled-sm { font-size: var(--font-size-sm) !important; }
.text-scaled-base { font-size: var(--font-size-base) !important; }
.text-scaled-lg { font-size: var(--font-size-lg) !important; }
.text-scaled-xl { font-size: var(--font-size-xl) !important; }

/* Spacing utilities (fixed) */
.gap-scaled-1 { gap: 4px !important; }
.gap-scaled-2 { gap: 8px !important; }
.gap-scaled-3 { gap: 12px !important; }
.gap-scaled-4 { gap: 16px !important; }

.p-scaled-2 { padding: 8px !important; }
.p-scaled-3 { padding: 12px !important; }
.p-scaled-4 { padding: 16px !important; }

.py-scaled-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-scaled-4 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-scaled-8 { padding-top: 32px !important; padding-bottom: 32px !important; }

.px-scaled-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-scaled-3 { padding-left: 12px !important; padding-right: 12px !important; }

.mb-scaled-1 { margin-bottom: 4px !important; }
.mb-scaled-2 { margin-bottom: 8px !important; }
.mb-scaled-3 { margin-bottom: 12px !important; }
.mb-scaled-4 { margin-bottom: 16px !important; }

.mt-scaled-1 { margin-top: 4px !important; }
.mt-scaled-2 { margin-top: 8px !important; }
.mt-scaled-4 { margin-top: 16px !important; }

.ml-scaled-1 { margin-left: 4px !important; }
.ml-scaled-2 { margin-left: 8px !important; }
.ml-scaled-4 { margin-left: 16px !important; }

.pl-scaled-5 { padding-left: 20px !important; }

/* Icon sizes (fixed) */
.icon-scaled-sm { width: 14px; height: 14px; }
.icon-scaled-md { width: 16px; height: 16px; }

/* === Markdown Content Styles === */
.markdown-content {
  line-height: 1.6;
  word-wrap: break-word;
}

.markdown-content p {
  margin-bottom: 0.5em;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-weight: var(--font-weight-bold);
  margin-top: 1em;
  margin-bottom: 0.5em;
  color: var(--text-primary);
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.3em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content ul,
.markdown-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.markdown-content li {
  margin: 0.25em 0;
}

.markdown-content blockquote {
  margin: 0.5em 0;
  padding-left: 1em;
  border-left: 3px solid var(--border-primary);
  color: var(--text-muted);
}

.markdown-content .inline-code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--bg-subtle);
  border-radius: 3px;
  color: var(--text-primary);
}

.markdown-content .code-block {
  margin: 0.5em 0;
  padding: 0.75em 1em;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.markdown-content .code-block code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text-primary);
  white-space: pre;
}

.markdown-content a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-content a:hover {
  color: var(--accent-secondary);
}

.markdown-content hr {
  margin: 1em 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

.markdown-content table {
  width: 100%;
  margin: 0.5em 0;
  border-collapse: collapse;
}

.markdown-content th,
.markdown-content td {
  padding: 0.5em;
  border: 1px solid var(--border-color);
  text-align: left;
}

.markdown-content th {
  background: var(--bg-subtle);
  font-weight: var(--font-weight-medium);
}

.markdown-content strong {
  font-weight: var(--font-weight-bold);
}

.markdown-content em {
  font-style: italic;
}

/* === Step Content Formatting === */

/* Preformatted content - preserves whitespace and line breaks */
.step-content-pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
}

/* Collapsible content wrapper */
.collapsible-content {
  position: relative;
}

/* Collapsed state - limit height with fade */
.collapsible-collapsed {
  max-height: 6em;
  overflow: hidden;
  position: relative;
}

.collapsible-collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2em;
  background: linear-gradient(transparent, var(--bg-tertiary));
  pointer-events: none;
}

/* Collapsed state inside hover - adjust gradient */
.step-item-new:hover .collapsible-collapsed::after {
  background: linear-gradient(transparent, var(--bg-secondary));
}

/* Toggle button */
.collapsible-toggle {
  display: inline-flex;
  align-items: center;
  margin-top: var(--spacing-xs);
  padding: 2px 0;
  font-size: var(--font-size-xs);
  color: var(--accent-primary);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.collapsible-toggle:hover {
  color: var(--accent-secondary);
}

/* Icon size in collapsible toggle */
.icon-scaled-xs {
  width: 12px;
  height: 12px;
}

/* === Bash Content === */
.bash-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.bash-content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.bash-content-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.bash-content-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
  transition: all var(--transition-fast);
}

.bash-content-copy:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.bash-content-code {
  margin: 0;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

.bash-prompt {
  color: var(--accent-success);
  user-select: none;
  margin-right: 6px;
}

/* === File Content === */
.file-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-content-path {
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-content-icon {
  color: var(--accent-warning);
  flex-shrink: 0;
}

.file-path-text {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--accent-primary);
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 3px;
  word-break: break-all;
}

.file-content-detail {
  margin: 0;
  padding-left: 20px;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* === JSON Content === */
.json-content {
  display: flex;
  flex-direction: column;
}

.json-content-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  text-align: left;
  transition: color var(--transition-fast);
}

.json-content-toggle:hover {
  color: var(--text-primary);
}

.json-preview {
  color: var(--accent-primary);
}

.json-content-code {
  margin: 4px 0 0 0;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  overflow-x: auto;
}

/* === Paired Tool Step === */
.paired-tool-step {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.paired-step-call {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.paired-step-result {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
}

.paired-step-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.paired-step-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
}

.paired-step-tool-name {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  color: var(--text-primary);
}

.paired-step-content {
  padding-left: 20px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}
