/**
 * LukeOS Mini App - Nightglass Theme
 *
 * Dark glassmorphism design system for Telegram Mini App.
 * Touch-optimised with 44px+ tap targets.
 */

/* CSS Variables - Nightglass Theme */
:root {
  /* Backgrounds */
  --bg-primary: #0a0a0c;
  --bg-card: #161b22;
  --bg-elevated: #21262d;
  --bg-hover: #30363d;

  /* Accent - Slate Blue */
  --accent: #6b7a99;
  --accent-hover: #8892b0;
  --accent-muted: rgba(107, 122, 153, 0.3);

  /* Text */
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  /* Semantic */
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --brown: #8b5a2b;
  --critical: #ef4444;

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  /* Glass */
  --glass-bg: rgba(22, 27, 34, 0.85);
  --glass-border: rgba(255, 255, 255, 0.06);

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;

  /* Font Families */
  --font-serif: 'Libre Baskerville', Georgia, serif;
  --font-sans: 'Rubik', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

/* Base */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 100%;
  padding: var(--space-3);
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  margin-bottom: var(--space-3);
}

.header h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-lg);
  transition: all 0.2s ease;
}

.icon-btn:active {
  background: var(--bg-elevated);
  color: var(--accent);
}

/* Focus Card */
.focus-card {
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.95), rgba(33, 38, 45, 0.85));
  backdrop-filter: blur(20px) saturate(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.focus-card.brown {
  border-left: 4px solid var(--brown);
}

.focus-card.critical {
  border-left: 4px solid var(--critical);
}

.focus-card.blocked {
  border-left: 4px solid var(--warning);
}

.focus-card.empty {
  text-align: center;
  padding: var(--space-6);
}

.label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.days-waiting {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  background: rgba(139, 90, 43, 0.2);
  color: #d4a574;
  border-radius: var(--radius-sm);
}

.focus-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  line-height: 1.3;
}

.focus-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.tag {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.tag-brown {
  background: rgba(139, 90, 43, 0.2);
  color: #d4a574;
}

.tag-critical {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
}

.tag-waiting, .tag-blocked {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.focus-context {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.focus-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn-done {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-5);
  background: var(--success);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-done:active {
  transform: scale(0.98);
  box-shadow: none;
}

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

/* Calendar Card */
.calendar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.date-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.count-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: var(--radius-sm);
}

.event-list {
  padding: 0;
}

.event {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  gap: var(--space-3);
}

.event:last-child {
  border-bottom: none;
}

.event.workshop {
  background: rgba(107, 122, 153, 0.1);
}

.event-time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  min-width: 60px;
  flex-shrink: 0;
}

.event-title {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* Task Card */
.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.task-item {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  gap: var(--space-3);
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.task-item:active {
  background: var(--bg-elevated);
}

.task-item.brown {
  border-left: 3px solid var(--brown);
}

.task-bullet {
  color: var(--text-muted);
  flex-shrink: 0;
}

.task-text {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-primary);
  flex: 1;
}

.task-days {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-right: var(--space-2);
}

.btn-done-small {
  padding: 0.4rem 0.6rem;
  background: var(--success);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.9;
  flex-shrink: 0;
}

.btn-done-small:active {
  transform: scale(0.95);
}

.task-days.brown {
  color: #d4a574;
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: var(--space-2) var(--space-4);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  background: rgba(10, 10, 12, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.tab-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  min-height: 48px;
  padding: var(--space-2);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.tab-item.active {
  color: var(--accent);
}

.tab-item:active {
  color: var(--accent-hover);
}

.tab-icon {
  width: 24px;
  height: 24px;
  margin-bottom: var(--space-1);
}

.tab-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tab-badge {
  position: absolute;
  top: 2px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--error);
  color: #ffffff;
  border-radius: 9px;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

/* States */
.loading, .loading-small {
  text-align: center;
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-small {
  padding: var(--space-3);
  font-size: 0.85rem;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-icon {
  font-size: 1.25rem;
  opacity: 0.5;
}

.error-message {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: rgba(239, 68, 68, 0.9);
  color: #ffffff;
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  z-index: 100;
  animation: slideDown 0.3s ease;
}

.error-message.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Scrollbar - minimal */
::-webkit-scrollbar {
  width: 4px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 2px;
}

/* MENDINGS Panel */
.mendings-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 60px; /* Above quick actions */
  background: var(--bg-primary);
  z-index: 100;
  padding: var(--space-4);
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}

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

.mendings-panel .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.mendings-panel h3 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-size: 1.25rem;
}

.mendings-status {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.mendings-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
}

.mendings-letter {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.875rem;
}

.mendings-label {
  flex: 1;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.mendings-value-container {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.mendings-value {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-primary);
}

.mendings-value.good {
  color: var(--success);
}

.mendings-value.okay {
  color: var(--warning);
}

.mendings-value.rough {
  color: var(--error);
}

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

.mendings-value.set {
  color: var(--success);
  font-size: 0.75rem;
}

.mendings-value.not-set {
  color: var(--text-muted);
  font-style: italic;
}

.mendings-check-btn {
  padding: 0.4rem 0.6rem;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mendings-check-btn:active {
  background: var(--accent);
  color: #ffffff;
}

.mendings-prompts {
  padding: var(--space-4);
  background: var(--bg-card);
  border-radius: 12px;
  border-left: 3px solid var(--accent);
}

.mendings-prompt {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: var(--space-2);
  padding-left: var(--space-2);
}

.mendings-prompt:last-child {
  margin-bottom: 0;
}

.mendings-error {
  text-align: center;
  padding: var(--space-4);
  color: var(--text-secondary);
}

.mendings-fallback {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-top: var(--space-3);
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* Daily Spread View */
.spread-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.spread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.95), rgba(33, 38, 45, 0.85));
}

.spread-date {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.spread-stats {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  padding: 0.25rem 0.6rem;
  background: var(--accent-muted);
  border-radius: var(--radius-md);
}

.spread-section {
  padding: var(--space-2) 0;
}

.spread-section-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
}

#spread-carried .spread-section-label {
  color: #d4a574;
  background: rgba(139, 90, 43, 0.1);
}

.spread-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.spread-item {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  gap: var(--space-3);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.spread-item:active {
  background: var(--bg-elevated);
}

.spread-item.done {
  opacity: 0.6;
}

.spread-item.done .spread-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.spread-item.due-today {
  border-left: 3px solid var(--warning);
}

.spread-bullet {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.spread-item.done .spread-bullet {
  color: var(--success);
}

.spread-text {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-primary);
  flex: 1;
}

.spread-days {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  background: rgba(139, 90, 43, 0.2);
  color: #d4a574;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Carried forward section styling */
#spread-carried {
  background: rgba(139, 90, 43, 0.05);
  border-bottom: 1px solid var(--border);
}

#spread-carried .spread-item {
  border-left: 3px solid var(--brown);
}

/* Artifacts System */
.artifact-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  margin-bottom: var(--space-4);
}

.artifact-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.artifact-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.artifact-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.artifact-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(107, 122, 153, 0.15);
}

.artifact-tag {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

/* Checklist */
.artifact-checklist {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.checklist-group {
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.checklist-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.95), rgba(33, 38, 45, 0.85));
  border-bottom: 1px solid var(--border);
}

.checklist-group-title {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.checklist-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.checklist-item:active {
  background: var(--bg-elevated);
}

.checklist-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border-hover);
  background: rgba(10, 10, 12, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.checklist-checkbox::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) scale(0);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.checklist-item.is-checked .checklist-checkbox {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.6);
}

.checklist-item.is-checked .checklist-checkbox::after {
  transform: rotate(-45deg) scale(1);
  opacity: 1;
  animation: tickPop 0.28s ease;
}

.checklist-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.checklist-text {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.checklist-item.is-checked .checklist-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.checklist-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding-left: 2px;
}

@keyframes tickPop {
  0% {
    transform: rotate(-45deg) scale(0.2);
  }
  70% {
    transform: rotate(-45deg) scale(1.1);
  }
  100% {
    transform: rotate(-45deg) scale(1);
  }
}

/* Table */
.artifact-table {
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.95), rgba(33, 38, 45, 0.92));
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}

.table-scroll tbody td {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-primary);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table-scroll tbody tr:nth-child(even) td {
  background: rgba(33, 38, 45, 0.4);
}

.table-scroll tbody tr:last-child td {
  border-bottom: none;
}

.cell-number {
  text-align: right;
  font-family: var(--font-mono);
}

.cell-highlight {
  background: rgba(16, 185, 129, 0.15);
  color: #b6f3d6;
  font-weight: 600;
}

/* Report */
.artifact-report {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.report-section {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.report-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.report-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.35rem 0.7rem;
  background: rgba(107, 122, 153, 0.2);
  border: 1px solid var(--accent-muted);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--accent);
}

.report-chip-icon {
  font-size: 0.9rem;
  opacity: 0.8;
}

.report-chip-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
}

.report-text {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.report-text strong {
  color: var(--text-primary);
  font-weight: 700;
}

.report-text a {
  color: var(--accent);
  text-decoration: none;
}

.report-text a:active {
  color: var(--accent-hover);
}

.report-kv {
  display: grid;
  gap: var(--space-2);
}

.report-kv-item {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr);
  gap: var(--space-3);
  align-items: center;
}

.report-kv-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.report-kv-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
  text-align: right;
}

/* Loading Skeleton */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(33, 38, 45, 0.6);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(220%);
  }
}

/* Offline Indicator */
.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Pull to Refresh */
.pull-to-refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
}

.pull-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.pull-to-refresh.is-refreshing .pull-spinner {
  border-top-color: var(--success);
}

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

@media (max-width: 640px) {
  .artifact-card {
    padding: var(--space-4);
  }

  .report-kv-item {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .report-kv-value {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .checklist-item,
  .skeleton::after,
  .pull-spinner {
    animation: none;
    transition: none;
  }
}

/* ======================================
   NEW COMPONENTS - Mini App Rebuild
   ====================================== */

/* Main Content */
.main-content {
  padding-bottom: var(--space-4);
}

.view {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Quick Stats Row */
.quick-stats {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
}

.stat-chip.stat-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.stat-chip.stat-clickable:active {
  border-color: var(--accent);
}

.stat-icon {
  font-size: 0.9rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-secondary);
}

/* Tasks View */
.tasks-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.tasks-date {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
}

.tasks-stats {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tasks-section {
  margin-bottom: var(--space-4);
}

.tasks-section:last-child {
  margin-bottom: 0;
}

.tasks-section-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.tasks-section.collapsed .tasks-section-label {
  margin-bottom: 0;
}

.tasks-section-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}

.tasks-section-toggle:active {
  color: var(--text-primary);
}

.tasks-section-count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tasks-section-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.tasks-section.collapsed .tasks-section-arrow {
  transform: rotate(-90deg);
}

/* CR Card */
.cr-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

/* CR List */
.cr-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.cr-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.cr-item:active {
  border-color: var(--accent);
}

.cr-type-chip {
  padding: var(--space-1) var(--space-2);
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.cr-type-chip.skill {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.cr-type-chip.code {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.cr-type-chip.discussion {
  background: rgba(107, 122, 153, 0.2);
  color: var(--accent);
}

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

.cr-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.cr-target {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cr-age {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* CR Detail View */
.cr-detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.cr-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.cr-detail-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.cr-detail-target {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: var(--space-2);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.cr-detail-section {
  margin-bottom: var(--space-4);
}

.cr-detail-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.cr-detail-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* CR Diff */
.cr-diff {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cr-diff-section {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.cr-diff-label {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-hover);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.cr-diff-code {
  padding: var(--space-3);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin: 0;
}

/* CR Actions */
.cr-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.btn-primary {
  flex: 1;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  background: var(--success);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary:active {
  background: #0d9668;
  transform: scale(0.98);
}

.btn-secondary {
  flex: 1;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.btn-secondary:active {
  border-color: var(--border-hover);
  transform: scale(0.98);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.modal-content h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.modal-content textarea {
  width: 100%;
  min-height: 100px;
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: var(--space-3);
}

.modal-content textarea::placeholder {
  color: var(--text-muted);
}

.modal-content textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
}
