/* ========== GLOBAL ========== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-subtle: rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 2px 6px rgba(15, 23, 42, 0.06);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --neutral-soft: #e5e7eb;
  --danger-soft: #fee2e2;
  --danger-strong: #b91c1c;
  --chip-bg: #f3f4f6;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
}

p {
  margin: 0 0 0.35rem;
}

/* ========== HEADER ========== */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
}
.app-header-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.app-title-block {
  max-width: 640px;
}
.app-title {
  font-size: 1.4rem;
}
.app-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ========== LAYOUT ========== */
.app-main {
  max-width: 1160px;
  margin: 1.25rem auto 2rem;
  padding: 0 1.25rem;
  display: flex;
  gap: 1.5rem;
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.panel-input {
  flex: 0 0 40%;
}
.panel-output {
  flex: 1;
}
.panel-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border-radius: 0.9rem;
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow-soft);
}
.card-title {
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
  margin-bottom: 0.7rem;
}
.form-row,
.filter-row {
  display: flex;
  gap: 0.75rem;
}
.form-row .form-group,
.filter-row .form-group {
  flex: 1;
}
label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
  color: #374151;
}
.text-input,
.textarea-input,
.select-input {
  width: 100%;
  font: inherit;
  border-radius: 0.6rem;
  border: 1px solid rgba(15, 23, 42, 0.15);
  padding: 0.45rem 0.55rem;
  background: #ffffff;
}
.textarea-input {
  resize: vertical;
}
.text-input:focus,
.textarea-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========== BUTTONS ========== */
.primary-button,
.secondary-button,
.ghost-button {
  font: inherit;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  white-space: nowrap;
}
.primary-button {
  background: var(--accent);
  color: #ffffff;
}
.primary-button:hover {
  background: var(--accent-strong);
}
.secondary-button {
  background: #e5e7eb;
  color: #111827;
}
.secondary-button:hover {
  background: #d4d4d8;
}
.ghost-button {
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #374151;
}
.ghost-button:hover {
  background: rgba(15, 23, 42, 0.03);
}
.form-footer {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.export-footer {
  justify-content: flex-start;
}
.file-button {
  position: relative;
}
.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ========== SUMMARY CARD ========== */
.card-summary {
  border-left: 3px solid #e5e7eb;
}
.summary-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.summary-project-name {
  font-size: 0.95rem;
  font-weight: 500;
}
.summary-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.summary-pill-neutral {
  background: var(--neutral-soft);
  color: #4b5563;
}
.summary-pill-good {
  background: #dcfce7;
  color: #166534;
}
.summary-pill-warning {
  background: #fef9c3;
  color: #854d0e;
}
.summary-pill-bad {
  background: var(--danger-soft);
  color: var(--danger-strong);
}
.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.summary-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.summary-stat-value {
  font-size: 1rem;
  font-weight: 600;
}
.summary-list {
  padding-left: 1.1rem;
  margin: 0;
  font-size: 0.85rem;
}

/* ========== ACCORDION (QUESTION VIEW) ========== */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.accordion-item {
  border-radius: 0.6rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f9fafb;
  overflow: hidden;
}
.accordion-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}
.accordion-title {
  font-size: 0.9rem;
  font-weight: 500;
}
.accordion-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.accordion-body {
  padding: 0.5rem 0.6rem 0.6rem;
  border-top: 1px solid rgba(15, 23, 42, 0.05);
  background: #ffffff;
}
.accordion-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.accordion-list {
  list-style: none;
  padding-left: 0;
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
}
.accordion-list li + li {
  margin-top: 0.18rem;
}

/* ========== TIMELINE ========== */
.timeline {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.timeline-item {
  position: relative;
  padding-left: 1.1rem;
  margin-bottom: 0.55rem;
  font-size: 0.8rem;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 0.2rem;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 999px;
  background: var(--accent);
}
.timeline-item::after {
  content: "";
  position: absolute;
  left: 0.49rem;
  top: 0.55rem;
  width: 1px;
  height: calc(100% - 0.55rem);
  background: rgba(15, 23, 42, 0.12);
}
.timeline-item:last-child::after {
  display: none;
}
.timeline-item-empty::before,
.timeline-item-empty::after {
  display: none;
}
.timeline-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.timeline-main {
  display: block;
  font-weight: 500;
}
.timeline-meta {
  display: block;
  color: var(--text-muted);
}

/* ========== EXPORT PREVIEW ========== */
.export-preview {
  margin-top: 0.6rem;
  font-size: 0.8rem;
}

/* ========== MISC ========== */
.placeholder-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== FOOTER ========== */
.app-footer {
  padding: 1rem 1.25rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 960px) {
  .app-main {
    flex-direction: column;
  }
  .panel-input,
  .panel-output {
    flex: 1 1 auto;
  }
}
@media (max-width: 720px) {
  .app-header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .form-row,
  .filter-row {
    flex-direction: column;
  }
  .summary-stats {
    gap: 0.5rem;
  }
}

/* ========== LABLEDGER COMPATIBILITY (existing markup hooks) ========== */

/* Map our <details>/<summary> structure to accordion styles */
.accordion-details summary.accordion-summary {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  list-style: none;
}
.accordion-summary::-webkit-details-marker {
  display: none;
}
.accordion-content {
  padding: 0.5rem 0.6rem 0.6rem;
  border-top: 1px solid rgba(15, 23, 42, 0.05);
  background: #ffffff;
}

/* Summary pill alias used by app.js */
.summary-pill-warn {
  background: #fef9c3;
  color: #854d0e;
}

/* Chips used for priority/status/outcome */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--neutral-soft);
  color: var(--text-main);
  font-size: 0.75rem;
  text-transform: capitalize;
}
.chip-priority-high { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.chip-priority-medium { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.chip-priority-low { background: #ecfeff; border-color: #bae6fd; color: #075985; }
.chip-status-active { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.chip-status-supported { background: #dcfce7; border-color: #86efac; color: #166534; }
.chip-status-refuted { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.chip-status-parked { background: #f3f4f6; border-color: #e5e7eb; color: #6b7280; }
.chip-outcome-positive { background: #dcfce7; border-color: #86efac; color: #166534; }
.chip-outcome-negative { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.chip-outcome-inconclusive { background: #fef9c3; border-color: #fde68a; color: #854d0e; }
.chip-outcome-pending { background: #f3f4f6; border-color: #e5e7eb; color: #6b7280; }

/* Question/Hypothesis/Experiment blocks used by renderer */
.question-header { display: grid; gap: 0.25rem; }
.question-title { font-weight: 600; }
.question-meta { color: var(--text-muted); font-size: 0.8rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.meta { color: var(--text-muted); }
.block { margin-top: 0.5rem; }
.block-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.25rem; }
.hypotheses-list { display: flex; flex-direction: column; gap: 0.4rem; }
.hypothesis-item { background: #ffffff; border: 1px solid var(--border-subtle); border-radius: 0.6rem; padding: 0.6rem; }
.hypothesis-header { display: grid; gap: 0.25rem; margin-bottom: 0.25rem; }
.hypothesis-title { font-weight: 600; }
.hypothesis-notes { color: var(--text-muted); }
.experiments-block { margin-top: 0.25rem; }
.experiments-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.experiment-item { background: #f9fafb; border: 1px solid var(--border-subtle); border-radius: 0.5rem; padding: 0.5rem; }
.experiment-main { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.experiment-title { font-weight: 500; }
.experiment-link { margin-top: 0.2rem; }
.experiment-summary { color: var(--text-muted); margin-top: 0.2rem; }
.decisions-block { margin-top: 0.4rem; }
.decisions-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.decision-item { background: #f9fafb; border: 1px solid var(--border-subtle); border-radius: 0.5rem; padding: 0.5rem; }
.decision-main { font-weight: 500; }
.decision-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; color: var(--text-muted); font-size: 0.8rem; margin-top: 0.2rem; }
.decision-reason { color: var(--text-muted); margin-top: 0.25rem; }

/* Timeline bits used by current renderer */
.timeline-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.timeline-target { font-weight: 600; color: var(--text-main); }
.timeline-body { color: var(--text-main); }
.timeline-reason { color: var(--text-muted); margin-top: 0.2rem; }
.timeline-footer { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }


