/* ==========================================================================
   TimeMatrix — Stylesheet
   Modern, responsive, accessible, dark/light theme support
   ========================================================================== */

:root {
  /* Color Palette - Dark Theme Default */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.5);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);

  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;

  --pin-active-bg: rgba(245, 158, 11, 0.15);
  --pin-active-border: #f59e0b;
  --pin-active-text: #fbbf24;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.8);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-focus: #4f46e5;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
}

/* App Layout */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary) 0%, #a855f7 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.select-input {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select-input:focus {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Global Config Bar */
.global-config-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.config-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.config-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.time-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.number-stepper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  gap: 4px;
}

.time-num-input {
  width: 48px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.time-num-input::-webkit-inner-spin-button,
.time-num-input::-webkit-outer-spin-button {
  opacity: 1;
}

.unit {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.time-picker-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 10px;
  outline: none;
}

.quick-presets {
  display: flex;
  gap: 6px;
}

.btn-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-chip.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Metric Summary Pills */
.metrics-summary {
  display: flex;
  gap: 12px;
}

.metric-pill {
  display: flex;
  flex-direction: column;
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-width: 120px;
}

.metric-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Main Layout Grid */
.main-layout {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Tasks Panel (Left) */
.tasks-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.badge {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

/* Info Banner */
.tradeoff-info-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.tradeoff-info-banner svg {
  flex-shrink: 0;
  color: var(--accent-primary);
  margin-top: 1px;
}

/* Tasks List */
.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Task Item Card */
.task-item-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.task-item-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-md);
}

.task-item-card.is-pinned {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(245, 158, 11, 0.04) 100%);
}

.task-item-card.is-highlighted {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow), var(--shadow-md);
}

/* Left color strip */
.task-item-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 5px;
  background-color: var(--item-color, var(--accent-primary));
  transition: background-color var(--transition-fast);
}

.task-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-info-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* Color Picker Button & Input */
.color-picker-wrapper {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  border: 2px solid #ffffff;
  transition: transform var(--transition-fast);
}

.color-picker-wrapper:hover {
  transform: scale(1.15);
}

.native-color-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.task-title-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  outline: none;
  flex: 1;
  min-width: 100px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.task-title-input:hover {
  border-color: var(--border-color);
  background: var(--bg-secondary);
}

.task-title-input:focus {
  border-color: var(--border-color-focus);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Task Metrics Display (Time + Percent) */
.task-metrics-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.task-time-display {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.task-pct-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Action buttons in item */
.task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Pin Button */
.btn-pin {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-pin:hover {
  border-color: var(--pin-active-border);
  color: var(--pin-active-text);
}

.btn-pin.pinned {
  background: var(--pin-active-bg);
  border-color: var(--pin-active-border);
  color: var(--pin-active-text);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.btn-pin.pinned svg {
  fill: currentColor;
}

/* Delete Button */
.btn-delete {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-delete:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-danger);
}

.btn-delete:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Slider Controls Area */
.task-slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

/* Custom Range Slider */
.task-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.task-range-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Slider Thumb (WebKit) */
.task-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--item-color, var(--accent-primary));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.task-range-slider:not(:disabled)::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.task-range-slider:not(:disabled)::-webkit-slider-thumb:active {
  transform: scale(1.1);
}

/* Slider Thumb (Firefox) */
.task-range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--item-color, var(--accent-primary));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

/* Number Input for direct percent typing */
.pct-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  width: 76px;
  gap: 2px;
}

.pct-input-wrapper:focus-within {
  border-color: var(--border-color-focus);
}

.task-pct-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
}

.pct-symbol {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.task-status-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-status-hint.is-locked {
  color: var(--accent-warning);
}

/* Quick Add Footer */
.quick-add-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.quick-add-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.quick-add-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-add {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip-add:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Block Toolbox
   ========================================================================== */
.toolbox-card {
  margin-top: 4px;
}

.toolbox-header {
  padding: 14px 18px;
}

.toolbox-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbox-header-icon {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.toolbox-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  gap: 6px;
}

.toolbox-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 18px 18px;
  transition: all var(--transition-normal);
}

.toolbox-card.collapsed .toolbox-body {
  display: none;
}

.toolbox-card.collapsed #toolbox-toggle-icon {
  transform: rotate(180deg);
}

.toolbox-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.toolbox-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  transition: all var(--transition-fast);
}

.toolbox-search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.toolbox-search-bar:focus-within {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.toolbox-search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

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

.btn-clear-search {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: color var(--transition-fast);
}

.btn-clear-search:hover {
  color: var(--text-primary);
}

.toolbox-filters-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toolbox-filters-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toolbox-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toolbox-filter-chip {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbox-filter-chip:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.toolbox-filter-chip.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.toolbox-filter-count {
  font-size: 0.68rem;
  opacity: 0.85;
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 5px;
  border-radius: 10px;
}

.toolbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}

/* Custom scrollbar for toolbox grid */
.toolbox-grid::-webkit-scrollbar {
  width: 6px;
}

.toolbox-grid::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 10px;
}

.toolbox-grid::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 10px;
}

.toolbox-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.toolbox-block-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--block-color, var(--accent-primary));
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.toolbox-block-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.toolbox-block-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.toolbox-block-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbox-block-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--block-color, var(--accent-primary));
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--block-color, var(--accent-primary));
}

.toolbox-block-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.toolbox-block-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.toolbox-block-card:hover .toolbox-block-add-btn {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.toolbox-block-desc {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0;
  flex: 1;
}

.toolbox-block-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.toolbox-block-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.toolbox-block-label-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.toolbox-block-label-tag.matching {
  background: rgba(99, 102, 241, 0.18);
  color: var(--accent-primary);
  border-color: rgba(99, 102, 241, 0.3);
}

.toolbox-in-routine-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-success);
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.toolbox-empty-state {
  grid-column: 1 / -1;
  padding: 32px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.toolbox-empty-icon {
  color: var(--text-muted);
  opacity: 0.5;
}

.toolbox-empty-text {
  font-size: 0.85rem;
}

.btn-reset-toolbox {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-reset-toolbox:hover {
  background: var(--accent-primary);
  color: #ffffff;
}

/* Right Column: Visuals & Analytics */
.visuals-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 20px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-type-toggle {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.btn-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-tab.active {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 1px 4px var(--accent-glow);
}

/* Chart Stage & SVG */
.chart-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
}

.svg-chart-wrapper {
  position: relative;
  width: 320px;
  height: 320px;
}

#pie-chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.25));
}

/* SVG Slices */
.pie-slice {
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity var(--transition-fast);
  transform-origin: 200px 200px;
  stroke: var(--bg-secondary);
  stroke-width: 2.5px;
}

.pie-slice:hover {
  transform: scale(1.04);
  filter: brightness(1.12);
  opacity: 1;
}

.pie-slice.is-dimmed {
  opacity: 0.35;
}

/* Donut Center Info */
.chart-center-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
}

.center-subtitle {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.center-title {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}

.center-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-success);
  margin-top: 2px;
}

/* SVG Chart Tooltip */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
  z-index: 20;
}

.chart-tooltip.visible {
  opacity: 1;
}

/* Chart Legend */
.chart-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 18px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.legend-item:hover {
  background: var(--bg-card-hover);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legend-title {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.legend-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Daily Routine Timeline Bar */
.schedule-range-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.schedule-timeline-bar {
  display: flex;
  height: 44px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  margin-bottom: 8px;
}

.timeline-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  position: relative;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.timeline-segment:hover {
  filter: brightness(1.18);
  z-index: 2;
}

.timeline-segment:not(:last-child) {
  border-right: 1.5px solid rgba(0, 0, 0, 0.2);
}

/* Timeline Ticks */
.timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 2px;
}

/* Trade-off Insights Card */
.insight-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insight-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.insight-stat-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.insight-stat-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.insight-stat-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.insight-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  line-height: 1.45;
}

.insight-alert.info {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--text-secondary);
}

.insight-alert.warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--pin-active-text);
}

/* Buttons and Global Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-color-focus);
}

.hidden {
  display: none !important;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: slideInToast 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInToast {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .app-container {
    padding: 12px;
  }
  .global-config-bar {
    padding: 14px;
  }
  .svg-chart-wrapper {
    width: 270px;
    height: 270px;
  }
  .task-card-top {
    flex-wrap: wrap;
  }
  .task-metrics-group {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
}

