/* styles.css */
:root{
  --bg:#ffffff;
  --panel:#ffffff;
  --stroke:#0090f6;
  --strokeSoft: rgba(0,144,246,.22);
  --text:#0b1220;
  --muted: rgba(11,18,32,.72);
  --accent:#0090f6;
  --shadow: 0 10px 26px rgba(0,0,0,.08);
  --radius:14px;
  --gap:14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

*{box-sizing:border-box}
html,body{min-height:100%}
body{
  margin:0;
  background: radial-gradient(1200px 800px at 20% 0%, rgba(0,144,246,.08) 0%, #fff 55%);
  color:var(--text);
  font-family:var(--sans);
}

.app{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  gap:var(--gap);
  padding:var(--gap);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:var(--gap);
  background: var(--panel);
  border:1px solid var(--strokeSoft);
  border-radius:var(--radius);
  padding:10px 12px;
  box-shadow:var(--shadow);
  flex-wrap:wrap;
}

.brand{display:flex;align-items:center;gap:10px;min-width:260px}
.dot{
  width:10px;height:10px;border-radius:50%;
  background:var(--accent);
  box-shadow:0 0 0 5px rgba(0,144,246,.12);
}
.brand h1{font-size:14px;margin:0;letter-spacing:.2px}
.brand .meta{font-size:12px;color:var(--muted);overflow-wrap:anywhere}

.pill{
  display:inline-flex;align-items:center;gap:6px;
  padding:6px 10px;border-radius:999px;
  border:1px solid var(--strokeSoft);
  background:#fff;
  font-family:var(--mono);
  font-size:12px;
  color:var(--muted);
}
.pill .led{width:8px;height:8px;border-radius:50%;background:var(--accent)}

.topActions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.toolbar{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  padding:8px 10px;
  background: var(--panel);
  border:1px solid var(--strokeSoft);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}
.toolbar .btn{
  width:auto;
  padding:6px 10px;
  min-height:32px;
  font-size:11px;
  white-space:nowrap;
}

.layout{
  flex:1;
  display:grid;
  grid-template-columns: minmax(280px, 360px) minmax(0,1fr) minmax(280px, 360px);
  gap:var(--gap);
  align-items:start;
}

.panel{
  background:var(--panel);
  border:1px solid var(--strokeSoft);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

.panel header{
  padding:10px 12px;
  border-bottom:1px solid var(--strokeSoft);
  background:rgba(0,144,246,.05);
}
.panel header h2{
  font-size:12px;
  margin:0;
  color:rgba(0,144,246,.95);
  font-weight:800;
  letter-spacing:.35px;
  text-transform:uppercase;
}
.panel .content{
  padding:10px 12px;
  overflow:visible;   /* kluczowe: nie robimy “wewnętrznych” ścinających scrolli */
}

.stage{
  position:relative;
  display:flex;
  flex-direction:column;
  border-radius:var(--radius);
  border:1px solid var(--strokeSoft);
  background:#fff;
  box-shadow:var(--shadow);

  /* stała, sensowna wysokość sceny */
  height: calc(100vh - 130px);
  min-height:520px;
  max-height:900px;
}
.stageToolbar{
  position:sticky;
  top:0;
  z-index:5;
  width:100%;
  border-radius:var(--radius) var(--radius) 0 0;
  border:0;
  border-bottom:1px solid var(--strokeSoft);
  box-shadow:none;
}
.canvasWrap{
  position:relative;
  flex:1;
  min-height:0;
}
canvas{display:block}

.btn{
  width:100%;
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--strokeSoft);
  background:#fff;
  color:rgba(0,144,246,.98);
  cursor:pointer;
  font-weight:800;
  transition:transform .05s ease, background .15s ease, border-color .15s ease;
  user-select:none;
}
.btn:hover{background:rgba(0,144,246,.06);border-color:rgba(0,144,246,.35)}
.btn:active{transform:translateY(1px)}
.btn.ok{
  background:rgba(0,144,246,.95);
  color:#fff;
  border-color:rgba(0,144,246,.95);
}
.btn.secondary{background:#fff;color:rgba(0,144,246,.98)}
.btn.danger{
  /* “danger” bez czerwieni — nadal w palecie white + blue */
  background:#fff;
  color:rgba(0,144,246,.98);
  border-color:rgba(0,144,246,.55);
}
.btn:disabled{opacity:.45;cursor:not-allowed}

.grid{display:grid;gap:10px}
.field{
  display:grid;
  grid-template-columns: 120px 1fr;
  gap:10px;
  align-items:stretch;
  font-size:12px;
  color:var(--muted);
}
.field label{
  line-height:1.3;
  padding:3px 0;
  display:flex;
  align-items:center;
}
.field input, .field select{
  width:100%;
  height:36px;
  padding:0 10px;
  line-height:36px;
  border-radius:10px;
  border:1px solid var(--strokeSoft);
  background:#fff;
  color:var(--text);
  outline:none;
  font-family:var(--mono);
}
.shapePicker{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:8px;
}
.shapeBtn{
  display:flex;
  align-items:center;
  justify-content:center;
  height:36px;
  border-radius:10px;
  border:1px solid var(--strokeSoft);
  background:#fff;
  cursor:pointer;
  transition:background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.shapeBtn:hover{background:rgba(0,144,246,.06);border-color:rgba(0,144,246,.35)}
.shapeBtn.active{
  border-color:var(--accent);
  box-shadow:0 0 0 2px rgba(0,144,246,.18);
}
.shapeIcon{
  display:inline-block;
  width:20px;
  height:20px;
  border:2px solid var(--accent);
  background:rgba(0,144,246,.08);
  border-radius:4px;
}
.shapeIcon.circle{border-radius:50%}
.shapeIcon.square{border-radius:4px}
.shapeIcon.rect{
  width:26px;
  height:16px;
  border-radius:4px;
}
.shapeSelectHidden{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}
.srOnly{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.row2.rect .field{
  grid-template-columns:1fr;
  gap:6px;
}
.row2.rect .field label{
  padding:0;
}
.row2.rect .field input{
  height:34px;
  line-height:34px;
}
.hintBox{
  font-size:12px;
  line-height:1.35;
  color:var(--muted);
  padding:10px 12px;
  background:rgba(0,144,246,.04);
  border:1px solid var(--strokeSoft);
  border-radius:12px;
  overflow-wrap:anywhere;
}

.sep{height:1px;background:var(--strokeSoft);margin:10px 0}

.previewWrap{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:10px;
  background:rgba(0,144,246,.04);
  border:1px solid var(--strokeSoft);
  border-radius:12px;
}
.previewBox{
  width:150px;height:90px;
  border:2px solid rgba(0,144,246,.8);
  background:rgba(0,144,246,.06);
  box-shadow: inset 0 0 0 2px rgba(0,144,246,.08);
  transition:all .12s ease;
}

.tools{display:grid;gap:10px}
.toolrow{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.toolrow3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px}
.small{padding:8px 10px;border-radius:10px;font-size:12px;font-weight:800}

.statusLine{
  font-family:var(--mono);
  font-size:12px;
  color:var(--muted);
  white-space:normal;     /* kluczowe: koniec ucinania */
  overflow-wrap:anywhere; /* kluczowe: długie tokeny/origins nie utną panelu */
}

/* Responsywność: żeby NIC nie ucinać, tylko przejść w pion */
@media (max-width: 1200px){
  .layout{grid-template-columns:1fr}
  .stage{
    height: 60vh;
    min-height:420px;
    max-height:none;
  }
}
@media (max-width: 700px){
  .toolbar{
    flex-wrap:nowrap;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
  }
  .toolbar .btn{
    flex:0 0 auto;
  }
  .stage{
    height: 50vh;
    min-height:360px;
  }
  .field input, .field select{
    height:40px;
    line-height:40px;
  }
  .btn{min-height:40px}
}
@media (max-width: 420px){
  .row2{grid-template-columns:1fr}
}
