* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f2f2f5;
}

/* App container (desktop-first) */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: #ffffff;
}

/* Top bar */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #ddd;
  background: #f7f7f7;
  gap: 0.75rem;
}

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

.top-left label {
  font-weight: 500;
}

#ticker {
  width: 120px;
  padding: 0.3rem 0.4rem;
}

#run-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 3px;
  border: 1px solid #0053d6;
  background: #0b63ff;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

#run-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.model-label {
  font-weight: 500;
}

/* Disclaimer banner */

.disclaimer {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  text-align: center;
  background: #fff7e6;
  color: #663c00;
  border-bottom: 1px solid #f0d38a;
}

.disclaimer strong {
  font-weight: 600;
}

/* Main layout (desktop) */

.main-layout {
  flex: 1 1 auto;
  display: flex;
  padding: 0.5rem;
  gap: 0.75rem;
  min-height: 0;
  background: #f2f2f5;
}

.chart-section {
  flex: 3 1 0;
  min-width: 0;
  min-height: 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #ffffff;
  padding: 0.5rem;
  display: flex;
}

#chart {
  width: 100%;
  height: 100%;
}

.side-panels {
  flex: 1 0 280px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  min-height: 0;
}

.panel {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
}

.metrics-panel {
  flex: 0 0 150px;
  overflow: auto;
}

.payload-panel {
  flex: 1 1 auto;
  min-height: 0;
}

.payload-panel pre {
  flex: 1 1 auto;
  overflow-y: auto;
}

pre {
  margin: 0;
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* -----------------------
   Mobile / small screens
   ----------------------- */

@media (max-width: 768px) {
  body {
    background: #ffffff;
    font-size: 14px;
  }

  #app {
    max-width: 100%;
    height: auto;
    min-height: 100%;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .top-left {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  #ticker {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }

  #run-btn {
    flex-shrink: 0;
  }

  .top-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .disclaimer {
    font-size: 0.75rem;
    text-align: left;
  }

  .main-layout {
    flex-direction: column;
    padding: 0.5rem 0.5rem 0.75rem;
  }

  .chart-section {
    flex: 0 0 auto;
    width: 100%;
    height: 420px;          /* taller chart on phone */
    padding: 0.4rem;
  }

  #chart {
    height: 100%;
    min-height: 380px;
  }

  .side-panels {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }

  .panel {
    max-height: 220px;
  }

  .metrics-panel,
  .payload-panel {
    flex: 0 0 auto;
  }
}
