/* Personal Trader — own CSS only. Never import WAVE369. */
:root {
  --bg: #0a0e18;
  --header: #0d1424;
  --tile: #101726;
  --line: rgba(130, 160, 220, 0.28);
  --accent: #5ee0c5;
  --accent-soft: rgba(94, 224, 197, 0.14);
  --text: #e8eefc;
  --muted: #8b9bb8;
  --danger: #ff7b8a;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --header-h: 48px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; width: 100%; height: 100%; overflow: hidden;
  color: var(--text); font-family: var(--font);
}
html {
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(6,10,18,0.42) 0%, rgba(6,10,18,0.28) 40%, rgba(6,10,18,0.45) 100%),
    url("./background.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
body {
  display: flex; flex-direction: column;
  background: transparent;
}

.header {
  position: relative; z-index: 50;
  height: var(--header-h); flex: 0 0 var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; background: rgba(13, 20, 36, 0.82); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), #6aa8ff);
  box-shadow: 0 0 12px rgba(94, 224, 197, 0.45);
}
.title { font-size: 0.95rem; font-weight: 600; letter-spacing: 0.03em; }
.build { color: var(--muted); font-size: 0.65rem; opacity: 0.7; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: inherit; font-size: 0.85rem; line-height: 1;
  min-width: 28px; height: 28px; padding: 0 10px; border-radius: 8px; cursor: pointer;
}
.chip:hover, .chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }
body[data-mode="view"] .edit-only { display: none !important; }

.board {
  position: relative; flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column; background: transparent;
}
.pt-row-shell {
  position: relative; width: 100%; min-height: 80px;
  display: flex; flex-direction: column; background: transparent;
}
.pt-row {
  position: relative; flex: 1 1 auto; min-height: 0; display: grid; width: 100%;
  gap: 0; column-gap: 0; row-gap: 0; background: transparent;
  grid-template-rows: 1fr;
  grid-auto-rows: 0;
  overflow: hidden;
}
/* Row gutter: zero flow space so tiles flush; handle overlays the join */
.pt-row-rez {
  flex: 0 0 0; height: 0; margin: 0; padding: 0;
  position: relative; z-index: 8;
  cursor: row-resize; background: transparent;
  overflow: visible;
}
.pt-row-rez::before {
  content: "";
  position: absolute; left: 0; right: 0; top: -3px; height: 6px;
  background: transparent;
  transition: background 0.12s;
}
.pt-row-rez:hover::before, .pt-row-rez.is-active::before {
  background: rgba(94, 224, 197, 0.55);
}
body[data-mode="view"] .pt-row-rez,
body[data-mode="view"] .pt-col-rez { display: none !important; }

.pt-tile {
  position: relative; min-width: 0; min-height: 0; margin: 0;
  grid-row: 1;
  border: 1px solid var(--line);
  overflow: visible; display: flex; flex-direction: column; user-select: none;
  background: rgba(16, 23, 38, var(--pt-alpha, 0.9));
}
.pt-tile.is-glass {
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-color: rgba(160, 190, 255, 0.22);
}
.pt-tile.is-selected { box-shadow: inset 0 0 0 2px rgba(94, 224, 197, 0.55); }
.pt-tile.is-dragging { opacity: 0.4; z-index: 5; }
/* Leave grid flow while dragging so the row stays one intact track with a real empty slot */
.pt-tile.is-drag-source { display: none !important; }
.pt-tile.is-drop-target {
  box-shadow: inset 0 0 0 2px var(--accent); border-color: var(--accent);
}

.pt-tile-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; padding-left: 36px; padding-right: 40px;
  min-height: 26px;
  background: rgba(0,0,0,0.14);
  border-bottom: 1px solid rgba(130,160,220,0.10);
  cursor: grab; touch-action: none;
}
body[data-mode="view"] .pt-tile-bar { display: none !important; }
.pt-tile-bar:active, .pt-tile-bar.is-grabbing { cursor: grabbing; }
.pt-grip {
  width: 18px; height: 16px; flex: 0 0 auto; opacity: 0.55; cursor: grab; position: relative; z-index: 2;
  background:
    radial-gradient(circle, var(--muted) 1.3px, transparent 1.5px) 0 0 / 7px 7px,
    radial-gradient(circle, var(--muted) 1.3px, transparent 1.5px) 0 3.5px / 7px 7px;
}
.pt-grip.is-hot { opacity: 1; outline: 1px solid var(--accent); border-radius: 3px; }
.pt-widget-select, .pt-span-select {
  appearance: none; border: 1px solid transparent; background: rgba(12, 18, 32, 0.85);
  color: var(--text); font: inherit; font-size: 0.75rem; padding: 2px 6px;
  border-radius: 6px; cursor: pointer;
}
.pt-widget-select option, .pt-span-select option,
.pt-pop select option {
  background: #121a2c; color: #e8eefc;
}
.pt-widget-select { flex: 1 1 auto; min-width: 0; max-width: 42%; }
.pt-span-select { flex: 0 0 auto; color: var(--muted); border-color: var(--line); }
.pt-widget-select:hover, .pt-widget-select:focus,
.pt-span-select:hover, .pt-span-select:focus {
  border-color: var(--line); background: rgba(255,255,255,0.03);
  outline: none; color: var(--text);
}
.pt-gear {
  position: absolute; top: 4px; right: 4px; z-index: 12;
  width: 18px; height: 18px; padding: 0; border-radius: 5px;
  border: 1px solid transparent; background: rgba(0,0,0,0.2);
  color: var(--muted); cursor: pointer; font-size: 0.7rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.28; transition: opacity 0.12s, border-color 0.12s, background 0.12s;
}
.pt-tile:hover .pt-gear, .pt-gear.is-open { opacity: 0.9; border-color: var(--line); background: rgba(0,0,0,0.35); }
body[data-mode="view"] .pt-gear {
  opacity: 0.22; width: 16px; height: 16px; font-size: 0.62rem; top: 3px; right: 3px;
}
body[data-mode="view"] .pt-tile:hover .pt-gear { opacity: 0.75; }

.pt-body {
  flex: 1 1 auto; min-height: 0; display: flex; align-items: stretch; justify-content: stretch;
  padding: 10px; color: var(--muted); font-size: 0.9rem; letter-spacing: 0.02em;
  pointer-events: auto; cursor: default; overflow: auto;
}
body[data-mode="edit"] .pt-body { cursor: pointer; }
body[data-mode="edit"] .pt-body .pt-settings-controls,
body[data-mode="edit"] .pt-body button,
body[data-mode="edit"] .pt-body input,
body[data-mode="edit"] .pt-body select { cursor: pointer; }

/* Col gutter: absolute overlay on the join — no see-through channel */
.pt-col-rez {
  position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px;
  cursor: col-resize; z-index: 6; background: transparent;
  grid-column: unset; grid-row: unset;
}
.pt-col-rez::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 2px; width: 2px;
  background: transparent;
  transition: background 0.12s, width 0.12s, left 0.12s;
}
.pt-col-rez:hover::before, .pt-col-rez.is-active::before {
  background: rgba(94, 224, 197, 0.7);
  width: 3px; left: 1.5px;
}

.pt-ghost {
  position: fixed; z-index: 100; pointer-events: none; opacity: 0.9;
  border: 2px solid var(--accent); border-radius: 8px;
  background: rgba(16,23,38,0.94); box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.8rem; padding: 8px; min-width: 100px; height: 44px;
}

/* Empty-slot drop targets (edit drag) */
.pt-drop-slot {
  position: absolute; top: 0; bottom: 0; z-index: 4;
  pointer-events: auto;
  border: 1px dashed rgba(94, 224, 197, 0.28);
  background: rgba(94, 224, 197, 0.06);
  border-radius: 4px;
  box-sizing: border-box;
  grid-column: unset; grid-row: unset;
}
/* Board-level strip: drop here to append a new row at the bottom */
.pt-drop-slot.pt-drop-new-row {
  position: relative; left: auto; top: auto; bottom: auto;
  flex: 0 0 40px; height: 40px; width: auto; margin: 6px 8px 10px;
  z-index: 4;
}
.pt-drop-slot.is-hot {
  border-color: var(--accent);
  background: rgba(94, 224, 197, 0.16);
  box-shadow: inset 0 0 0 1px rgba(94, 224, 197, 0.35);
}

/* Settings popover */
.pt-pop {
  position: absolute; top: 26px; right: 4px; z-index: 30;
  width: 220px; padding: 10px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(12, 18, 32, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
  display: none; flex-direction: column; gap: 8px;
}
.pt-pop.is-open { display: flex; }
.pt-pop-remove {
  margin-top: 6px;
  appearance: none; width: 100%; margin: 0 0 2px;
  border: 1px solid rgba(255,123,138,0.4);
  background: rgba(255,123,138,0.12);
  color: #ff9aa5; font: inherit; font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.02em; line-height: 1.2;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: center;
}
.pt-pop-remove:hover {
  background: rgba(255,123,138,0.22);
  border-color: rgba(255,123,138,0.6);
  color: #ffc0c6;
}
.pt-pop label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 0.72rem; color: var(--muted);
}
.pt-pop label > span:first-child { flex: 0 0 auto; }
.pt-pop select, .pt-pop input[type="range"] {
  width: 100%; accent-color: var(--accent);
}
.pt-pop select {
  appearance: none; margin-top: 4px;
  background: #121a2c; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 0.75rem;
}
.pt-pop .row { display: flex; flex-direction: column; gap: 4px; }
.pt-pop .switch {
  appearance: none; width: 34px; height: 18px; border-radius: 999px;
  background: rgba(255,255,255,0.12); border: 1px solid var(--line);
  position: relative; cursor: pointer; flex: 0 0 auto;
}
.pt-pop .switch::after {
  content: ""; position: absolute; top: 1px; left: 1px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}
.pt-pop .switch.is-on { background: rgba(94, 224, 197, 0.25); border-color: var(--accent); }
.pt-pop .switch.is-on::after { transform: translateX(16px); background: var(--accent); }
.pt-pop .val { font-variant-numeric: tabular-nums; color: var(--text); min-width: 2.5em; text-align: right; }

/* Hover radial — Remove + Settings (edit mode) */
.pt-radial-root {
  position: fixed; inset: 0; z-index: 200; pointer-events: none;
}
.pt-radial-root.is-open { pointer-events: none; }
.pt-radial-root.is-open .pt-radial { pointer-events: auto; }
body[data-mode="view"] .pt-radial-root { display: none !important; }
.pt-radial {
  position: absolute; width: 0; height: 0; transform: translate(-50%, -50%);
  pointer-events: none;
}
.pt-radial-hub {
  position: absolute; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: rgba(13, 20, 36, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  opacity: 0; transform: scale(0.5);
  transition: opacity 0.14s ease, transform 0.16s ease;
  pointer-events: none;
}
.pt-radial-root.is-open .pt-radial-hub { opacity: 1; transform: scale(1); }
.pt-radial-item {
  position: absolute; left: 50%; top: 50%;
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; border: 1px solid var(--line);
  background: rgba(16, 23, 38, 0.96); color: var(--text);
  font: inherit; font-size: 0.85rem; line-height: 1;
  cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  opacity: 0; transform: translate(0,0) scale(0.5);
  transition: opacity 0.14s ease, transform 0.16s ease, border-color 0.12s, background 0.12s, color 0.12s;
}
.pt-radial-root.is-open .pt-radial-item { opacity: 1; }
.pt-radial-root.is-open .pt-radial-item[data-act="settings"] {
  transform: translate(-28px, -4px) scale(1);
}
.pt-radial-root.is-open .pt-radial-item[data-act="remove"] {
  transform: translate(28px, -4px) scale(1);
}
.pt-radial-item:hover {
  border-color: var(--accent); background: rgba(20, 36, 48, 0.98); color: var(--accent);
}
.pt-radial-item.pt-radial-remove:hover {
  border-color: var(--danger); color: #ff9aa5; background: rgba(40, 16, 22, 0.96);
}

/* ——— Widget placeholder panels ——— */
.pt-panel {
  width: 100%; display: flex; flex-direction: column; gap: 8px;
  padding: 4px 2px; min-height: 0; text-align: left; letter-spacing: 0;
  cursor: inherit;
}
.pt-panel-title {
  font-size: 0.85rem; font-weight: 600; color: var(--accent);
  letter-spacing: 0.04em;
}
.pt-panel-desc {
  font-size: 0.72rem; color: var(--muted); line-height: 1.35;
}
.pt-panel-note {
  font-size: 0.65rem; color: rgba(139, 155, 184, 0.75);
  font-style: italic; margin-top: 2px;
}
.pt-list {
  display: flex; flex-direction: column; gap: 4px; margin-top: 4px;
  min-height: 0; overflow: auto;
}
.pt-list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  background: #121a2c;
  color: #e8eefc;
  border: 1px solid rgba(130, 160, 220, 0.18);
  font-size: 0.72rem; line-height: 1.3;
}
.pt-list-row:nth-child(even) {
  background: rgba(18, 26, 44, 0.85);
}
.pt-list-row .pt-list-main { flex: 1 1 auto; min-width: 0; color: #e8eefc; }
.pt-list-row .pt-list-meta { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Settings widget global controls */
.pt-settings-controls {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.pt-settings-controls .chip {
  background: rgba(18, 26, 44, 0.95); color: var(--text);
}
.pt-settings-placeholder {
  margin-top: 6px; font-size: 0.7rem; color: var(--muted);
}
