/* ===== Design Tokens ===== */
:root {
  --bg:       #f5f3ee;
  --bg2:      #ece9e0;
  --surface:  #ffffff;
  --border:   #d6d1c4;
  --border2:  #b8b2a4;
  --text:     #1a1a1a;
  --text2:    #5a5a5a;
  --text3:    #9a9a9a;
  --accent:   #3b6ea5;
  --accent-h: #2d5482;
  --good:     #2e7d32;
  --error:    #c62828;
  --radius:   6px;
  --pad:      16px;
  --mono:     "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

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

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-shrink: 0;
}

header h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

header span {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.06em;
}

/* ===== Layout ===== */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ===== Left Panel ===== */
.panel-left {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.section {
  padding: var(--pad);
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ===== Chart Type Buttons ===== */
.chart-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.chart-type-btn {
  padding: 8px 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
  transition: all 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.chart-type-btn .icon {
  font-size: 18px;
  line-height: 1;
}

.chart-type-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #eef3fa;
}

.chart-type-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* ===== Title Input ===== */
.text-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  transition: border-color 0.12s;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== Palette Radio ===== */
.palette-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.palette-item input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.palette-swatches {
  display: flex;
  gap: 3px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.1);
}

.palette-name {
  font-size: 12px;
  color: var(--text2);
}

/* ===== Data Editor ===== */
.data-textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.12s;
}

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

.data-textarea.error {
  border-color: var(--error);
}

.error-msg {
  margin-top: 6px;
  font-size: 11px;
  color: var(--error);
  line-height: 1.5;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ===== Buttons ===== */
.btn {
  padding: 7px 14px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  flex: 1;
}

.btn-primary:hover {
  background: var(--accent-h);
  border-color: var(--accent-h);
  color: #fff;
}

/* ===== Right Panel ===== */
.panel-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
}

/* ===== Chart Sub-panel ===== */
.panel-chart {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.canvas-wrap {
  flex: 1;
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.chart-container {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chart-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chart-info {
  font-size: 11px;
  color: var(--text3);
}

/* ===== Code Sub-panel ===== */
.panel-code {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #1e1e2e;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: #181825;
  border-bottom: 1px solid #313244;
  flex-shrink: 0;
}

.code-header-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6c7086;
}

.btn-copy {
  padding: 3px 10px;
  border: 1px solid #45475a;
  border-radius: 4px;
  background: transparent;
  color: #a6adc8;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.12s;
}

.btn-copy:hover {
  border-color: #89b4fa;
  color: #89b4fa;
}

.btn-copy.copied {
  border-color: #a6e3a1;
  color: #a6e3a1;
}

.code-block {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.75;
  color: #cdd6f4;
  white-space: pre;
  tab-size: 2;
}

/* Syntax-like token colors */
.tok-tag   { color: #89dceb; }
.tok-attr  { color: #89b4fa; }
.tok-str   { color: #a6e3a1; }
.tok-key   { color: #89b4fa; }
.tok-num   { color: #fab387; }
.tok-bool  { color: #cba6f7; }
.tok-cmt   { color: #6c7086; font-style: italic; }

/* ===== Resizer ===== */
.resizer {
  width: 5px;
  flex-shrink: 0;
  background: var(--border);
  cursor: col-resize;
  position: relative;
  transition: background 0.15s;
  z-index: 10;
}

.resizer:hover,
.resizer.dragging {
  background: var(--accent);
}

.resizer::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
  height: 32px;
  border-left: 1px dotted rgba(255,255,255,0.6);
  pointer-events: none;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .panel-right { flex-direction: column; }
  .resizer { width: 100%; height: 5px; cursor: row-resize; }
  .resizer::after { width: 32px; height: 1px; border-left: none; border-top: 1px dotted rgba(0,0,0,0.3); }
  .panel-code { width: 100% !important; height: 240px; border-top: 1px solid #313244; }
}

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .panel-left { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
}
