/* Mandala Stüdyosu */
:root {
  --mb-bar: 64px;
  --mb-ink: #2b2550;
  --mb-sub: #6d6890;
  --mb-glass: rgba(255, 255, 255, .86);
  --mb-line: rgba(90, 70, 160, .14);
  --mb-acc: #7c4dff;
  --mb-acc2: #ff4fa3;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #fff; overscroll-behavior: none; }
body { font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--mb-ink); -webkit-tap-highlight-color: transparent; }

#mandala-app { position: fixed; inset: 0; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }

/* ── Üst çubuk ── */
.mb-bar {
  position: relative; z-index: 40; height: var(--mb-bar); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 10px; padding-top: env(safe-area-inset-top);
  background: var(--mb-glass); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--mb-line); box-shadow: 0 6px 24px rgba(60, 40, 140, .08);
}
.mb-group { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 16px; background: rgba(124, 77, 255, .07); }
.mb-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 54px; height: 50px; padding: 0 6px; border: 0; border-radius: 13px; background: transparent;
  color: var(--mb-ink); font: 700 11px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .12s, color .15s;
}
.mb-btn:hover { background: rgba(124, 77, 255, .1); }
.mb-btn:active { transform: scale(.92); }
.mb-btn.active { background: var(--mb-acc); color: #fff; box-shadow: 0 4px 14px rgba(124, 77, 255, .4); }
.mb-btn:disabled { opacity: .3; pointer-events: none; }
.mb-ico { position: relative; width: 24px; height: 24px; display: grid; place-items: center; }
.mb-ico svg { width: 22px; height: 22px; }
.mb-lbl { white-space: nowrap; letter-spacing: .01em; }
.mb-drop .mb-lbl::after { content: '▾'; margin-left: 2px; opacity: .55; font-size: 9px; }
.mb-swatch { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .9), 0 0 0 1.5px rgba(0, 0, 0, .18); }
.mb-dot { position: absolute; right: -3px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.mb-badge { position: absolute; right: -12px; top: -6px; min-width: 18px; padding: 2px 4px; border-radius: 9px; background: var(--mb-acc2); color: #fff; font-size: 9px; line-height: 1; }
.mb-btn.active .mb-badge { background: #fff; color: var(--mb-acc); }
.mb-back { min-width: 44px; }
.mb-magic { background: linear-gradient(135deg, #ff6fd8, #7c4dff 55%, #3ad0ff); color: #fff; box-shadow: 0 4px 16px rgba(124, 77, 255, .35); }
.mb-magic:hover { background: linear-gradient(135deg, #ff6fd8, #7c4dff 55%, #3ad0ff); filter: brightness(1.1); }
.mb-magic .mb-ico { animation: mbTwinkle 2.4s ease-in-out infinite; }
.mb-save { background: #18b26b; color: #fff; }
.mb-save:hover { background: #12a05f; }
@keyframes mbTwinkle { 50% { transform: rotate(-12deg) scale(1.12); } }

/* ── Paneller ── */
.mb-panel {
  position: fixed; z-index: 50; top: calc(var(--mb-bar) + env(safe-area-inset-top) + 8px); left: 50%;
  width: min(400px, calc(100vw - 16px)); max-height: calc(100dvh - var(--mb-bar) - 24px); overflow: auto;
  padding: 6px 14px 14px; border-radius: 20px; background: rgba(255, 255, 255, .97);
  box-shadow: 0 18px 50px rgba(40, 20, 110, .22), 0 0 0 1px var(--mb-line);
  opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98); transform-origin: top center;
  transition: opacity .16s, transform .16s, visibility .16s; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.mb-panel.open { opacity: 1; visibility: visible; transform: none; }
.mb-sec { padding: 10px 0 4px; }
.mb-sec + .mb-sec { border-top: 1px solid var(--mb-line); }
.mb-sec-t { margin-bottom: 8px; color: var(--mb-sub); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.mb-brushes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mb-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 7px; border: 2px solid transparent; border-radius: 14px; background: #f5f3fd; color: var(--mb-ink); font: 700 11.5px inherit; font-family: inherit; cursor: pointer; transition: transform .12s, border-color .15s; }
.mb-tile canvas { width: 84px; height: 36px; }
.mb-tile:active { transform: scale(.95); }
.mb-tile.sel { border-color: var(--mb-acc); background: #efe9ff; }

.mb-sizerow { display: flex; align-items: center; gap: 14px; }
.mb-grow { flex: 1; }
.mb-sizedot { flex: none; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.15); transition: width .1s, height .1s; }
.mb-slider { display: block; margin: 4px 0 8px; }
.mb-slider-t { display: block; margin-bottom: 2px; font-size: 13px; font-weight: 700; }
.mb-slider-t b { color: var(--mb-acc); }
.mb-slider input { width: 100%; accent-color: var(--mb-acc); height: 28px; }

.mb-colors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.mb-recent { grid-template-columns: repeat(12, 1fr); gap: 4px; }
.mb-c { aspect-ratio: 1; width: 100%; padding: 0; border: 0; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .12s; }
.mb-c:hover { transform: scale(1.12); }
.mb-c.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--mb-acc); transform: scale(1.05); }
.mb-custom { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 700; font-size: 13px; cursor: pointer; }
.mb-custom input { width: 44px; height: 34px; padding: 0; border: 0; border-radius: 10px; background: none; cursor: pointer; }

.mb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mb-chip { min-width: 42px; padding: 9px 10px; border: 0; border-radius: 12px; background: #f1eefb; color: var(--mb-ink); font: 800 13px inherit; font-family: inherit; cursor: pointer; transition: background .15s, transform .12s; }
.mb-chip:active { transform: scale(.94); }
.mb-chip.sel { background: var(--mb-acc); color: #fff; }

.mb-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 10px 2px; border: 0; background: none; color: var(--mb-ink); font: 700 14px inherit; font-family: inherit; cursor: pointer; }
.mb-toggle i { position: relative; width: 44px; height: 26px; border-radius: 13px; background: #d9d5ea; transition: background .2s; flex: none; }
.mb-toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.mb-toggle.on i { background: var(--mb-acc); }
.mb-toggle.on i::after { transform: translateX(18px); }

.mb-bgs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mb-bg { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--mb-ink); font: 700 11px inherit; font-family: inherit; cursor: pointer; }
.mb-bg i { width: 100%; aspect-ratio: 1.3; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .12s; }
.mb-bg.sel i { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--mb-acc); }
.mb-bg span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ── Tuval ── */
.mb-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: crosshair; }
.mb-layer { position: absolute; left: 0; top: 0; display: block; }
.mb-art { position: absolute; inset: 0; transform-origin: 50% 50%; }
.mb-art.spin { animation: mbSpin 24s linear infinite; }
.mb-layer.guide { pointer-events: none; }
@keyframes mbSpin { to { transform: rotate(360deg); } }

.mb-hint {
  position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 10px 18px; border-radius: 99px; background: rgba(43, 37, 80, .82); color: #fff; font-weight: 700; font-size: 14px;
  pointer-events: none; white-space: nowrap; transition: opacity .5s; animation: mbFloat 2.4s ease-in-out infinite;
}
.mb-hint.gone { opacity: 0; }
@keyframes mbFloat { 50% { transform: translateX(-50%) translateY(-5px); } }
.mb-toast {
  position: fixed; z-index: 60; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 12px 20px; border-radius: 99px;
  background: #2b2550; color: #fff; font-weight: 800; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.mb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.mb-flash { position: absolute; inset: 0; background: #fff; pointer-events: none; animation: mbFlash .5s ease-out forwards; z-index: 30; }
@keyframes mbFlash { from { opacity: .85; } to { opacity: 0; } }

/* ── Mobil: yalnızca simgeler, çubuk ekrana sığar ── */
@media (max-width: 760px) {
  :root { --mb-bar: 54px; }
  .mb-bar { padding: 0 4px; gap: 3px; }
  .mb-lbl { display: none; }
  .mb-group { gap: 0; padding: 2px; border-radius: 13px; }
  .mb-btn { min-width: 0; width: clamp(32px, 9.4vw, 46px); height: 44px; padding: 0; border-radius: 11px; }
  .mb-back { width: 32px; }
  .mb-ico svg { width: 20px; height: 20px; }
  .mb-badge { right: -8px; top: -7px; }
  .mb-panel { left: 8px !important; width: calc(100vw - 16px); border-radius: 18px; }
}
@media (max-width: 360px) {
  .mb-btn { width: 30px; }
  .mb-ico svg { width: 18px; height: 18px; }
}
@media (min-width: 761px) { .mb-panel { transform-origin: top left; } }
