:root {
  color-scheme: dark;
  --page: #0b0d10;
  --surface: #11151b;
  --surface-2: #171d24;
  --surface-3: #202832;
  --line: #2b3542;
  --line-strong: #3c4a5b;
  --muted: #91a0b3;
  --text: #f4f7fb;
  --accent: #17e875;
  --data: #f5e95b;
  --brand-logo: #d7ff00;
  --cyan: #64d2ff;
  --danger: #ff5a76;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 34%),
    var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 100vh;
}

.workspace {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.topbar,
.stage-header,
.controls-header,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  min-height: 46px;
}

.eyebrow,
.section-label {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1;
}

h2 {
  font-size: 18px;
  line-height: 1.15;
}

h3 {
  font-size: 13px;
  line-height: 1.2;
}

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

.ghost-button,
.primary-button,
.segment,
.layer-pill {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #10151b;
  color: var(--text);
  cursor: pointer;
  font-weight: 760;
}

.ghost-button,
.primary-button {
  padding: 0 14px;
}

.ghost-button:hover,
.segment:hover,
.layer-pill:hover {
  border-color: var(--line-strong);
  background: #151b23;
}

.primary-button {
  border-color: rgba(23, 232, 117, 0.72);
  background: rgba(23, 232, 117, 0.16);
  color: #dbffe9;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.panel-action {
  width: 100%;
}

.stage-panel {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stage-header strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.canvas-size {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  padding: 7px 9px;
  white-space: nowrap;
}

.stage-wrap {
  display: grid;
  min-height: 0;
  place-items: center;
}

.card-preview {
  position: relative;
  container-type: inline-size;
  width: min(100%, 1080px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #07100a;
  box-shadow:
    0 18px 56px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  user-select: none;
}

.card-preview.has-custom-bg {
  cursor: grab;
}

.card-preview.bg-moving {
  cursor: grabbing;
}

.card-preview:not(.loaded) .drag-layer {
  display: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  gap: 8px;
  background:
    linear-gradient(135deg, rgba(17, 21, 27, 0.8), rgba(11, 13, 16, 0.88)),
    var(--surface);
  color: var(--text);
  text-align: center;
}

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

.empty-state span {
  color: var(--muted);
  font-size: 13px;
}

.card-preview.loaded .empty-state {
  display: none;
}

.card-bg,
.card-vignette,
.card-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-bg {
  background:
    linear-gradient(90deg, rgba(7, 13, 8, 0.06), rgba(2, 4, 3, 0.44)),
    url("/card/assets/pnl-card-bg.svg") center / cover no-repeat;
  filter: saturate(1.08) brightness(0.78);
  transform: scale(1.01);
}

.card-vignette {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.58)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.6));
}

.card-grid {
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
}

.drag-layer {
  position: absolute;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  touch-action: none;
  cursor: grab;
}

.drag-layer:active {
  cursor: grabbing;
}

.drag-layer.selected {
  outline: 1px solid rgba(100, 210, 255, 0.95);
  outline-offset: 8px;
}

.drag-layer.hidden {
  display: none;
}

.text-layer,
.metric-layer {
  color: #fff;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, 0.38),
    0 0 24px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}

.avatar-layer {
  left: 47%;
  top: 2.6%;
  width: 6.5cqw;
  height: 6.5cqw;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 1.8cqw;
  background: #f8f8f0;
  box-shadow: 0 0 24px rgba(23, 232, 117, 0.34);
}

.avatar-layer img {
  width: 100%;
  height: 100%;
  border-radius: 1.4cqw;
  object-fit: cover;
}

.ticker-layer {
  left: 63%;
  top: 18%;
  color: #fff;
  font-size: 7.1cqw;
  font-weight: 950;
  line-height: 0.9;
}

.signal-layer {
  left: 63.5%;
  top: 33.5%;
  color: #f8f8f0;
  font-size: 3.1cqw;
  font-weight: 700;
}

.entry-layer {
  left: 64%;
  top: 62%;
}

.ath-layer {
  left: 64%;
  top: 68%;
}

.metric-layer {
  gap: 12px;
  color: #fff;
  font-size: 2.55cqw;
  font-weight: 800;
}

.metric-label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.62em;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-value {
  color: var(--data);
}

.pnl-layer {
  left: 52.5%;
  top: 42.3%;
  color: var(--accent);
  font-size: 11.4cqw;
  font-weight: 1000;
  line-height: 0.82;
  text-shadow:
    0 5px 0 rgba(0, 80, 22, 0.9),
    0 0 18px rgba(0, 255, 72, 0.74);
}

.author-layer {
  left: 64%;
  top: 77.2%;
  color: #fff;
  font-size: 3.15cqw;
  font-weight: 950;
}

.chart-layer {
  left: 7.5%;
  top: 61.5%;
  width: 53cqw;
  height: 19.4cqw;
  color: var(--accent);
  border-radius: 8px;
}

.chart-layer svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 12px rgba(23, 232, 117, 0.3));
}

.chart-area {
  fill: url("#chartFill");
}

.chart-line {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 6;
}

.signal-line {
  stroke: rgba(255, 255, 255, 0.48);
  stroke-dasharray: 8 9;
  stroke-width: 2;
}

.signal-dot,
.current-dot {
  fill: #fff;
  stroke: currentColor;
  stroke-width: 5;
}

.chart-tag {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(3, 8, 5, 0.76);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  padding: 6px 8px;
  text-transform: uppercase;
}

.chart-tag-signal {
  left: 118px;
  top: 72px;
}

.chart-tag-now {
  right: 0;
  top: 3px;
}

.brand-logo-watermark {
  position: absolute;
  z-index: 5;
  top: 3.2%;
  left: 3.2%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5.5cqw;
  height: 5.5cqw;
  max-width: 66px;
  max-height: 66px;
  min-width: 42px;
  min-height: 42px;
  pointer-events: none;
}

.brand-logo-mark {
  width: 100%;
  height: 100%;
  background: var(--brand-logo);
  -webkit-mask: url("/card/assets/panoptiq-icon.png") center / contain no-repeat;
  mask: url("/card/assets/panoptiq-icon.png") center / contain no-repeat;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.48));
}

.brand-handle-watermark {
  position: absolute;
  right: 3.2%;
  bottom: 3.6%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(3, 8, 5, 0.42);
  color: rgba(255, 255, 255, 0.84);
  padding: 6px 10px 6px 7px;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.56);
}

.brand-telegram {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #2aabee;
}

.brand-telegram svg {
  width: 72%;
  height: 72%;
  fill: #fff;
  transform: translateX(-4%);
}

.brand-handle {
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

.layer-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.layer-pill {
  min-width: 76px;
  padding: 0 11px;
}

.layer-pill.active {
  border-color: rgba(100, 210, 255, 0.8);
  background: rgba(100, 210, 255, 0.12);
  color: #dff5ff;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #0e1217;
  padding: 22px;
}

.controls-header {
  min-height: 46px;
}

.panel {
  display: grid;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
}

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

input[type="text"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 11px;
}

input[type="text"]:focus {
  border-color: rgba(100, 210, 255, 0.72);
}

input[type="color"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  padding: 4px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.selected-name {
  border: 1px solid rgba(100, 210, 255, 0.42);
  border-radius: 7px;
  background: rgba(100, 210, 255, 0.08);
  color: #dff5ff;
  font-size: 13px;
  font-weight: 850;
  padding: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segment {
  height: 38px;
}

.segment.active {
  border-color: rgba(23, 232, 117, 0.72);
  background: rgba(23, 232, 117, 0.12);
  color: #dfffe9;
}

.upload-grid,
.layer-toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.file-control {
  min-width: 0;
}

.file-control span {
  color: var(--muted);
}

.file-control input {
  width: 100%;
  min-width: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 9px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 9px;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: auto;
  }

  .controls {
    min-height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 680px) {
  .workspace,
  .controls {
    padding: 14px;
  }

  .topbar,
  .stage-header,
  .controls-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .stage-panel {
    padding: 10px;
  }

  .layer-pill {
    flex: 1 1 88px;
  }

  .upload-grid,
  .layer-toggle-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }
}
