/* BRICK.XYZ v3 – 2.5D neo wall + Supabase backend */
:root{
  --bg:#05070c;
  --panel:#0f1620;
  --panel2:#0b1220;
  --text:#e8f1ff;
  --muted: rgba(232,241,255,0.74);
  --muted2: rgba(232,241,255,0.56);
  --line: rgba(232,241,255,0.12);

  /* TesseraSpace neon */
  --neon-g: #29ff8a;
  --neon-b: #3fd7ff;
  --accent: var(--neon-b);
  --accent2: var(--neon-g);

  --shadow: 0 10px 30px rgba(0,0,0,0.55);
  --radius: 16px;

  --brick-w: 84px;
  --brick-h: 44px;
  --brick-gap: 8px;
}

*{box-sizing:border-box}
html,body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background:
    radial-gradient(1200px 900px at 20% 10%, rgba(41,255,138,0.14), transparent 60%),
    radial-gradient(900px 800px at 85% 80%, rgba(63,215,255,0.12), transparent 62%),
    linear-gradient(180deg, rgba(0,0,0,0.0), rgba(0,0,0,0.55)),
    url("./bg_render.png");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 14px 16px;
  background: rgba(5,7,12,0.74);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand{display:flex; align-items:center; gap:12px}
.logo{
  width:38px;height:38px;border-radius:12px;
  display:grid;place-items:center;
  font-weight:900;
  background: radial-gradient(circle at 30% 20%, rgba(41,255,138,0.24), rgba(63,215,255,0.18));
  border: 1px solid rgba(63,215,255,0.35);
  box-shadow: var(--shadow);
}

.brand-title{font-weight:900; letter-spacing:0.3px}
.brand-sub{font-size:12px; color: var(--muted2); margin-top:2px}

.topbar-right{display:flex; align-items:center; gap:10px}

.layout{
  display:grid;
  grid-template-columns: 380px 1fr;
  height: calc(100% - 68px);
}

.sidebar{
  padding:14px;
  overflow:auto;
  border-right: 1px solid var(--line);
  background: rgba(5,12,24,0.88);
  backdrop-filter: blur(10px);
}

.stage{position:relative; overflow:hidden}
.hint{
  position:absolute;
  left: 14px;
  top: 14px;
  z-index: 5;
  font-size: 12px;
  color: var(--muted);
  background: rgba(3,10,22,0.78);
  border: 1px solid rgba(70,224,255,0.25);
  padding: 8px 10px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

.card{
  background: rgba(8,20,46,0.64);
  border: 1px solid rgba(120,180,255,0.15);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  margin-bottom: 12px;
}
.card h3{
  margin:0 0 10px 0;
  font-size:14px;
  letter-spacing:0.14em;
  text-transform: uppercase;
  color: rgba(168,216,255,0.92);
}

.muted{color: var(--muted)}
.small{font-size:12px}
.divider{height:1px;background: rgba(120,180,255,0.15); margin: 10px 0}

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

label{display:grid; gap:6px; margin:10px 0}
label.inline{display:grid; grid-template-columns: 34px 1fr; gap:8px; align-items:center; margin:0}
label span{font-size:12px; color: var(--muted)}

.auth-grid{display:grid; gap:10px}

input, select{
  width:100%;
  background: rgba(3,10,22,0.85);
  border: 1px solid rgba(63,215,255,0.25);
  color: var(--text);
  padding: 10px 10px;
  border-radius: 12px;
  outline:none;
}
input:focus, select:focus{border-color: rgba(70,224,255,0.55); box-shadow: 0 0 0 3px rgba(70,224,255,0.14)}

.btn{
  background: linear-gradient(90deg, rgba(10,25,47,0.9), rgba(16,42,67,0.9));
  border: 1px solid rgba(63,215,255,0.35);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(63,215,255,0.18);
}
.btn:hover{filter:brightness(1.1); box-shadow: 0 0 18px rgba(63,215,255,0.35)}
.btn:disabled{opacity:0.45; cursor:not-allowed}

.btn-ghost{
  background: transparent;
  border: 1px solid rgba(120,180,255,0.35);
  box-shadow:none;
}
.btn-oauth{
  min-width: 110px;
}
.btn.file{position:relative; overflow:hidden; display:inline-flex; justify-content:center; align-items:center}
.btn.file input{position:absolute; inset:0; opacity:0; cursor:pointer}

.pill{
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(63,215,255,0.25);
  background: rgba(3,10,22,0.65);
  font-size: 12px;
  color: rgba(232,241,255,0.88);
}

.coord-row{display:flex; gap:8px}

.kv{
  display:grid;
  grid-template-columns: 90px 1fr;
  gap:6px 10px;
  font-size:12px;
  margin-top: 10px;
}
.kv .k{color: var(--muted2)}
.kv .v{color: rgba(232,241,255,0.92); word-break: break-word}

.tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom: 10px;
}
.tab{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(90,160,255,0.6);
  background: rgba(8,20,46,0.88);
  cursor:pointer;
  font-size: 12px;
  color: rgba(201,227,255,0.95);
}
.tab.active{
  background: linear-gradient(90deg, rgba(29,78,216,0.95), rgba(34,211,238,0.95));
  border-color: transparent;
  color: #fff;
}

.pane{display:none}
.pane.active{display:block}

.wall-wrapper{
  width:100%;
  height:100%;
  overflow:auto;
  display:flex;
  justify-content:center;
  align-items:center;
  padding: 22px;
}

.wall{
  background:
    radial-gradient(circle at top left, rgba(41,255,138,0.14) 0, transparent 50%),
    radial-gradient(circle at bottom right, rgba(255, 90, 180, 0.16) 0, transparent 55%),
    rgba(2,7,17,0.72);
  padding: 30px;
  border-radius: 18px;
  box-shadow:
    0 0 40px rgba(0, 0, 0, 0.9),
    0 0 32px rgba(63,215,255,0.18);
  width: max-content;
  height: max-content;
  position: relative;
  transform-origin: center center;
}

.wall-grid{
  display:grid;
  grid-auto-rows: var(--brick-h);
  gap: var(--brick-gap);
}

.brick{
  width: var(--brick-w);
  height: var(--brick-h);
  position: relative;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  border-radius: 12px;
  overflow:hidden;
  background: radial-gradient(circle at 30% 20%, rgba(0,255,255,0.12), rgba(0,0,0,0.92));
}
.brick-inner{
  position:absolute;
  inset: 6%;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 20%, rgba(0,0,0,0.12), rgba(0,0,0,0.96));
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.92),
    inset 0 0 20px rgba(0,0,0,0.8);
}

.brick::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: 14px;
  border: 1px solid rgba(63,215,255,0.82);
  box-shadow:
    0 0 6px rgba(63,215,255,0.65),
    0 0 16px rgba(63,215,255,0.55);
  opacity: 0.95;
  pointer-events:none;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.brick.crypto::before{
  border-color: rgba(0, 255, 200, 0.95);
  box-shadow: 0 0 7px rgba(0, 255, 200, 0.9), 0 0 18px rgba(0, 200, 255, 0.7);
}
.brick.heart::before{
  border-color: rgba(255, 0, 120, 0.95);
  box-shadow: 0 0 7px rgba(255, 0, 120, 0.9), 0 0 18px rgba(255, 120, 180, 0.7);
}
.brick.deep::before{
  border-color: rgba(120, 80, 255, 0.95);
  box-shadow: 0 0 7px rgba(120, 80, 255, 0.9), 0 0 18px rgba(0, 240, 160, 0.7);
}

.brick-symbol{
  position:absolute;
  inset: 18%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 16px;
  color: rgba(255,255,255,0.85);
  z-index: 3;
  pointer-events:none;
}

.brick-image{
  position:absolute;
  inset:12%;
  width:76%;
  height:76%;
  object-fit: cover;
  border-radius: 10px;
  z-index:2;
  display:none;
  box-shadow: 0 0 8px rgba(0,0,0,0.7);
}

.brick-label{
  position:absolute;
  bottom: 3px;
  left: 6px;
  right: 6px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: #a9d7ff;
  background: linear-gradient(90deg, rgba(0,0,0,0.65), transparent);
  padding: 2px 4px;
  border-radius: 7px;
  z-index: 4;
  pointer-events:none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow:hidden;
}

.brick:hover,
.brick.active{
  transform: scale(3.3);
  z-index: 50;
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.7), 0 0 40px rgba(0, 170, 255, 0.7);
}
.brick:hover::before,
.brick.active::before{
  box-shadow: 0 0 10px rgba(0, 255, 255, 1), 0 0 30px rgba(0, 170, 255, 0.9), 0 0 60px rgba(0, 120, 255, 0.7);
}

.toasts{
  position: fixed;
  right: 14px;
  bottom: 14px;
  display:grid;
  gap:10px;
  z-index: 999;
}
.toast{
  background: rgba(3,10,22,0.92);
  border: 1px solid rgba(63,215,255,0.25);
  border-left: 4px solid rgba(70,224,255,0.9);
  border-radius: 14px;
  padding: 10px 12px;
  width: min(420px, calc(100vw - 28px));
  box-shadow: var(--shadow);
}
.toast.ok{border-left-color: rgba(0,255,200,0.9)}
.toast.warn{border-left-color: rgba(251,191,36,0.9)}
.toast.bad{border-left-color: rgba(251,113,133,0.9)}
.toast .t{font-weight: 800; margin-bottom: 4px}
.toast .m{font-size: 12px; color: var(--muted)}

dialog::backdrop{ background: rgba(0,0,0,0.62) }
dialog{ border:none; background: transparent }
.dialog{
  width: min(860px, calc(100vw - 28px));
  border-radius: 18px;
  background: rgba(5,12,24,0.96);
  border: 1px solid rgba(120,180,255,0.18);
  box-shadow: var(--shadow);
  padding: 14px;
}
.dialog h2{ margin: 6px 0 10px; }
.dialog ul{ margin: 0 0 10px 18px; color: var(--muted); }
.dialog code{ color: rgba(232,241,255,0.95); }

.draw-tools{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
#drawCanvas{
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid rgba(120,180,255,0.18);
  background: rgba(0,0,0,0.25);
  cursor: crosshair;
}

@media (max-width: 1040px){
  .layout{grid-template-columns: 1fr; height:auto}
  .sidebar{border-right:none; border-bottom: 1px solid var(--line)}
  .stage{height: 70vh}
}

.logo img{
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(41,255,138,0.25)) drop-shadow(0 0 14px rgba(63,215,255,0.18));
}
