:root {
  color-scheme: light;
  --ink: #1a1b18;
  --muted: #6c6f68;
  --paper: #f3f0e8;
  --panel: #fffdf7;
  --line: #d6d0c2;
  --charcoal: #161714;
  --charcoal-soft: #24261f;
  --green: #15a46e;
  --green-soft: rgba(21, 164, 110, 0.16);
  --red: #cf3f3f;
  --red-soft: rgba(207, 63, 63, 0.15);
  --amber: #b7791f;
  --cyan: #14809a;
  --shadow: 0 18px 42px rgba(24, 24, 20, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Tahoma, "Noto Sans Thai", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 14px 22px;
  background: var(--charcoal);
  color: #fffaf0;
  border-bottom: 1px solid #33352d;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(3, 6px);
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 6px;
  border: 1px solid rgba(255, 250, 240, 0.28);
  border-radius: 8px;
}

.brand-mark span {
  display: block;
  width: 6px;
  background: #e7e0cf;
}

.brand-mark span:nth-child(1) {
  height: 10px;
}

.brand-mark span:nth-child(2) {
  height: 19px;
  background: var(--green);
}

.brand-mark span:nth-child(3) {
  height: 14px;
  background: var(--red);
}

.brand h1,
.brand p,
.section-title h2,
.signal-head h2,
.trade-plan h3 {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
  line-height: 1.15;
}

.brand p {
  margin-top: 2px;
  color: #cac1ae;
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.tool-button {
  gap: 8px;
  min-height: 40px;
  padding: 0 13px;
  background: #fff8e8;
  color: #1d1e1a;
  font-weight: 700;
}

.tool-button:hover {
  background: #fff2d2;
}

.tool-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  height: calc(100vh - 72px);
  min-height: 620px;
  padding: 18px;
}

.chart-panel,
.side-panel {
  min-width: 0;
}

.chart-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
}

.canvas-shell {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    #11130f;
  background-size: 40px 40px;
  border: 1px solid #2d3128;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.canvas-shell.dragging {
  outline: 3px solid rgba(20, 128, 154, 0.36);
  outline-offset: -6px;
}

#chartCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  pointer-events: none;
  color: #fff8ea;
}

.empty-state strong {
  font-size: 24px;
}

.empty-state span {
  color: #c9c1b1;
  font-size: 13px;
}

.empty-state.hidden {
  display: none;
}

.chart-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.side-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.settings-panel,
.signal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-panel {
  padding: 15px;
}

.signal-panel {
  overflow: auto;
  padding: 16px;
}

.section-title,
.signal-head,
.zone-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  font-size: 16px;
}

.icon-button {
  width: 34px;
  height: 34px;
  background: #f0eadc;
  color: var(--ink);
}

.icon-button:hover {
  background: #e6decd;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfc7b7;
  border-radius: 7px;
  padding: 8px 10px;
  background: #fffaf0;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(20, 128, 154, 0.14);
}

.target-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.target-row span {
  display: grid;
  min-height: 32px;
  place-items: center;
  border: 1px solid #e0d6c4;
  border-radius: 7px;
  background: #f8f1e2;
  color: #453f34;
  font-size: 12px;
  font-weight: 800;
}

.signal-head {
  align-items: flex-start;
}

.eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

#biasTitle {
  font-size: 25px;
  line-height: 1.2;
}

.score-badge {
  display: inline-grid;
  min-width: 58px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #eee7d8;
  color: var(--ink);
  font-weight: 900;
}

.score-badge.buy {
  background: var(--green-soft);
  color: #08734a;
}

.score-badge.sell {
  background: var(--red-soft);
  color: #9b2828;
}

.score-badge.wait {
  background: rgba(183, 121, 31, 0.15);
  color: #85550f;
}

.structure-list {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.structure-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #ece3d4;
}

.structure-row span:first-child {
  color: var(--muted);
  font-size: 13px;
}

.structure-row span:last-child {
  text-align: right;
  font-weight: 800;
}

.placeholder-line {
  width: 100%;
  height: 37px;
  border-radius: 7px;
  background: linear-gradient(90deg, #eee7db, #f8f2e7, #eee7db);
}

.placeholder-line.short {
  width: 72%;
}

.zone-stack {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.zone-card {
  padding: 12px;
  border: 1px solid #e1d8c7;
  border-radius: 8px;
  background: #fff9ed;
}

.zone-card.demand {
  border-color: rgba(21, 164, 110, 0.35);
  background: rgba(21, 164, 110, 0.08);
}

.zone-card.supply {
  border-color: rgba(207, 63, 63, 0.34);
  background: rgba(207, 63, 63, 0.08);
}

.zone-card strong {
  font-size: 14px;
}

.zone-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.zone-card p {
  margin: 8px 0 0;
  color: #47443c;
  font-size: 13px;
  line-height: 1.45;
}

.trade-plan {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid #e7dece;
}

.trade-plan h3 {
  font-size: 16px;
}

.trade-plan p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.level {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 7px;
  background: #f2ebdd;
}

.level span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.level strong {
  font-size: 14px;
}

.level.stop {
  background: var(--red-soft);
}

.level.take {
  background: var(--green-soft);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .canvas-shell {
    height: 58vh;
  }

  .side-panel {
    overflow: visible;
  }

  .signal-panel {
    overflow: visible;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .top-actions {
    justify-content: stretch;
  }

  .tool-button {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 10px;
  }

  .workspace {
    padding: 10px;
  }

  .field-grid,
  .levels {
    grid-template-columns: 1fr;
  }

  .target-row {
    grid-template-columns: 1fr 1fr;
  }
}
