:root {
  --primary: #27282A;
  --primary-hover: #01011B;
  --primary-active: #01011B;
  --bg: #f5f5f5;
  --card: #ffffff;
  --border: #e0e0e0;
  --border-inner: #f0f0f0;
  --text-primary: #111111;
  --text-secondary: #555555;
  --sidebar-width: 220px;
  --header-height: 52px;
  --tabbar-height: 36px;
}

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

html, body {
  width: 780px;
  height: 560px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13px;
}

#app {
  display: flex;
  flex-direction: column;
  width: 780px;
  height: 560px;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────── */
#header {
  height: var(--header-height);
  background: #2c2c2c;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#back-btn {
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin: -8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  transition: background 0.15s;
}
#back-btn:hover { background: rgba(255,255,255,0.12); }

#header-text {
  flex: 1;
}

#header h1 {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
}

#header p {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin: 0;
}

/* ── Tab Bar ─────────────────────────────────────── */
#tab-bar {
  height: var(--tabbar-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ── Body ────────────────────────────────────────── */
#body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.card-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
}

/* Input card */
#input-card {
  display: flex;
  flex-direction: column;
}

#start-input-sequence,
#start-input-cycle,
#range-input-histogram,
#range-input-heatmap,
#range-input-growth {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

#start-input-sequence:focus,
#start-input-cycle:focus,
#range-input-histogram:focus,
#range-input-heatmap:focus,
#range-input-growth:focus {
  border-color: var(--primary);
}


.tab-input {
  display: none;
}

#generate-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0;
}

#generate-btn:hover {
  background: var(--primary-hover);
}

#generate-btn:active {
  background: var(--primary-active);
}

/* Collapsible cards */
.collapsible-card {
  padding: 0;
}

.collapsible-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 12px;
  gap: 6px;
}

.collapsible-header .card-label {
  margin: 0;
}

.chevron {
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.collapsible-header[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.collapsible-body {
  padding: 0 12px 10px;
}

.collapsible-body.hidden {
  display: none;
}

/* Stat rows */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-inner);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row span:first-child {
  color: var(--text-secondary);
}

.stat-row span:last-child {
  color: var(--text-primary);
  font-weight: 600;
}

/* Sequence text */
#sequence-display {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.7;
  word-break: break-all;
  max-height: 90px;
  overflow-y: auto;
  margin: 0;
}

/* ── Main / Views ────────────────────────────────── */
#main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  padding: 10px;
}

.view {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  padding: 10px;
}

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

/* Chart canvases fill their view */
.view > canvas {
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/* Heatmap wrapper is scrollable; canvas draws at full height inside */
#view-heatmap {
  padding: 10px;
  overflow: hidden;
}

#heatmap-wrapper {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

#chart-heatmap {
  display: block;
  width: 100%;
}

/* Cycle canvas */
#chart-cycle {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

/* Responsive: stretch to fill viewport on any screen larger than the base size */
@media screen and (min-width: 600px) {
  html, body {
    width: 100%;
    height: 100vh;
  }
  #app {
    width: 100%;
    height: 100vh;
  }
}

/* Narrow screens: stack sidebar above chart */
@media screen and (max-width: 599px) {
  html, body {
    width: 100%;
    height: auto;
    overflow: auto;
  }
  #app {
    width: 100%;
    height: auto;
    overflow: visible;
  }
  #body {
    flex-direction: column;
  }
  #sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  #main {
    position: relative;
    flex: none;
    height: 320px;
  }
}
