/* Utility */
.hidden {
  display: none !important;
}

/* Modern Design Tokens */
:root {
  --font-primary: 'Outfit', sans-serif;
  --font-secondary: 'Plus Jakarta Sans', sans-serif;

  /* HSL Tailored Colors */
  --bg-app: hsl(220, 24%, 7%);
  --bg-card: hsla(220, 20%, 12%, 0.6);
  --bg-card-hover: hsla(220, 20%, 16%, 0.8);
  --bg-modal: hsla(220, 24%, 10%, 0.95);
  
  --border-color: hsla(220, 16%, 22%, 0.5);
  --border-color-glow: hsla(220, 16%, 35%, 0.8);

  --color-primary: hsl(262, 83%, 68%); /* Purple */
  --color-primary-glow: hsla(262, 83%, 68%, 0.25);
  
  --color-secondary: hsl(190, 90%, 50%); /* Cyan */
  --color-secondary-glow: hsla(190, 90%, 50%, 0.25);
  
  --color-success: hsl(145, 80%, 50%); /* Green */
  --color-warning: hsl(35, 90%, 55%); /* Orange */
  --color-danger: hsl(355, 85%, 60%); /* Red */
  
  --color-text: hsl(0, 0%, 94%);
  --color-text-muted: hsl(220, 12%, 60%);
  --color-text-dark: hsl(220, 16%, 30%);

  /* Level Colors */
  --color-level-1: hsl(262, 83%, 68%);   /* Project - Indigo/Purple */
  --color-level-2: hsl(210, 100%, 60%);  /* Initiative - Blue */
  --color-level-3: hsl(160, 85%, 45%);   /* Epic - Emerald */
  --color-level-4: hsl(35, 90%, 55%);    /* Task - Orange/Gold */

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);

  --backdrop-blur: blur(12px);
  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & layouts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  max-height: 100dvh;
}

body {
  background-color: var(--bg-app);
  color: var(--color-text);
  font-family: var(--font-primary);
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* Header styling */
#app-header {
  background: hsla(220, 24%, 6%, 0.85);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  z-index: 10;
  flex-shrink: 0;
}

#brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--color-text) 50%, var(--color-text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text .subtext {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-family: var(--font-secondary);
}

#search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 99px;
  padding: 0.5rem 1rem;
  width: 320px;
  transition: var(--transition-fast);
  position: relative;
}

#search-bar:focus-within {
  border-color: var(--color-primary);
  background: var(--bg-card-hover);
  box-shadow: 0 0 12px var(--color-primary-glow);
}

.search-icon {
  color: var(--color-text-muted);
  margin-right: 0.5rem;
  flex-shrink: 0;
}

#global-search {
  width: 100%;
  font-size: 0.85rem;
}

#global-search::placeholder {
  color: var(--color-text-dark);
}

#search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
}

.search-candidate-box {
  position: relative;
}

.search-candidate-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 99;
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--backdrop-blur);
}

.search-candidate-dropdown.hidden {
  display: none;
}

#existing-search-bar .search-candidate-dropdown {
  z-index: 110;
}

.search-candidate-empty {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.search-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: var(--transition-fast);
}

.search-item:last-child {
  border-bottom: none;
}

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

.search-item.selected {
  background: hsla(262, 83%, 68%, 0.15);
  border-left: 3px solid var(--color-primary);
  padding-left: calc(1rem - 3px);
}

.search-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.search-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  word-break: break-word;
}

.search-item-meta {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.search-item-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

#header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.view-toggle-group {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--color-text-muted);
}

.toggle-btn svg {
  opacity: 0.7;
}

.toggle-btn.active {
  background: hsla(262, 83%, 68%, 0.15);
  color: var(--color-text);
  border: 1px solid hsla(262, 83%, 68%, 0.3);
}

.toggle-btn.active svg {
  color: var(--color-primary);
  opacity: 1;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px var(--color-primary-glow);
}

.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: hsla(355, 85%, 48%, 0.95);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid hsla(355, 85%, 60%, 0.45);
}

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

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--color-text-muted);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#btn-refresh.refreshing .refresh-icon {
  animation: spin 1s linear infinite;
}

.sync-hud {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text-muted);
  max-width: 11rem;
  line-height: 1.2;
  white-space: nowrap;
}

/* Viewports styling */
#app-viewport {
  flex-grow: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.view-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  overflow: auto;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
}

/* --- Hierarchy View (Tree) --- */
#view-hierarchy {
  padding: 2rem;
  background: radial-gradient(circle at 10% 20%, hsla(262, 83%, 68%, 0.03) 0%, transparent 50%);
}

#hierarchy-toolbar {
  max-width: 800px;
  margin: 0 auto 1rem auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

#hierarchy-toolbar .hud-btn {
  display: inline-flex;
  gap: 0.25rem;
}

#hierarchy-toolbar .btn-primary {
  margin-left: auto;
}

.tree-container {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.orphan-section {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
}

.orphan-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-level-4);
}

.orphan-section-count {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  background: hsla(35, 90%, 55%, 0.15);
  border: 1px solid hsla(35, 90%, 55%, 0.25);
}

.tree-node-wrapper.orphan-node > .tree-node-row {
  border-style: dashed;
  opacity: 0.92;
}

.graph-card.orphan-card {
  border-style: dashed;
  opacity: 0.92;
}

.graph-orphan-section {
  width: 100%;
}

.tree-node-wrapper {
  margin-bottom: 0.5rem;
}

.tree-node-row {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  transition: var(--transition-fast);
  backdrop-filter: var(--backdrop-blur);
  position: relative;
}

.tree-node-row:hover {
  border-color: var(--border-color-glow);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

/* Status group colors (to-do, in progress, complete) — fallback when catalog colors are not loaded */
.tree-node-row.status-group-to-do {
  border-left: 3px solid hsl(220, 12%, 52%);
  background: hsla(220, 14%, 18%, 0.72);
}

.tree-node-row.status-group-in-progress {
  border-left: 3px solid var(--color-level-2);
  background: hsla(210, 100%, 60%, 0.1);
}

.tree-node-row.status-group-complete {
  border-left: 3px solid var(--color-success);
  background: hsla(145, 80%, 50%, 0.1);
}

.tree-node-row.status-group-to-do:hover {
  background: hsla(220, 14%, 22%, 0.85);
}

.tree-node-row.status-group-in-progress:hover {
  background: hsla(210, 100%, 60%, 0.16);
}

.tree-node-row.status-group-complete:hover {
  background: hsla(145, 80%, 50%, 0.16);
}

.status-group-to-do .node-status-select {
  border-color: hsla(220, 12%, 52%, 0.45);
  color: hsl(220, 12%, 78%);
}

.status-group-in-progress .node-status-select {
  border-color: hsla(210, 100%, 60%, 0.45);
  color: hsl(210, 100%, 78%);
}

.status-group-complete .node-status-select {
  border-color: hsla(145, 80%, 50%, 0.45);
  color: hsl(145, 80%, 72%);
}

/* Per-status colors from the status catalog (statusRibbon / statusColors.js) */
.tree-node-row[data-status-color],
.graph-card[data-status-color],
.calendar-issue-card[data-status-color],
.status-ribbon-host[data-status-color] {
  border-left: 3px solid var(--status-border);
  background: var(--status-bg);
}

.graph-card[data-status-color] {
  border-left-width: 4px;
  border-color: color-mix(in srgb, var(--status-border) 55%, transparent);
}

.tree-node-row[data-status-color]:hover,
.graph-card[data-status-color]:hover {
  background: color-mix(in srgb, var(--status-bg) 85%, white 8%);
  border-left-color: var(--status-border);
}

.tree-node-row[data-status-color] .node-status-select,
.graph-card[data-status-color] .node-status-select {
  border-color: color-mix(in srgb, var(--status-border) 50%, transparent);
  color: var(--status-fg);
}

.tree-toggle-arrow {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  border-radius: 4px;
  margin-right: 0.5rem;
  transition: var(--transition-fast);
}

.tree-toggle-arrow:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
}

.tree-toggle-arrow svg {
  transition: transform var(--transition-fast);
}

.tree-node-wrapper.expanded > .tree-node-row .tree-toggle-arrow svg {
  transform: rotate(90deg);
}

.tree-toggle-arrow.hidden-arrow {
  visibility: hidden;
  pointer-events: none;
}

.tree-node-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-grow: 1;
  min-width: 0;
}

.node-type-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-secondary);
  flex-shrink: 0;
}

.type-project {
  background: hsla(262, 83%, 68%, 0.15);
  color: var(--color-level-1);
  border: 1px solid hsla(262, 83%, 68%, 0.25);
}
.type-initiative {
  background: hsla(210, 100%, 60%, 0.15);
  color: var(--color-level-2);
  border: 1px solid hsla(210, 100%, 60%, 0.25);
}
.type-epic {
  background: hsla(160, 85%, 45%, 0.15);
  color: var(--color-level-3);
  border: 1px solid hsla(160, 85%, 45%, 0.25);
}
.type-task {
  background: hsla(35, 90%, 55%, 0.15);
  color: var(--color-level-4);
  border: 1px solid hsla(35, 90%, 55%, 0.25);
}

.node-priority-select {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.18rem 1.2rem 0.18rem 0.45rem;
  border-radius: 4px;
  font-family: var(--font-secondary);
  flex-shrink: 0;
  color: var(--priority-fg, var(--color-text-muted));
  background-color: var(--priority-bg, hsla(220, 12%, 18%, 0.9));
  border: 1px solid var(--priority-border, hsl(220, 12%, 58%));
  line-height: 1.25;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.35rem center;
  max-width: 11rem;
}

.node-priority-select:hover:not(:disabled) {
  filter: brightness(1.12);
}

.node-priority-select:disabled {
  opacity: 0.6;
  cursor: wait;
}

.node-priority-select option {
  background: var(--bg-modal);
  color: var(--color-text);
}

.node-title {
  font-size: 0.95rem;
  font-weight: 500;
  word-break: break-word;
}

.node-status-badge,
.node-status-select {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.15rem 0.4rem;
  border-radius: 99px;
  color: var(--color-text-muted);
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.node-status-select {
  cursor: pointer;
  max-width: 9rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.35rem center;
  padding-right: 1.2rem;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.node-status-select:hover:not(:disabled) {
  border-color: var(--color-primary);
  background-color: hsla(262, 83%, 68%, 0.08);
}

.node-status-select:disabled {
  opacity: 0.6;
  cursor: wait;
}

.node-status-select option {
  background: var(--bg-modal);
  color: var(--color-text);
}

.tree-node-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.tree-node-row:hover .tree-node-actions {
  opacity: 1;
}

.action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--color-text-muted);
  border: 1px solid transparent;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
  border-color: var(--border-color);
}

.action-btn.btn-add-child:hover {
  color: var(--color-secondary);
  background: hsla(190, 90%, 50%, 0.1);
  border-color: hsla(190, 90%, 50%, 0.2);
}

.action-btn.btn-add-sibling:hover {
  color: var(--color-success);
  background: hsla(145, 80%, 50%, 0.1);
  border-color: hsla(145, 80%, 50%, 0.2);
}

.action-btn.btn-add-parent:hover {
  color: var(--color-primary);
  background: hsla(262, 83%, 68%, 0.1);
  border-color: hsla(262, 83%, 68%, 0.2);
}

.action-btn.btn-add-upstream:hover {
  color: hsl(35, 90%, 60%);
  background: hsla(35, 90%, 55%, 0.12);
  border-color: hsla(35, 90%, 55%, 0.25);
}

.action-btn.btn-delete-issue:hover:not(:disabled):not(.is-blocked) {
  color: var(--color-danger);
  background: hsla(355, 85%, 60%, 0.12);
  border-color: hsla(355, 85%, 60%, 0.3);
}

/* Blocked delete stays clickable — click toasts why (children, maybe filtered out). */
.action-btn.btn-delete-issue:disabled,
.btn-delete-issue.is-blocked,
#btn-delete-issue-detail.is-blocked {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Tree Children List with guidelines */
.tree-node-children {
  margin-left: 28px;
  padding-left: 12px;
  border-left: 1px dashed var(--border-color);
  display: none;
}

.tree-node-wrapper.expanded > .tree-node-children {
  display: block;
}

/* Search Highlights */
.search-highlight {
  background: hsla(50, 100%, 50%, 0.2);
  color: hsl(50, 100%, 70%);
  border-radius: 2px;
  padding: 0 2px;
}

/* Locate highlight after a search jump (D052) — same look as Aphrodite Randomize. */
.search-target-flash {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 0.5rem;
  animation: search-target-pulse 1.5s ease-out;
}

@keyframes search-target-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary) 45%, transparent);
  }
  70% {
    box-shadow: 0 0 0 0.55rem transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-target-flash {
    animation: none;
  }
}

.node-row-hidden {
  display: none !important;
}

/* --- Dependency Graph View (DAG) --- */
#view-dependency {
  background: radial-gradient(circle at 90% 80%, hsla(190, 90%, 50%, 0.02) 0%, transparent 50%),
              radial-gradient(circle at 10% 20%, hsla(262, 83%, 68%, 0.02) 0%, transparent 50%);
  /* Keep .view-panel absolute fill so the DAG scrolls inside the canvas, not grow the page */
  overflow: hidden;
  min-height: 0;
}

#dependency-hud {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  pointer-events: none;
}

#dependency-hud > * {
  pointer-events: auto;
}

.dependency-hud-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: var(--backdrop-blur);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.hud-btn:hover {
  border-color: var(--color-primary);
  background: var(--bg-card-hover);
}

.hud-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 0 12px var(--color-primary-glow);
  animation: pulse-border 2s infinite;
}

#btn-toggle-orphans.active {
  background: hsla(35, 90%, 55%, 0.15);
  color: var(--color-level-4);
  border-color: hsla(35, 90%, 55%, 0.35);
  box-shadow: none;
  animation: none;
}

#btn-toggle-finished-trees.active {
  background: hsla(142, 70%, 45%, 0.15);
  color: hsl(142, 70%, 55%);
  border-color: hsla(142, 70%, 45%, 0.35);
  box-shadow: none;
  animation: none;
}

#btn-toggle-orphans:disabled,
#btn-toggle-finished-trees:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.orphan-toggle-count {
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 99px;
  background: hsla(35, 90%, 55%, 0.2);
  color: var(--color-level-4);
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.finished-toggle-count {
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 99px;
  background: hsla(142, 70%, 45%, 0.2);
  color: hsl(142, 70%, 55%);
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#hud-status {
  background: hsla(262, 83%, 68%, 0.15);
  border: 1px solid hsla(262, 83%, 68%, 0.3);
  padding: 0.4rem 1rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-primary);
  backdrop-filter: var(--backdrop-blur);
}

.hud-zoom-controls {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: var(--backdrop-blur);
  border-radius: 8px;
  padding: 2px;
}

.hud-zoom-controls button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition-fast);
}

.hud-zoom-controls button:hover {
  background: rgba(255, 255, 255, 0.05);
}

#zoom-indicator {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.5rem;
  min-width: 50px;
  text-align: center;
  color: var(--color-text-muted);
}

#btn-zoom-reset {
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  width: auto !important;
  padding: 0 0.5rem;
}

/* Canvas & Graph Layout */
#graph-canvas-container {
  width: 100%;
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  padding: 5rem 2rem 2rem 2rem;
  cursor: grab;
}

#graph-canvas-container.grabbing {
  cursor: grabbing;
  user-select: none;
}

#graph-world-sizer {
  position: relative;
}

#graph-world {
  position: relative;
  display: inline-block;
}

#graph-edges-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

#graph-edges-svg path.graph-edge-path,
.detail-context-dag-edges path.graph-edge-path {
  fill: none;
  stroke: hsl(220, 45%, 72%);
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.detail-context-dag-edges path.graph-edge-path {
  stroke-width: 5;
  stroke: hsl(220, 55%, 78%);
}

#graph-columns-container {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  align-items: flex-start;
  position: relative;
  z-index: 2;
  width: max-content;
  min-width: 100%;
}

.graph-dag-layer {
  position: relative;
  min-width: 100%;
}

.graph-dag-layer #graph-edges-svg {
  position: absolute;
  top: 0;
  left: 0;
}

.graph-card.graph-card-positioned {
  position: absolute;
  margin: 0;
  z-index: 2;
}

.graph-card.graph-card-positioned:hover {
  transform: none;
}

.graph-card.graph-card-positioned .connector-pin {
  display: none;
}

.graph-cards-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  width: 100%;
}

/* Graph Node Cards */
.graph-card {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  position: relative;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  backdrop-filter: var(--backdrop-blur);
  cursor: pointer;
  user-select: none;
}

.graph-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.graph-card:not([class*="status-group-"]):hover {
  border-color: var(--border-color-glow);
}

/* Dependency graph status group colors */
.graph-card.status-group-to-do {
  border-color: hsla(220, 12%, 52%, 0.55);
  border-left-width: 4px;
  border-left-color: hsl(220, 12%, 64%);
  background: hsla(220, 16%, 17%, 0.95);
  box-shadow: inset 0 1px 0 hsla(220, 12%, 70%, 0.08);
}

.graph-card.status-group-in-progress {
  border-color: hsla(210, 100%, 60%, 0.5);
  border-left-width: 4px;
  border-left-color: var(--color-level-2);
  background: hsla(210, 65%, 18%, 0.95);
  box-shadow: inset 0 1px 0 hsla(210, 100%, 70%, 0.12);
}

.graph-card.status-group-complete {
  border-color: hsla(145, 80%, 50%, 0.5);
  border-left-width: 4px;
  border-left-color: var(--color-success);
  background: hsla(145, 45%, 16%, 0.95);
  box-shadow: inset 0 1px 0 hsla(145, 80%, 60%, 0.12);
}

.graph-card.status-group-to-do:hover {
  border-color: hsla(220, 12%, 58%, 0.7);
  border-left-color: hsl(220, 12%, 72%);
  background: hsla(220, 16%, 20%, 0.98);
}

.graph-card.status-group-in-progress:hover {
  border-color: hsla(210, 100%, 60%, 0.65);
  border-left-color: hsl(210, 100%, 68%);
  background: hsla(210, 65%, 21%, 0.98);
}

.graph-card.status-group-complete:hover {
  border-color: hsla(145, 80%, 50%, 0.65);
  border-left-color: hsl(145, 80%, 60%);
  background: hsla(145, 45%, 19%, 0.98);
}

/* Highlight matching search in Graph */
.graph-card.search-match {
  border-color: var(--color-secondary);
  box-shadow: 0 0 12px var(--color-secondary-glow);
}

.graph-card.search-mismatch {
  opacity: 0.25;
}

/* Dynamic Graph Card States */
.graph-card.linking-source {
  border-color: var(--color-primary);
  box-shadow: 0 0 14px var(--color-primary-glow);
  animation: pulse-border 2s infinite;
}

.graph-card.linking-target-candidate:hover {
  border-color: var(--color-success);
  box-shadow: 0 0 14px hsla(145, 80%, 50%, 0.3);
}

.graph-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.graph-card-header-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.graph-collapse-blockers {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.graph-collapse-blockers svg {
  transition: transform var(--transition-fast);
  transform: rotate(90deg);
}

.graph-collapse-blockers.is-collapsed svg {
  transform: rotate(0deg);
}

.graph-collapse-blockers:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
  background: hsla(262, 83%, 68%, 0.1);
}

.graph-collapsed-count {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.graph-card-priority {
  display: flex;
  align-items: flex-start;
  margin: 0 0 0.5rem;
}

.graph-card-priority .node-priority-select {
  max-width: 100%;
  width: 100%;
  white-space: normal;
}

.graph-card-header-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  min-width: 0;
  flex-shrink: 0;
}

.graph-card-options {
  position: relative;
  flex-shrink: 0;
}

.graph-options-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 700;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.graph-options-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color);
  color: var(--color-text);
}

.graph-card-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--backdrop-blur);
  z-index: 30;
  overflow: hidden;
}

.graph-menu-item {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  color: var(--color-text);
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: var(--transition-fast);
}

.graph-menu-item:last-child {
  border-bottom: none;
}

.graph-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.graph-menu-item.btn-remove-parent-link {
  color: var(--color-danger);
}

.graph-menu-item.btn-remove-parent-link:hover {
  background: hsla(355, 85%, 60%, 0.12);
}

.graph-menu-item.btn-delete-issue {
  color: var(--color-danger);
}

.graph-menu-item.btn-delete-issue:hover:not(:disabled) {
  background: hsla(355, 85%, 60%, 0.12);
}

.graph-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.graph-menu-empty {
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.graph-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
  word-break: break-word;
}

.graph-card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.graph-card-actions {
  display: flex;
  gap: 0.3rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.graph-card:hover .graph-card-actions {
  opacity: 1;
}

.graph-action-btn {
  width: auto;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  border-radius: 5px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  padding: 0 0.35rem;
}

.graph-action-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.graph-action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
  border-color: var(--border-color);
}

.graph-action-btn.btn-add-child:hover {
  color: var(--color-secondary);
  background: hsla(190, 90%, 50%, 0.1);
}

.graph-action-btn.btn-add-upstream:hover {
  color: hsl(35, 90%, 60%);
  background: hsla(35, 90%, 55%, 0.12);
}

.context-badge-upstream {
  background: hsla(35, 90%, 55%, 0.15);
  color: hsl(35, 90%, 65%);
  border-color: hsla(35, 90%, 55%, 0.3);
}

/* Connector Pins for drawing arrows */
.connector-pin {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-color);
  border: 2px solid var(--bg-app);
  transform: translateY(-50%);
  z-index: 3;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.connector-pin-left {
  left: -6px;
}

.connector-pin-right {
  right: -6px;
}

.graph-card:hover .connector-pin {
  background: var(--color-text-muted);
  transform: translateY(-50%) scale(1.2);
}

.graph-card.linking-source .connector-pin-right {
  background: var(--color-primary);
  transform: translateY(-50%) scale(1.3);
}

/* Modals & Popups (Slide-up drawer for mobile, center modal for desktop) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-medium);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#issue-modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  width: 460px;
  max-width: 90%;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(30px);
  transition: transform var(--transition-medium);
}

.modal-overlay.active #issue-modal {
  transform: translateY(0);
}

#delete-confirm-dialog {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  width: 400px;
  max-width: 90%;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.35rem 1rem;
  transform: translateY(30px);
  transition: transform var(--transition-medium);
}

.modal-overlay.active #delete-confirm-dialog {
  transform: translateY(0);
}

/* Confirm opens over the issue detail modal (and its pickers at 120). */
#delete-confirm-overlay {
  z-index: 130;
}

#issue-detail-modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  width: min(560px, 94vw);
  max-height: min(88vh, 720px);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(30px);
  transition: transform var(--transition-medium);
}

.modal-overlay.active #issue-detail-modal {
  transform: translateY(0);
}

.issue-detail-header {
  border-left: 4px solid var(--status-border, var(--color-primary));
}

.issue-detail-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.issue-detail-header-actions button,
.issue-detail-header-actions a.btn-secondary {
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  text-decoration: none;
  box-sizing: border-box;
}

.issue-detail-header-actions a.btn-secondary.hidden {
  display: none;
}

.issue-detail-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 0 0 auto;
}

.issue-detail-tab {
  flex: 0 0 auto;
  padding: 0.45rem 0.75rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 2.5rem;
  touch-action: manipulation;
}

.issue-detail-tab.active {
  color: var(--color-text);
  border-bottom-color: var(--color-primary, hsl(250, 70%, 60%));
}

.issue-detail-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.issue-detail-panel.hidden,
.issue-detail-panel[hidden] {
  display: none;
}

.issue-detail-context-mount {
  padding: 0.75rem 1rem 1rem;
  min-height: 12rem;
  max-height: min(62vh, 560px);
  overflow: auto;
}

.detail-relation-editors {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
}

.detail-relation-preview {
  min-height: 10rem;
  margin-top: 0.25rem;
}

.detail-context-tree-graph {
  overflow: auto;
  max-height: min(40vh, 360px);
  padding: 0.25rem 0.15rem 0.5rem;
}

.detail-context-tree-graph .tree-node-row.is-focus-issue {
  outline: 2px solid var(--color-primary, hsl(250, 70%, 60%));
  outline-offset: 1px;
  border-radius: 6px;
}

.detail-context-tree-graph .tree-node-content:disabled {
  opacity: 1;
  cursor: default;
}

.detail-context-dag-viewport {
  overflow: auto;
  max-height: min(40vh, 360px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: hsla(220, 24%, 8%, 0.45);
  min-height: 10rem;
}

.detail-context-dag-layer {
  position: relative;
  min-width: 100%;
  min-height: 8rem;
}

.detail-context-dag-layer.is-fallback-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
}

.detail-context-dag-edges {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.detail-context-graph-card {
  text-align: left;
  cursor: pointer;
  padding: 0.45rem 0.55rem;
  min-height: 4.5rem;
}

.detail-context-graph-card:disabled {
  cursor: default;
  opacity: 1;
}

.detail-context-graph-card.is-focus-issue {
  outline: 2px solid var(--color-primary, hsl(250, 70%, 60%));
  outline-offset: 2px;
  z-index: 2;
}

.detail-context-graph-card .graph-card-title {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.relation-editor {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.relation-editor-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.relation-editor-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.relation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  min-height: 1.75rem;
}

.relation-chips-empty {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.relation-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  padding: 0.2rem 0.35rem 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card, hsla(220, 20%, 12%, 0.65));
  font-size: 0.82rem;
}

.relation-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.relation-chip-remove {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  touch-action: manipulation;
}

.relation-chip-remove:hover {
  color: var(--color-text);
}

.relation-search-box {
  position: relative;
}

.relation-search-input {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: hsla(220, 20%, 12%, 0.65);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
}

.relation-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.relation-editor .search-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
}

.relation-editor .search-candidate-dropdown {
  z-index: 120;
}

.detail-context-lazy-hint,
.detail-context-empty,
.detail-context-empty-hint {
  margin: 0.5rem 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.detail-context-tree {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.detail-context-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  padding-left: calc(0.55rem + (var(--context-depth, 0) * 0.85rem));
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card, hsla(220, 20%, 12%, 0.55));
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.detail-context-row.is-focus-issue {
  outline: 2px solid var(--color-primary, hsl(250, 70%, 60%));
  outline-offset: 1px;
  border-color: var(--color-primary, hsl(250, 70%, 60%));
  cursor: default;
}

.detail-context-deps {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.detail-context-dep-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.detail-context-dep-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.detail-context-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  padding-left: calc(0.65rem + (var(--context-depth, 0) * 0.85rem));
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card, hsla(220, 20%, 12%, 0.55));
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.detail-context-card.is-focus-issue {
  outline: 2px solid var(--color-primary, hsl(250, 70%, 60%));
  outline-offset: 1px;
  border-color: var(--color-primary, hsl(250, 70%, 60%));
  cursor: default;
}

.detail-context-card-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
}

.detail-context-card-title {
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}

.detail-context-card-status {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.issue-detail-form {
  padding: 1rem 1.35rem 1.1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.issue-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 0.85rem;
}

.issue-detail-readonly {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-transform: capitalize;
  background: hsla(220, 20%, 12%, 0.5);
}

.issue-detail-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 4rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: hsla(220, 20%, 12%, 0.65);
  color: var(--color-text);
  font: inherit;
}

.issue-detail-form textarea:focus,
.issue-detail-form input[type="date"]:focus {
  outline: none;
  border-color: var(--color-primary);
}

.issue-detail-form input[type="date"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: hsla(220, 20%, 12%, 0.65);
  color: var(--color-text);
  font: inherit;
}

.issue-detail-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0.75rem 1.15rem 1rem;
  border-top: 1px solid var(--border-color);
}

.issue-detail-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.issue-detail-autosave-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

@media (max-width: 560px) {
  .issue-detail-grid {
    grid-template-columns: 1fr;
  }

  #issue-detail-overlay {
    align-items: flex-end;
    padding: 0;
  }

  #issue-detail-modal {
    width: 100%;
    max-width: 100%;
    max-height: min(92vh, 100dvh);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .issue-detail-form {
    padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0));
  }

  .issue-detail-form input,
  .issue-detail-form select,
  .issue-detail-form textarea,
  .issue-detail-form input[type="date"] {
    min-height: 2.5rem;
    font-size: 16px; /* avoid iOS zoom on focus */
  }

  .issue-detail-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .issue-detail-footer-actions {
    margin-left: 0;
    justify-content: space-between;
  }

  #btn-close-issue-detail-footer {
    min-height: 2.5rem;
    flex: 1;
  }
}

#delete-confirm-dialog h2 {
  font-size: 1.1rem;
  margin-bottom: 0.65rem;
}

#delete-confirm-dialog p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.45;
  margin-bottom: 1.1rem;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

#btn-close-modal {
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  transition: var(--transition-fast);
}

#btn-close-modal:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
}

#issue-form {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  font-family: var(--font-secondary);
}

.form-group input, .form-group select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--color-primary);
  background: rgba(0, 0, 0, 0.3);
}

.form-group select option {
  background: var(--bg-modal);
  color: var(--color-text);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-family: var(--font-secondary);
}

#context-info-group {
  flex-direction: row;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-color);
  padding: 0.75rem;
  border-radius: 8px;
}

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

.context-badge {
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-primary-glow);
  color: var(--color-primary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* Loading Spinner Overlay */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 1;
  transition: opacity var(--transition-medium);
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-container p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
}

.toast {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  transform: translateY(20px);
  opacity: 0;
  transition: transform var(--transition-medium), opacity var(--transition-medium);
}

.toast.active {
  transform: translateY(0);
  opacity: 1;
}

.toast-success { border-left: 4px solid var(--color-success); }
.toast-error { border-left: 4px solid var(--color-danger); }
.toast-info { border-left: 4px solid var(--color-primary); }

.toast-icon {
  flex-shrink: 0;
}

.toast-icon-success { color: var(--color-success); }
.toast-icon-error { color: var(--color-danger); }
.toast-icon-info { color: var(--color-primary); }

.toast-message {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
}

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

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(167, 139, 250, 0); }
  100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0); }
}

/* ==========================================================
   Mobile Responsive Adjustments
   ========================================================== */
@media (max-width: 768px) {
  /* Phone-first chrome (D042): two compact bands, not a stacked desktop header */
  #app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "brand search"
      "actions actions";
    padding: 0.4rem 0.6rem;
    align-items: center;
    gap: 0.4rem 0.5rem;
  }

  #brand {
    grid-area: brand;
    justify-content: flex-start;
  }

  .logo-icon svg {
    width: 20px;
    height: 20px;
  }

  .logo-text {
    display: none;
  }

  #search-bar {
    grid-area: search;
    width: auto;
    min-width: 0;
    padding: 0.35rem 0.7rem;
  }

  #header-actions {
    grid-area: actions;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.35rem;
  }

  #scope-toggle-group,
  .view-toggle-group {
    flex: 0 0 auto;
    justify-content: center;
  }

  .toggle-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    gap: 0.2rem;
  }

  /* Icon-only view toggles; keep Personal/Work labels (D042) */
  .view-toggle-group:not(#scope-toggle-group) .toggle-btn span {
    display: none;
  }

  #btn-refresh span,
  #btn-quick-create span,
  #sync-hud {
    display: none;
  }

  #dependency-hud .hud-btn > span:not(.orphan-toggle-count):not(.finished-toggle-count) {
    display: none;
  }

  #btn-refresh,
  #btn-quick-create {
    padding: 0.4rem 0.55rem;
  }

  /* Viewports */
  #view-hierarchy {
    padding: 1rem;
  }
  
  .tree-node-row {
    padding: 0.6rem 0.75rem;
  }
  
  .tree-node-actions {
    opacity: 1; /* Always visible on mobile since there is no hover */
  }
  
  .tree-node-children {
    margin-left: 14px;
    padding-left: 8px;
  }

  /* Overlay HUD: one row over the canvas, not a second stacked header (D042) */
  #dependency-hud {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    align-items: center;
    gap: 0.35rem;
    background: hsla(220, 24%, 7%, 0.8);
    backdrop-filter: blur(8px);
    padding: 0.35rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
  }

  #hierarchy-toolbar {
    margin-bottom: 0.5rem;
  }

  .calendar-toolbar-bar {
    padding: 0.5rem 0.65rem;
  }

  .calendar-controls-panel {
    padding: 0 0.65rem 0.65rem;
  }

  .calendar-controls-left {
    gap: 0.65rem 1rem;
    padding-top: 0.5rem;
  }

  .calendar-new-issue-btn {
    min-height: 2.5rem;
    min-width: 2.5rem;
    padding: 0.5rem 0.7rem;
    touch-action: manipulation;
  }

  .calendar-new-issue-btn span {
    display: none;
  }

  .hud-btn {
    padding: 0.4rem 0.55rem;
    font-size: 0.78rem;
  }

  .hud-zoom-controls {
    justify-content: center;
    margin-left: auto;
  }

  #graph-canvas-container {
    padding-top: 3.25rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Mobile Drawer Modal */
  #issue-modal {
    position: absolute;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    border-bottom: none;
  }

  .modal-overlay.active #issue-modal {
    transform: translateY(0);
  }

  #delete-confirm-dialog {
    position: absolute;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }

  .modal-overlay.active #delete-confirm-dialog {
    transform: translateY(0);
  }

  /* Actions inside Cards: always visible on mobile */
  .graph-card-actions {
    opacity: 1;
  }
}

/* Modal Tabs Layout */
.modal-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 1.5rem 0 1.5rem;
  gap: 1rem;
}

.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  padding: 0.5rem 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-tab:hover {
  color: var(--color-text);
}

.modal-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Link Existing Search List */
.search-results-list,
#existing-search-bar .search-candidate-dropdown {
  max-height: 220px;
}

.existing-result-item {
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: var(--transition-fast);
  color: var(--color-text);
}

.existing-result-item:last-child {
  border-bottom: none;
}

.existing-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.existing-result-item.selected {
  background: hsla(262, 83%, 68%, 0.15);
  border-left: 3px solid var(--color-primary);
  padding-left: calc(0.8rem - 3px);
}

.existing-result-title {
  word-break: break-word;
  min-width: 0;
  flex: 1;
}

.existing-result-empty {
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* Drag and Drop Card Hover state */
.graph-card.drag-hover {
  border-color: var(--color-success) !important;
  box-shadow: 0 0 14px hsla(145, 80%, 50%, 0.3) !important;
  transform: scale(1.02) !important;
}

.graph-card.dragging-card {
  opacity: 0.4;
}

/* Calendar View Styles */
#calendar-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  gap: 0;
}

.calendar-toolbar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  flex-wrap: wrap;
}

.calendar-controls-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
}

.calendar-controls-chevron {
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.85;
  transition: transform 0.15s ease;
}

#calendar-toolbar.is-controls-collapsed .calendar-controls-chevron {
  transform: rotate(-90deg);
}

.calendar-controls-panel {
  display: block;
  padding: 0 1rem 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
}

#calendar-toolbar.is-controls-collapsed .calendar-controls-panel {
  display: none;
}

.calendar-bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--color-primary) 12%, var(--bg-secondary, hsl(220, 20%, 10%)));
}

.calendar-bulk-bar.hidden {
  display: none;
}

.calendar-bulk-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  min-width: 6rem;
}

.calendar-bulk-field-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.calendar-bulk-field-label select,
.calendar-bulk-value {
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-card, hsl(220, 20%, 12%));
  color: var(--color-text);
  font-size: 0.85rem;
  min-width: 8rem;
}

.calendar-bulk-value-slot {
  display: flex;
  align-items: center;
  min-width: 0;
}

.calendar-bulk-value-slot textarea.calendar-bulk-value {
  min-width: 12rem;
  resize: vertical;
}

.calendar-bulk-apply:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.calendar-controls-left {
  display: flex;
  gap: 1.25rem 2rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  padding-top: 0.65rem;
}

.calendar-controls-right {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
}

.calendar-new-issue-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  min-height: 2.25rem;
  padding: 0.45rem 0.85rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.control-group select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--color-text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.control-group select:hover {
  border-color: var(--color-primary);
}

.view-mode-toggle {
  display: flex;
  gap: 0.25rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.15rem;
  background: rgba(0, 0, 0, 0.1);
}

.view-mode-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 3px;
  transition: var(--transition-fast);
}

.view-mode-btn:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.15);
}

.view-mode-btn.active {
  background: var(--color-primary);
  color: white;
}

#calendar-container {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.calendar-period-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.calendar-period-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  min-width: 10ch;
  text-align: center;
}

.calendar-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--color-text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-fast);
}

.calendar-nav-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.calendar-nav-today {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.calendar-nav-today:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.calendar-controls-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.calendar-today-toolbar-btn {
  min-height: 2.25rem;
  padding: 0.4rem 0.75rem;
}

/* Month View */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: var(--border-color);
  margin-bottom: 2rem;
}

.calendar-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: var(--border-color);
  margin-bottom: 1rem;
}

.calendar-day-header {
  padding: 0.75rem;
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  color: var(--color-text);
}

.calendar-cell {
  background: var(--bg-primary);
  min-height: 120px;
  padding: 0.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calendar-cell.other-month {
  background: rgba(0, 0, 0, 0.05);
  opacity: 0.6;
}

.calendar-cell.today {
  background: hsla(262, 83%, 68%, 0.08);
  border: 1px solid hsla(262, 83%, 68%, 0.2);
}

.calendar-date-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.calendar-issues-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Week View */
.calendar-week-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.calendar-day-column {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.calendar-day-column.today {
  border-color: hsla(262, 83%, 68%, 0.4);
  box-shadow: 0 0 8px hsla(262, 83%, 68%, 0.1);
}

.calendar-day-col-header {
  padding: 0.75rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.day-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.day-date {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
}

.calendar-day-issues {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
}

/* Day View */
.calendar-day-view-container {
  max-width: 600px;
  margin: 0 auto;
}

.calendar-day-view-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calendar-empty-message {
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Issue Cards */
.calendar-issue-card {
  position: relative;
  padding: 0.4rem 0.45rem 0.4rem 0.7rem;
  background: var(--bg-card, var(--bg-primary, hsla(220, 20%, 12%, 0.6)));
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: grab;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  min-height: fit-content;
}

/* Ribbon strip carries the click target; keep a tinted card border for scanability */
.calendar-issue-card.status-ribbon-host[data-status-color] {
  border-left-color: var(--status-border);
  border-left-width: 3px;
}

.calendar-issue-card:hover {
  border-color: color-mix(in srgb, var(--status-border, var(--color-primary)) 55%, transparent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calendar-issue-card.is-select-mode {
  cursor: pointer;
  padding-left: 1.55rem;
}

.calendar-issue-card.is-select-mode .status-ribbon,
.calendar-issue-card.is-select-mode .status-toggle,
.calendar-issue-card.is-select-mode .due-today-btn,
.calendar-issue-card.is-select-mode .calendar-reorder {
  pointer-events: none;
  opacity: 0.85;
}

.calendar-issue-card.drag-insert-before {
  box-shadow: inset 0 2px 0 0 var(--color-primary, hsl(250, 70%, 60%));
}

.calendar-issue-card.drag-insert-after {
  box-shadow: inset 0 -2px 0 0 var(--color-primary, hsl(250, 70%, 60%));
}

.calendar-issue-card.is-selected {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  border-color: var(--color-primary);
}

.calendar-issue-card.is-reorder-flash {
  outline: 2px solid var(--color-primary, hsl(250, 70%, 60%));
  outline-offset: 1px;
  border-color: var(--color-primary, hsl(250, 70%, 60%));
  animation: calendar-reorder-flash 1.6s ease-out;
}

@keyframes calendar-reorder-flash {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary, hsl(250, 70%, 60%)) 55%, transparent);
    background: color-mix(in srgb, var(--color-primary, hsl(250, 70%, 60%)) 22%, var(--bg-card, hsla(220, 20%, 12%, 0.6)));
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
    background: var(--bg-card, var(--bg-primary, hsla(220, 20%, 12%, 0.6)));
  }
}

@media (prefers-reduced-motion: reduce) {
  .calendar-issue-card.is-reorder-flash {
    animation: none;
  }
}

.calendar-select-check {
  position: absolute;
  left: 0.35rem;
  top: 0.4rem;
  z-index: 3;
  width: 0.9rem;
  height: 0.9rem;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.calendar-issue-card:active {
  cursor: grabbing;
}

.calendar-issue-card.dragging {
  opacity: 0.5;
  border-style: dashed;
}

.calendar-issue-main {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
}

.calendar-issue-chrome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.calendar-issue-title {
  font-weight: 500;
  color: var(--color-text);
  word-break: break-word;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  padding: 0 1.1rem 0 0;
  margin: 0;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.calendar-issue-title:hover,
.calendar-issue-title:focus-visible {
  outline: none;
  text-decoration: none;
}

.calendar-issue-badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding-left: 1.35rem;
}

.calendar-badge {
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.calendar-priority-badge {
  background: rgba(255, 165, 0, 0.2);
  color: var(--color-text);
  border: 1px solid rgba(255, 165, 0, 0.3);
}

/* Clickable status ribbon (left strip) */
.status-ribbon {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 4px 0 0 4px;
  background: var(--status-border, hsl(220, 12%, 58%));
  cursor: pointer;
  z-index: 2;
}

.status-ribbon:hover,
.status-ribbon:focus-visible {
  width: 10px;
  outline: none;
  filter: brightness(1.1);
}

.status-ribbon-menu {
  min-width: 9rem;
  max-height: min(50vh, 16rem);
  overflow: auto;
  padding: 0.25rem;
  background: var(--bg-primary, #141820);
  border: 1px solid var(--border-color, hsla(220, 12%, 40%, 0.45));
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.status-ribbon-menu-item {
  text-align: left;
  border: none;
  border-left: 3px solid var(--status-border, transparent);
  background: var(--status-bg, transparent);
  color: var(--status-fg, var(--color-text));
  padding: 0.35rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  cursor: pointer;
}

.status-ribbon-menu-item:hover,
.status-ribbon-menu-item.is-current {
  filter: brightness(1.08);
}

/* □ / − / ✓ status toggle */
.status-toggle {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  padding: 0;
  border: 1.5px solid var(--status-border, hsl(220, 12%, 58%));
  border-radius: 3px;
  background: transparent;
  color: var(--status-fg, var(--color-text));
  font-size: 0.7rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.status-toggle[data-status-group="complete"] {
  background: color-mix(in srgb, var(--status-border, hsl(145, 70%, 46%)) 35%, transparent);
}

.status-toggle[data-status-group="in_progress"] {
  background: color-mix(in srgb, var(--status-border, hsl(210, 90%, 58%)) 22%, transparent);
}

.status-toggle:hover,
.status-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--status-border) 40%, transparent);
}

.due-today-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 0.05rem 0.15rem;
  border: 1px solid var(--border-color, hsla(220, 12%, 40%, 0.45));
  border-radius: 2px;
  background: transparent;
  color: var(--color-text-muted, hsl(220, 10%, 62%));
  font-size: 0.55rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
}

.due-today-btn:hover:not(:disabled),
.due-today-btn:focus-visible:not(:disabled) {
  outline: none;
  color: var(--color-text);
  border-color: var(--color-primary, hsl(250, 70%, 60%));
}

.due-today-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Reorder-mode ↑↓ (horizontal so card height stays stable) */
.calendar-reorder {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  flex-shrink: 0;
  gap: 0.2rem;
  margin-left: auto;
}

.calendar-reorder-btn {
  min-width: 1.6rem;
  min-height: 1.6rem;
  padding: 0;
  border: 1px solid var(--border-color, hsla(220, 12%, 40%, 0.45));
  border-radius: 4px;
  background: var(--bg-primary, hsla(220, 20%, 14%, 0.9));
  color: var(--color-text);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.calendar-reorder-btn:hover:not(:disabled),
.calendar-reorder-btn:focus-visible:not(:disabled) {
  outline: none;
  border-color: var(--color-primary, hsl(250, 70%, 60%));
}

.calendar-reorder-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

@media (pointer: coarse) {
  .calendar-reorder-btn {
    min-width: 2.5rem;
    min-height: 2.5rem;
    font-size: 1rem;
  }

  .due-today-btn {
    min-height: 1.75rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.7rem;
  }

  .status-toggle {
    width: 1.35rem;
    height: 1.35rem;
  }
}

/* Type chip (non-Task) */
.issue-type-icon {
  position: absolute;
  top: 0.2rem;
  right: 0.25rem;
  width: 1rem;
  height: 1rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
}

.issue-type-icon.type-project {
  background: hsla(262, 83%, 68%, 0.2);
  color: var(--color-level-1);
  border: 1px solid hsla(262, 83%, 68%, 0.35);
}

.issue-type-icon.type-initiative {
  background: hsla(210, 100%, 60%, 0.2);
  color: var(--color-level-2);
  border: 1px solid hsla(210, 100%, 60%, 0.35);
}

.issue-type-icon.type-epic {
  background: hsla(160, 85%, 45%, 0.2);
  color: var(--color-level-3);
  border: 1px solid hsla(160, 85%, 45%, 0.35);
}

/* Drag Over State */
[data-date].drag-over {
  background: hsla(145, 80%, 50%, 0.1);
  border-color: hsla(145, 80%, 50%, 0.3) !important;
}

/* Undated Section */
.calendar-undated-section {
  border-top: 2px solid var(--border-color);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}

.calendar-undated-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.calendar-undated-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

/* D047: Non-blocking API loading chip */
.api-loading-chip {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color-glow);
  border-radius: 2rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease-out;
  z-index: 1000;
}

.api-loading-chip .spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ==========================================================
   Calendar compact agenda (phone month/week)
   ========================================================== */
.calendar-agenda {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 1.5rem;
}

.calendar-agenda-day {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  overflow: hidden;
}

.calendar-agenda-day.today {
  border-color: hsla(262, 83%, 68%, 0.45);
}

.calendar-agenda-day-title {
  margin: 0;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.calendar-agenda-day .calendar-day-issues {
  padding: 0.65rem;
  gap: 0.45rem;
}

/* ==========================================================
   List view
   ========================================================== */
#view-list,
#view-timeline {
  padding: 0.75rem 1rem 1.5rem;
  overflow: auto;
}

.list-toolbar {
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.list-view-root {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.list-group-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--color-text-muted);
}

.list-group-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.list-issue-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card, var(--bg-primary));
  color: inherit;
  cursor: pointer;
  position: relative;
}

.list-issue-row:hover {
  border-color: var(--color-primary);
}

.list-issue-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.list-issue-title {
  font-weight: 560;
  word-break: break-word;
}

.detail-parent-mount .relation-editor {
  margin: 0;
}

.detail-parent-mount .relation-editor-label {
  display: none;
}

/* ==========================================================
   Timeline view
   ========================================================== */
.timeline-view-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-rows {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  position: relative;
}

.timeline-row:hover {
  background: hsla(220, 20%, 16%, 0.55);
  border-color: var(--border-color);
}

.timeline-row-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.timeline-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 550;
}

.timeline-row-track {
  position: relative;
  height: 1.35rem;
  border-radius: 4px;
  background: hsla(220, 14%, 22%, 0.55);
  overflow: hidden;
}

.timeline-bar {
  position: absolute;
  top: 0.2rem;
  bottom: 0.2rem;
  border-radius: 3px;
  background: color-mix(in srgb, var(--status-border, var(--color-primary)) 70%, transparent);
  min-width: 4px;
}

.timeline-undated {
  margin-top: 0.5rem;
}

.timeline-undated-row {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0.25rem 0;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: inherit;
  cursor: pointer;
}

@media (max-width: 768px) {
  .timeline-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
}

/* Shared Filter / Sort chrome (VIEW_CONTROLS BRD) */
.view-controls-host,
.view-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.view-control-popover-wrap {
  position: relative;
}

.view-control-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 40;
  min-width: 16rem;
  max-width: min(92vw, 24rem);
  padding: 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card, var(--bg-primary));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.view-filter-panel {
  min-width: 20rem;
}

.view-filter-rules {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.view-filter-rule {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.35rem;
  align-items: center;
}

.view-filter-rule select,
.view-filter-rule input {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--color-text);
  max-width: 100%;
}

.view-filter-remove {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  font-size: 0.85rem;
}

.view-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.view-sort-options {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.view-sort-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-text);
}

.view-sort-option:hover,
.view-sort-option.active {
  background: var(--bg-hover, rgba(0, 0, 0, 0.06));
}

.view-sort-option.active {
  font-weight: 600;
}

.view-sort-hint {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.view-filter-btn.active,
.view-sort-btn.active {
  font-weight: 600;
}

#hierarchy-toolbar .view-controls-host,
#dependency-hud .view-controls-host {
  margin-right: 0.35rem;
}

@media (max-width: 720px) {
  .view-filter-rule {
    grid-template-columns: 1fr 1fr auto;
  }

  .view-filter-rule .view-filter-value-slot {
    grid-column: 1 / -2;
  }
}

.view-controls {
  flex-wrap: wrap;
  align-items: flex-start;
}

.view-control-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.25rem;
}

.view-control-chips.is-empty {
  display: none;
}

.view-control-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  padding: 0.2rem 0.35rem 0.2rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-primary);
  font-size: 0.75rem;
  color: var(--color-text);
}

.view-control-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-control-chip-remove {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 0.75rem;
  line-height: 1;
}

.view-sort-chip {
  border-color: hsl(210, 70%, 55%);
}

/* ============================================================
   Recurring routines (RECURRING_TASKS_BRD §6)
   ============================================================ */
body.place-recurring #search-bar,
body.place-recurring #scope-toggle-group,
body.place-recurring #btn-refresh,
body.place-recurring #sync-hud { display: none; }

#header-actions a.toggle-btn { text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem; }

#view-settings { background: radial-gradient(circle at 90% 10%, hsla(190, 90%, 50%, 0.04) 0%, transparent 50%); overflow-y: auto; }
.user-menu { position: relative; display: inline-block; }
.user-menu-list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 10rem; z-index: 60; display: flex; flex-direction: column; padding: 0.25rem; border-radius: 10px; background: var(--bg-card); border: 1px solid var(--border-color-glow); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.user-menu-list.hidden { display: none; }
.user-menu-item { display: block; padding: 0.6rem 0.75rem; min-height: 40px; box-sizing: border-box; border-radius: 8px; color: var(--color-text); text-decoration: none; }
.user-menu-item:hover { background: var(--bg-card-hover); }
.rec-builder .rec-check input { margin-right: 0.3rem; }

#view-recurring { background: radial-gradient(circle at 90% 10%, hsla(190, 90%, 50%, 0.04) 0%, transparent 50%); }
.rec-root { padding: 1.25rem 1.5rem 3rem; max-width: 1400px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.rec-page-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.rec-page-title { margin: 0; font-size: 1.3rem; }
.rec-muted { color: var(--color-text-muted); }
.rec-loading, .rec-message { padding: 1.5rem; color: var(--color-text-muted); }
.rec-message.is-error, .rec-preview.is-error, .rec-form-error { color: var(--color-danger); }

.rec-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 36px; padding: 0 0.85rem; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--border-color-glow); background: var(--bg-card); color: var(--color-text);
  font: inherit; font-size: 0.85rem; transition: background var(--transition-fast);
}
.rec-btn:hover:not(:disabled) { background: var(--bg-card-hover); }
.rec-btn:disabled { opacity: 0.5; cursor: default; }
.rec-btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.rec-btn-primary:hover:not(:disabled) { background: hsl(262, 83%, 62%); }
.rec-btn-danger { color: var(--color-danger); }
.rec-btn-group { display: inline-flex; gap: 0.25rem; }
.rec-input {
  min-height: 36px; padding: 0 0.6rem; border-radius: 8px; box-sizing: border-box; font: inherit; font-size: 0.85rem;
  border: 1px solid var(--border-color-glow); background: var(--bg-card); color: var(--color-text);
}
textarea.rec-input { padding: 0.5rem 0.6rem; width: 100%; resize: vertical; }
.rec-input-narrow { width: 5rem; }

.rec-headline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem 1.5rem; margin-bottom: 0.85rem; }
.rec-headline-count { font-size: 2rem; font-weight: 700; font-family: var(--font-primary); }
.rec-headline-label { color: var(--color-text-muted); }
.rec-headline-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rec-chip { padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.78rem; background: var(--bg-card); border: 1px solid var(--border-color); }
.rec-chip-muted { color: var(--color-text-muted); }
.rec-chip-due { border-color: var(--color-warning); color: var(--color-warning); }
.rec-state-paused { color: var(--color-warning); }
.rec-state-archived { color: var(--color-text-muted); }

.rec-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.85rem; }
.rec-search { flex: 1 1 180px; min-width: 140px; }

/* grid */
.rec-grid-scroll { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card); }
.rec-grid { display: table; min-width: 100%; border-collapse: collapse; }
.rec-grid-row { display: flex; align-items: center; border-bottom: 1px solid var(--border-color); }
.rec-grid-row:last-child { border-bottom: 0; }
.rec-name-cell, .rec-name-head {
  position: sticky; left: 0; z-index: 2; flex: 0 0 168px; width: 168px; box-sizing: border-box;
  padding: 0.5rem 0.6rem; background: hsl(220, 22%, 11%); display: flex; flex-direction: column; min-width: 0;
}
.rec-name-head { font-size: 0.75rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.rec-name-link { color: var(--color-text); text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
.rec-name-link:hover { color: var(--color-secondary); }
.rec-name-sub { font-size: 0.72rem; color: var(--color-text-muted); overflow-wrap: anywhere; }
.rec-row-paused .rec-name-link, .rec-row-archived .rec-name-link { opacity: 0.6; }
.rec-day-head { flex: 0 0 34px; width: 34px; text-align: center; font-size: 0.65rem; color: var(--color-text-muted); display: flex; flex-direction: column; padding: 0.3rem 0; }
.rec-day-head.is-weekend { opacity: 0.7; }
.rec-day-head.is-today { color: var(--color-secondary); font-weight: 700; }
.rec-day-dom { font-size: 0.75rem; }
.rec-stat-head, .rec-stat-cell { flex: 0 0 70px; width: 70px; text-align: center; font-size: 0.75rem; color: var(--color-text-muted); }
.rec-streak.is-hot { color: var(--color-warning); font-weight: 700; }

.rec-cell {
  flex: 0 0 26px; width: 26px; height: 26px; margin: 4px; border-radius: 7px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; line-height: 1;
  border: 1px solid transparent; padding: 0; font-family: inherit; color: inherit; background: transparent;
}
.rec-cell-done { background: hsla(145, 80%, 50%, 0.85); color: hsl(145, 80%, 10%); }
.rec-cell-late { background: hsla(90, 70%, 50%, 0.55); color: hsl(90, 70%, 10%); border-color: hsl(90, 70%, 50%); }
.rec-cell-skipped { background: hsla(220, 12%, 60%, 0.3); color: var(--color-text-muted); }
.rec-cell-missed { background: hsla(355, 85%, 60%, 0.75); color: #fff; }
.rec-cell-pending { border: 2px solid var(--color-secondary); color: var(--color-secondary); }
.rec-cell-none { background: hsla(220, 16%, 22%, 0.25); }
.rec-cell.is-today { outline: 1px solid var(--color-secondary); outline-offset: 1px; }
.rec-cell.is-actionable { cursor: pointer; }
.rec-cell.is-actionable:hover { filter: brightness(1.25); }

.rec-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.75rem; font-size: 0.75rem; color: var(--color-text-muted); }
.rec-legend-item { display: inline-flex; align-items: center; }
.rec-legend-swatch { flex-basis: 16px; width: 16px; height: 16px; margin: 0 6px 0 0; font-size: 0.6rem; }
.rec-inline-cell { flex-basis: 18px; width: 18px; height: 18px; margin: 0 4px 0 0; vertical-align: middle; }

.rec-popover {
  position: fixed; z-index: 1000; min-width: 180px; max-width: 260px; overflow: auto; box-sizing: border-box;
  padding: 0.75rem; border-radius: 12px; background: var(--bg-modal); border: 1px solid var(--border-color-glow);
  box-shadow: var(--shadow-lg); backdrop-filter: var(--backdrop-blur);
}
.rec-popover-title { font-weight: 600; overflow-wrap: anywhere; }
.rec-popover-sub { color: var(--color-text-muted); font-size: 0.75rem; margin-bottom: 0.6rem; }
.rec-popover-actions { display: flex; gap: 0.4rem; }
.rec-popover-actions .rec-btn { flex: 1; min-height: 40px; }
.rec-popover-link { display: block; margin-top: 0.6rem; font-size: 0.78rem; color: var(--color-secondary); }

.rec-empty { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }

/* detail */
.rec-detail-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.rec-detail-title h2 { margin: 0; overflow-wrap: anywhere; }
.rec-detail-sub { margin: 0.2rem 0 0; color: var(--color-text-muted); font-size: 0.85rem; }
.rec-detail-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: flex-start; }
.rec-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; margin-bottom: 1.25rem; }
.rec-card { padding: 0.75rem; border-radius: 12px; background: var(--bg-card); border: 1px solid var(--border-color); }
.rec-card-label { font-size: 0.72rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.rec-card-value { font-size: 1.7rem; font-weight: 700; font-family: var(--font-primary); }
.rec-card-hint { font-size: 0.75rem; color: var(--color-text-muted); }
.rec-section { margin-bottom: 1.5rem; }
.rec-section h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.rec-next-list { margin: 0; padding-left: 1.2rem; }
.rec-heat-scroll { overflow-x: auto; padding-bottom: 0.4rem; }
.rec-heatmap { display: inline-flex; gap: 3px; }
.rec-heat-col { display: flex; flex-direction: column; gap: 3px; }
.rec-heat-cell { width: 11px; height: 11px; border-radius: 3px; display: block; }
.rec-heat-cell.is-empty { background: transparent; }

/* table */
.rec-table-wrap { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 12px; }
.rec-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.rec-table th, .rec-table td { padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; overflow-wrap: anywhere; border-bottom: 1px solid var(--border-color); }
.rec-table th { background: hsl(220, 22%, 11%); color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }
.rec-table th.is-sortable { cursor: pointer; }
.rec-table tr:last-child td { border-bottom: 0; }
.rec-pager { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-top: 0.75rem; }
.rec-pager-info { color: var(--color-text-muted); font-size: 0.8rem; margin-top: 0.5rem; }

/* builder */
.rec-builder { max-width: 640px; display: flex; flex-direction: column; gap: 0.9rem; }
.rec-builder h2 { margin: 0; }
.rec-field { display: flex; flex-direction: column; gap: 0.3rem; }
.rec-field-label { font-size: 0.78rem; color: var(--color-text-muted); }
.rec-field-hint { font-size: 0.72rem; color: var(--color-text-muted); }
.rec-fieldset { border: 1px solid var(--border-color); border-radius: 12px; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.8rem; }
.rec-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.rec-inline { color: var(--color-text-muted); }
.rec-extra { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.rec-weekdays { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.rec-chip-btn { min-height: 36px; min-width: 44px; padding: 0 0.6rem; border-radius: 999px; cursor: pointer; font: inherit; font-size: 0.8rem; background: var(--bg-card); color: var(--color-text); border: 1px solid var(--border-color-glow); }
.rec-chip-btn.is-on { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.rec-check { display: inline-flex; align-items: center; gap: 0.3rem; min-height: 36px; }
.rec-preview { padding: 0.75rem; border-radius: 12px; background: var(--bg-card); border: 1px dashed var(--border-color-glow); }
.rec-preview-summary { font-weight: 600; margin-bottom: 0.3rem; }
.rec-preview-dates { margin: 0; padding-left: 1.3rem; }
.rec-form-actions { display: flex; gap: 0.5rem; }

/* issue chips + detail strip */
.rec-issue-chip { margin-left: 0.35rem; text-decoration: none; font-size: 0.8em; opacity: 0.85; flex: none; }
.rec-issue-chip:hover { opacity: 1; }
.detail-recurring-body { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.detail-recurring-link { color: var(--color-secondary); text-decoration: none; }
.rec-strip { display: inline-flex; gap: 3px; }
.rec-strip-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

@media (max-width: 768px) {
  .rec-root { padding: 0.75rem 0.75rem 5rem; }
  .rec-name-cell, .rec-name-head { flex-basis: 120px; width: 120px; }
  .rec-headline-count { font-size: 1.6rem; }
  .rec-toolbar .rec-btn, .rec-toolbar .rec-input { min-height: 40px; }
}

/* Recurring gamification (UC-REC-13/14) */
.rec-level { display: flex; flex-direction: column; gap: 0.3rem; min-width: 11rem; flex: 0 1 16rem; }
.rec-level-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.rec-level-badge { font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--color-primary, #4f46e5); color: #fff; }
.rec-level-xp { color: var(--color-text-muted); font-size: 0.9rem; }
.rec-xp-bar { height: 0.45rem; border-radius: 999px; background: var(--color-border, #e5e7eb); overflow: hidden; }
.rec-xp-fill { height: 100%; background: var(--color-primary, #4f46e5); transition: width 0.3s; }
.rec-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.rec-badge { font-size: 1.15rem; line-height: 1; padding: 0.2rem; cursor: help; }
.rec-badge.is-locked { filter: grayscale(1); opacity: 0.35; }
