:root {
  --bg-dark: #0f1115;
  --bg-sidebar: #17191e;
  --bg-panel: rgba(255, 255, 255, 0.03);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f2f5;
  --text-secondary: #8b92a5;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --success: #10b981;
  --glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.badge {
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: white;
  text-transform: uppercase;
}

.sidebar-header p {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 2rem;
}

.entries-nav {
  margin-top: 2rem;
  flex: 1;
  overflow-y: auto;
}

.entries-nav h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

#entries-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.entry-item {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background-color: transparent;
}

.entry-item:hover {
  background-color: var(--bg-panel);
}

.entry-item.active {
  background-color: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
}

.entry-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-item-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  padding: 2rem 3rem;
  gap: 2rem;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent 40%);
}

.editor-section {
  flex: 3;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-header {
  margin-bottom: 1.5rem;
}

#entry-title {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 700;
  font-family: inherit;
  outline: none;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-left: -0.75rem; /* Offset padding to align text visually */
  transition: all 0.2s ease;
}

#entry-title:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

#entry-title:focus {
  background: rgba(15, 23, 42, 0.6);
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

#entry-title::placeholder {
  color: rgba(139, 146, 165, 0.3);
}

.date-display {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

#entry-content {
  flex: 1;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.6;
  font-family: inherit;
  resize: none;
  outline: none;
}

#entry-content::placeholder {
  color: rgba(139, 146, 165, 0.4);
}

.editor-footer {
  padding-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: flex-end;
}

.save-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.save-indicator::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--success);
}

/* AI Hub Glassmorphism */
.glass-panel {
  background: rgba(23, 25, 30, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  border-radius: 16px;
}

.ai-hub {
  flex: 2;
  max-width: 400px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  height: max-content;
  max-height: 100%;
}

.ai-hub-header {
  margin-bottom: 1.5rem;
}

.ai-hub-header h2 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.ai-hub-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background-color: var(--accent-color);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: var(--glow);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn-icon {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
}

.btn-icon:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.1);
}

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

#ai-output {
  margin-top: 1rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

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

.output-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-color);
}

.output-text {
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-primary);
  overflow-y: auto;
  white-space: pre-wrap;
  flex: 1;
}

/* Loading Spinner */
#ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(99, 102, 241, 0.3);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s ease-in-out infinite;
}

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

.tag {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent-color);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Amazon LP Radar ────────────────────────────────────────────────────── */

#view-amazon-radar {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 1rem;
  overflow-y: auto;
  padding-bottom: 2rem;
}

/* Coverage Wheel */
.radar-header {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  padding: 1.5rem 2rem;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 20px;
}

.radar-svg-wrap {
  flex-shrink: 0;
}

#lp-radar-svg .lp-segment {
  transition: opacity 0.2s, filter 0.2s;
  cursor: pointer;
}
#lp-radar-svg .lp-segment:hover {
  opacity: 0.85;
  filter: brightness(1.2);
}
#lp-radar-svg .segment-label {
  font-size: 7px;
  fill: rgba(255,255,255,0.7);
  font-family: 'Inter', sans-serif;
  pointer-events: none;
  font-weight: 600;
}

.radar-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}
.radar-legend h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}
.radar-legend p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}
.radar-coverage-count {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.radar-legend-pills {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.legend-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.legend-pill span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* LP Board Grid */
.lp-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.lp-card {
  background: rgba(23, 25, 30, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 160px;
}
.lp-card.drag-over {
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.lp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.lp-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
  min-width: 0;
  word-break: break-word;
  line-height: 1.3;
}
.lp-score-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  min-width: 36px;
  text-align: center;
}
.lp-score-badge.strong  { background: rgba(16,185,129,0.2); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.lp-score-badge.partial { background: rgba(245,158,11,0.2); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.lp-score-badge.weak    { background: rgba(239,68,68,0.15);  color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.lp-score-badge.none    { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* Story chips inside LP cards */
.lp-stories-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.story-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: grab;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  user-select: none;
}
.story-chip:active { cursor: grabbing; }
.story-chip:hover {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.25);
  transform: translateY(-1px);
}
.story-chip.dragging {
  opacity: 0.4;
  transform: scale(0.97);
}
.story-chip-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.story-chip-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.chip-icon {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
}
.chip-icon.star    { background: rgba(139,92,246,0.2); color: #8b5cf6; }
.chip-icon.metrics { background: rgba(16,185,129,0.2); color: #10b981; }
.chip-score {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-left: auto;
}

/* Missing indicator pills on weak story chips */
.chip-missing {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.lp-empty-msg {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 1rem 0.5rem;
  opacity: 0.6;
}

/* LP card question tooltip */
.lp-card {
  position: relative;
}
.lp-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #1e2028;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none;
}
.lp-card:hover .lp-tooltip {
  display: block;
}
.lp-tooltip-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.lp-tooltip ol {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.lp-tooltip li {
  font-size: 0.75rem;
  color: var(--text-primary);
  line-height: 1.4;
}

/* STAR Story Modal */
#star-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#star-modal {
  background: #17191e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  width: 90%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}
#star-modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
#star-modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
#star-modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  flex: 1;
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-secondary);
}
#star-modal-body strong, #star-modal-body b {
  color: var(--accent-color);
}
#star-modal-lp-tags {
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.lp-tag-chip {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  color: var(--accent-color);
  cursor: pointer;
  transition: background 0.15s;
}
.lp-tag-chip:hover { background: rgba(99,102,241,0.3); }

/* Live recording pulse */
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%       { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
.recording-pulse {
  animation: mic-pulse 1.2s ease-in-out infinite;
  border-radius: 8px;
}
/* Live transcript preview bubble */
#live-transcript-preview {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 10px;
  font-size: 0.875rem;
  line-height: 1.6;
  min-height: 2.5rem;
  max-height: 120px;
  overflow-y: auto;
  word-break: break-word;
}
