/* ============================================================
 * /sprite-generator — full-shell dfl wrapper.
 *
 * Mirror of `.ts-flush-shell` and `.ws-flush-shell`: a fixed host
 * pinned to the AppShell offsets so the DashFlexLayout uses every
 * pixel of AppShellMain.
 * ============================================================ */

.sg-flush-shell {
    position:        fixed;
    top:             var(--app-shell-header-offset, 56px);
    left:            var(--app-shell-navbar-offset, 0px);
    right:           0;
    bottom:          0;
    z-index:         10;
    background:      var(--mantine-color-body);
    border-top:      1px solid var(--mantine-color-default-border);
    border-left:     1px solid var(--mantine-color-default-border);
    overflow:        hidden;
}

.sg-flush-shell > .flexlayout__layout,
.sg-flush-shell > div {
    height: 100%;
    width:  100%;
}

/* The dfl is now mounted into ``#sg-flex-host`` (a callback fills it once
 * the viewport resolves), so it's one level deeper than the flush-shell.
 * Give the host + the FlexLayout it holds the full box. */
#sg-flex-host > .flexlayout__layout {
    height: 100%;
    width:  100%;
}

/* ============================================================
 * Preview canvas — common chrome for all three preview tabs.
 * ============================================================ */

.sg-canvas {
    height:          100%;
    width:           100%;
    display:         flex;
    flex-direction:  column;
    overflow:        hidden;
    background:      light-dark(
                         var(--mantine-color-gray-0),
                         var(--mantine-color-dark-8)
                     );
}

.sg-canvas-toolbar {
    padding:         10px 14px;
    border-bottom:   1px solid var(--mantine-color-default-border);
    background:      light-dark(
                         var(--mantine-color-white),
                         var(--mantine-color-dark-7)
                     );
    display:         flex;
    align-items:     center;
    gap:             12px;
}

/* ============================================================
 * Sprite Matrix — the 8-direction × N-animation grid.
 *
 * Layout:
 *   sg-matrix-body
 *     sg-matrix-block        (one per animation)
 *       sg-matrix-blockhead  (animation header + frame badge)
 *       sg-matrix-row        (one per direction)
 *         sg-matrix-rowlabel (the direction tag)
 *         sg-matrix-cells    (the 4/6/8/9 frame thumbs)
 *           sg-frame-cell    (each clickable sprite frame)
 * ============================================================ */

.sg-matrix-body {
    padding:         14px;
    display:         flex;
    flex-direction:  column;
    gap:             18px;
}

.sg-matrix-block {
    background:      light-dark(
                         var(--mantine-color-white),
                         var(--mantine-color-dark-7)
                     );
    border:          1px solid var(--mantine-color-default-border);
    border-radius:   12px;
    padding:         12px;
    box-shadow:      0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

/* Block head is a clickable button — selects every cell in the animation. */
.sg-matrix-blockhead {
    display:         flex;
    align-items:     center;
    gap:             8px;
    padding:         4px 6px 10px;
    margin-bottom:   10px;
    border-bottom:   1px dashed var(--mantine-color-default-border);
    background:      transparent;
    border:          0;
    border-bottom:   1px dashed var(--mantine-color-default-border);
    cursor:          pointer;
    text-align:      left;
    width:           100%;
    color:           inherit;
    font:            inherit;
    transition:      background 100ms ease, border-color 100ms ease;
}

.sg-matrix-blockhead:hover {
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-blue-1) 35%, transparent),
                         color-mix(in srgb, var(--mantine-color-blue-9) 14%, transparent)
                     );
    border-radius:   6px 6px 0 0;
}

.sg-matrix-blockhead--selected {
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-blue-1) 60%, transparent),
                         color-mix(in srgb, var(--mantine-color-blue-9) 22%, transparent)
                     );
    border-bottom-color: var(--mantine-color-blue-4);
    border-radius:   6px 6px 0 0;
}

.sg-matrix-anim {
    font-size:       11px;
    font-weight:     700;
    letter-spacing:  0.08em;
    color:           var(--mantine-color-text);
}

.sg-matrix-row {
    display:         grid;
    grid-template-columns: 86px 1fr;
    align-items:     center;
    gap:             10px;
    padding:         4px 0;
}

/* Row label is also a clickable button — selects every cell in the
 * (anim, direction) row. Looks like a plain label but reacts to hover. */
.sg-matrix-rowlabel {
    display:         flex;
    align-items:     center;
    gap:             4px;
    font-size:       11px;
    color:           var(--mantine-color-dimmed);
    text-transform:  capitalize;
    background:      transparent;
    border:          1px solid transparent;
    border-radius:   6px;
    padding:         3px 6px;
    cursor:          pointer;
    font-family:     inherit;
    text-align:      left;
    transition:      background 100ms ease, color 100ms ease, border-color 100ms ease;
}

.sg-matrix-rowlabel:hover {
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-blue-1) 40%, transparent),
                         color-mix(in srgb, var(--mantine-color-blue-9) 16%, transparent)
                     );
    color:           var(--mantine-color-text);
    border-color:    color-mix(in srgb, var(--mantine-color-blue-4) 40%, transparent);
}

.sg-matrix-rowlabel--selected {
    background:      color-mix(in srgb, var(--mantine-color-blue-4) 18%, transparent);
    color:           var(--mantine-color-blue-6);
    border-color:    var(--mantine-color-blue-4);
    font-weight:     600;
}

.sg-matrix-dir { white-space: nowrap; }

.sg-matrix-cells {
    display:         flex;
    flex-wrap:       wrap;
    gap:             6px;
}

/* Per-row kebab — Merge into… / Add new frame. Rides at the end of the cell
 * flow (last flex child), nudged to the row's right edge so it reads as a
 * trailing row action. Subtle until the row is hovered or the menu is open. */
.sg-row-kebab-btn {
    margin-left:     auto;
    align-self:      center;
    opacity:         0.5;
    transition:      opacity 100ms ease;
}
.sg-matrix-row:hover .sg-row-kebab-btn,
.sg-row-kebab-btn:hover,
.sg-row-kebab-btn[aria-expanded="true"] {
    opacity:         1;
}

.sg-frame-cell {
    position:        relative;
    width:           54px;
    height:          54px;
    border-radius:   8px;
    border:          1px solid var(--mantine-color-default-border);
    background:      light-dark(
                         var(--mantine-color-gray-1),
                         var(--mantine-color-dark-6)
                     );
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    overflow:        hidden;
    transition:      transform 100ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.sg-frame-cell:hover {
    transform:       translateY(-1px);
    border-color:    light-dark(
                         var(--mantine-color-blue-4),
                         var(--mantine-color-blue-6)
                     );
}

.sg-frame-img {
    width:           48px;
    height:          48px;
    image-rendering: pixelated;
    user-select:     none;
    pointer-events:  none;
    display:         block;
    /* When the clientside callback swaps `img.src` after a Gemini call,
     * we briefly animate a soft scale-in so the eye locks onto the cell
     * that just revealed. Triggered by JS adding `.sg-frame-img--reveal`. */
}

.sg-frame-img--reveal {
    animation: sg-reveal 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sg-reveal {
    0%   { transform: scale(0.78); opacity: 0; filter: blur(2px); }
    60%  { transform: scale(1.05); opacity: 1; filter: blur(0);   }
    100% { transform: scale(1);    opacity: 1; filter: blur(0);   }
}

.sg-frame-idx {
    position:        absolute;
    bottom:          2px;
    right:           3px;
    font-family:     var(--mantine-font-family-monospace, monospace);
    font-size:       9px;
    color:           var(--mantine-color-dimmed);
    background:      color-mix(in srgb, var(--mantine-color-body) 70%, transparent);
    padding:         0 3px;
    border-radius:   3px;
    pointer-events:  none;
}

.sg-frame-cell--selected {
    border-color:    var(--mantine-color-blue-4);
    box-shadow:      0 0 0 2px color-mix(in srgb,
                         var(--mantine-color-blue-4) 35%, transparent);
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-blue-1) 45%, transparent),
                         color-mix(in srgb, var(--mantine-color-blue-9) 22%, transparent)
                     );
}

.sg-frame-cell--selected::after {
    content:         "REGEN";
    position:        absolute;
    top:             2px;
    left:            2px;
    background:      var(--mantine-color-blue-4);
    color:           white;
    font-size:       7px;
    font-weight:     700;
    letter-spacing:  0.05em;
    padding:         1px 3px;
    border-radius:   3px;
    pointer-events:  none;
    z-index:         3;
}

/* ============================================================
 * Per-cell skeleton overlay — the live reveal mechanism.
 *
 * Always rendered in the DOM (one `<div class="sg-frame-cell__skeleton">`
 * inside every cell). Visibility is purely driven by `data-state` on the
 * parent cell, which a clientside callback flips as `sg-queue` /
 * `sg-progress` change. When generation lands a frame, the same tick
 * removes the data-state and updates the cell's `<img src>` — so the
 * shimmer disappears the instant the new sprite arrives.
 *
 *   data-state="queued"  -> faint shimmer, frame is in the queue
 *   data-state="loading" -> bright shimmer + ring spinner, Gemini is
 *                           generating this exact frame right now
 *   (no attribute)       -> overlay is hidden, sprite is visible
 * ============================================================ */

.sg-frame-cell__skeleton {
    position:           absolute;
    inset:              0;
    border-radius:      inherit;
    background:         linear-gradient(
                            90deg,
                            color-mix(in srgb, var(--mantine-color-gray-3) 92%, transparent) 25%,
                            color-mix(in srgb, var(--mantine-color-gray-1) 88%, transparent) 50%,
                            color-mix(in srgb, var(--mantine-color-gray-3) 92%, transparent) 75%
                        );
    background-size:    220% 100%;
    animation:          sg-shimmer 1.4s linear infinite;
    pointer-events:     none;
    z-index:            2;
    opacity:            0;
    /* Slow fade so the reveal-on-finish is visible to the eye — the
     * data-state attribute disappears the instant Gemini returns, and
     * we want the user to actually SEE the shimmer dissolve into the
     * new sprite rather than blink. */
    transition:         opacity 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-mantine-color-scheme="dark"] .sg-frame-cell__skeleton {
    background:         linear-gradient(
                            90deg,
                            color-mix(in srgb, var(--mantine-color-dark-5) 92%, transparent) 25%,
                            color-mix(in srgb, var(--mantine-color-dark-3) 85%, transparent) 50%,
                            color-mix(in srgb, var(--mantine-color-dark-5) 92%, transparent) 75%
                        );
    background-size:    220% 100%;
}

@keyframes sg-shimmer {
    0%   { background-position: 220% 0; }
    100% { background-position: -220% 0; }
}

.sg-frame-cell[data-state="queued"] .sg-frame-cell__skeleton {
    opacity:        0.6;
}

.sg-frame-cell[data-state="loading"] .sg-frame-cell__skeleton {
    opacity:        1;
}

/* Ring spinner over the loading cell — single ::after inside the overlay,
 * so the shimmer + the spinner stack cleanly without a second wrapper. */
.sg-frame-cell[data-state="loading"] .sg-frame-cell__skeleton::after {
    content:        "";
    position:       absolute;
    top:            50%;
    left:           50%;
    width:          18px;
    height:         18px;
    margin:         -9px 0 0 -9px;
    border:         2px solid var(--mantine-color-blue-4);
    border-top-color: transparent;
    border-radius:  50%;
    animation:      sg-spin 0.85s linear infinite;
    background:     transparent;
}

@keyframes sg-spin {
    to { transform: rotate(360deg); }
}

.sg-frame-cell[data-state="queued"] {
    border-color:   color-mix(in srgb, var(--mantine-color-blue-4) 55%, transparent);
}

.sg-frame-cell[data-state="loading"] {
    border-color:   var(--mantine-color-blue-4);
    box-shadow:     0 0 0 2px color-mix(in srgb, var(--mantine-color-blue-4) 45%, transparent),
                    0 0 14px color-mix(in srgb, var(--mantine-color-blue-4) 35%, transparent);
}

/* ============================================================
 * Animation player — large preview + 8-way compass + filmstrip.
 * ============================================================ */

.sg-anim-stage {
    flex:            1 1 auto;
    display:         grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: 1fr auto;
    gap:             16px;
    padding:         20px;
    overflow:        auto;
}

.sg-anim-compass {
    grid-row:        1 / span 1;
    grid-column:     1;
    display:         grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows:    repeat(3, 1fr);
    gap:             6px;
    align-self:      center;
    aspect-ratio:    1 / 1;
    max-width:       220px;
    padding:         10px;
    background:      light-dark(
                         var(--mantine-color-white),
                         var(--mantine-color-dark-7)
                     );
    border:          1px solid var(--mantine-color-default-border);
    border-radius:   12px;
}

/* Map compass cells: NW N NE / W . E / SW S SE */
.sg-anim-dirbtn[data-dir="north"]        { grid-column: 2; grid-row: 1; }
.sg-anim-dirbtn[data-dir="north-east"]   { grid-column: 3; grid-row: 1; }
.sg-anim-dirbtn[data-dir="east"]         { grid-column: 3; grid-row: 2; }
.sg-anim-dirbtn[data-dir="south-east"]   { grid-column: 3; grid-row: 3; }
.sg-anim-dirbtn[data-dir="south"]        { grid-column: 2; grid-row: 3; }
.sg-anim-dirbtn[data-dir="south-west"]   { grid-column: 1; grid-row: 3; }
.sg-anim-dirbtn[data-dir="west"]         { grid-column: 1; grid-row: 2; }
.sg-anim-dirbtn[data-dir="north-west"]   { grid-column: 1; grid-row: 1; }

.sg-anim-dirbtn {
    border:          1px solid var(--mantine-color-default-border);
    background:      light-dark(
                         var(--mantine-color-gray-0),
                         var(--mantine-color-dark-6)
                     );
    border-radius:   8px;
    display:         flex;
    align-items:     center;
    justify-content: center;
    cursor:          pointer;
    color:           var(--mantine-color-text);
    transition:      transform 80ms ease, box-shadow 120ms ease;
}
.sg-anim-dirbtn:hover { transform: scale(1.05); }
.sg-anim-dirbtn--active {
    background:      var(--mantine-color-blue-4);
    border-color:    var(--mantine-color-blue-4);
    color:           white;
    box-shadow:      0 0 0 2px color-mix(in srgb,
                         var(--mantine-color-blue-4) 35%, transparent);
}

.sg-anim-viewer {
    grid-row:        1;
    grid-column:     2;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             14px;
    background:      light-dark(
                         var(--mantine-color-white),
                         var(--mantine-color-dark-7)
                     );
    border:          1px solid var(--mantine-color-default-border);
    border-radius:   12px;
    padding:         24px;
    min-height:      280px;
    position:        relative;
}

.sg-anim-frame {
    width:           192px;
    height:          192px;
    image-rendering: pixelated;
    filter:          drop-shadow(0 8px 12px rgba(0, 0, 0, 0.18));
    background:
        linear-gradient(45deg, var(--mantine-color-gray-2) 25%, transparent 25%),
        linear-gradient(-45deg, var(--mantine-color-gray-2) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--mantine-color-gray-2) 75%),
        linear-gradient(-45deg, transparent 75%, var(--mantine-color-gray-2) 75%);
    background-size:    16px 16px;
    background-position:0 0, 0 8px, 8px -8px, -8px 0;
    border-radius:      6px;
}

[data-mantine-color-scheme="dark"] .sg-anim-frame {
    background:
        linear-gradient(45deg, var(--mantine-color-dark-5) 25%, transparent 25%),
        linear-gradient(-45deg, var(--mantine-color-dark-5) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--mantine-color-dark-5) 75%),
        linear-gradient(-45deg, transparent 75%, var(--mantine-color-dark-5) 75%);
    background-size:    16px 16px;
    background-position:0 0, 0 8px, 8px -8px, -8px 0;
}

.sg-anim-readout {
    display:         flex;
    gap:             8px;
    align-items:     center;
}

.sg-anim-filmstrip {
    grid-column:     1 / span 2;
    display:         flex;
    gap:             6px;
    overflow-x:      auto;
    padding:         8px;
    border:          1px dashed var(--mantine-color-default-border);
    border-radius:   8px;
    background:      light-dark(
                         var(--mantine-color-gray-0),
                         var(--mantine-color-dark-7)
                     );
    min-height:      72px;
}

.sg-anim-stripframe {
    width:           56px;
    height:          56px;
    image-rendering: pixelated;
    border-radius:   6px;
    border:          1px solid var(--mantine-color-default-border);
    background:      light-dark(
                         var(--mantine-color-gray-1),
                         var(--mantine-color-dark-6)
                     );
    flex-shrink:     0;
}

/* ============================================================
 * Test-on-map pane.
 * ============================================================ */

.sg-canvas--map {
    position:        relative;
}

.sg-canvas--map > .leaflet-container,
.sg-canvas--map > div[id="sg-test-map"] {
    height:          100% !important;
    width:           100% !important;
}

.sg-test-frame {
    image-rendering: pixelated;
}

.sg-test-icon {
    background:      transparent !important;
    border:          none !important;
}

.sg-test-hint {
    position:        absolute;
    top:             14px;
    left:            56px;
    z-index:         500;
    display:         flex;
    align-items:     center;
    gap:             6px;
    padding:         6px 10px;
    background:      color-mix(in srgb,
                         var(--mantine-color-body) 70%, transparent);
    backdrop-filter: blur(10px) saturate(140%);
    border:          1px solid var(--mantine-color-default-border);
    border-radius:   8px;
    color:           var(--mantine-color-text);
    font-size:       12px;
    pointer-events:  none;
}

.sg-test-readout {
    position:        absolute;
    bottom:          14px;
    left:            14px;
    z-index:         500;
    display:         flex;
    gap:             6px;
}

/* ============================================================
 * Right-side controls.
 * ============================================================ */

.sg-upload {
    border:          2px dashed var(--mantine-color-default-border);
    border-radius:   10px;
    padding:         18px;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             8px;
    cursor:          pointer;
    transition:      border-color 120ms ease, background 120ms ease;
    background:      light-dark(
                         var(--mantine-color-gray-0),
                         var(--mantine-color-dark-7)
                     );
}
.sg-upload:hover {
    border-color:    var(--mantine-color-blue-4);
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-blue-1) 30%, transparent),
                         color-mix(in srgb, var(--mantine-color-blue-9) 16%, transparent)
                     );
}

.sg-frame-counts {
    display:         flex;
    gap:             8px;
    flex-wrap:       wrap;
}

.sg-gen-status {
    padding:         10px 12px;
    background:      light-dark(
                         var(--mantine-color-gray-0),
                         var(--mantine-color-dark-7)
                     );
    border-left:     3px solid var(--mantine-color-blue-4);
    border-radius:   6px;
    min-height:      40px;
}

/* ============================================================
 * Logs tab — live event stream alongside Controls.
 * Rows are appended clientside (innerHTML) for cheap painting.
 * ============================================================ */

.sg-log-now {
    display:         flex;
    align-items:     center;
    gap:             8px;
    padding:         8px 12px;
    border-radius:   8px;
    background:      light-dark(
                         var(--mantine-color-gray-0),
                         var(--mantine-color-dark-7)
                     );
    border:          1px solid var(--mantine-color-default-border);
    font-size:       12px;
    color:           var(--mantine-color-text);
}

.sg-log-now--live {
    border-color:    var(--mantine-color-blue-4);
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-blue-1) 35%, transparent),
                         color-mix(in srgb, var(--mantine-color-blue-9) 18%, transparent)
                     );
}

.sg-log-now--done {
    border-color:    var(--mantine-color-green-6);
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-green-1) 35%, transparent),
                         color-mix(in srgb, var(--mantine-color-green-9) 18%, transparent)
                     );
}

.sg-log-now--with-errors {
    border-color:    var(--mantine-color-orange-6);
    background:      light-dark(
                         color-mix(in srgb, var(--mantine-color-orange-1) 35%, transparent),
                         color-mix(in srgb, var(--mantine-color-orange-9) 18%, transparent)
                     );
}

.sg-log-now-dot {
    width:           8px;
    height:          8px;
    border-radius:   50%;
    background:      var(--mantine-color-dimmed);
    flex-shrink:     0;
}

.sg-log-now-dot--live {
    background:      var(--mantine-color-blue-4);
    box-shadow:      0 0 0 0 var(--mantine-color-blue-4);
    animation:       sg-log-pulse 1.4s ease-out infinite;
}

.sg-log-now-dot--ok   { background: var(--mantine-color-green-6); }
.sg-log-now-dot--warn { background: var(--mantine-color-orange-6); }

@keyframes sg-log-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mantine-color-blue-4) 70%, transparent); }
    70%  { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.sg-log-now-txt code {
    font-family:     ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size:       11px;
    padding:         1px 4px;
    border-radius:   4px;
    background:      light-dark(
                         var(--mantine-color-white),
                         var(--mantine-color-dark-6)
                     );
}

.sg-log-body {
    display:         flex;
    flex-direction:  column;
    gap:             2px;
    padding:         6px 4px 80px;
    font-family:     ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size:       11.5px;
    line-height:     1.5;
}

.sg-log-empty {
    padding:         24px 12px;
    text-align:      center;
    color:           var(--mantine-color-dimmed);
    font-size:       12px;
    font-style:      italic;
}

.sg-log-row {
    display:         grid;
    grid-template-columns: 72px 16px max-content 1fr;
    align-items:     center;
    gap:             8px;
    padding:         4px 8px;
    border-radius:   4px;
    border-left:     2px solid transparent;
    transition:      background 80ms ease;
}

.sg-log-row:hover {
    background:      light-dark(
                         var(--mantine-color-gray-1),
                         var(--mantine-color-dark-6)
                     );
}

.sg-log-row--success { border-left-color: var(--mantine-color-green-6); }
.sg-log-row--error   { border-left-color: var(--mantine-color-red-6);
                       background:        light-dark(
                                              color-mix(in srgb, var(--mantine-color-red-1) 25%, transparent),
                                              color-mix(in srgb, var(--mantine-color-red-9) 14%, transparent)
                                          ); }
.sg-log-row--info    { border-left-color: var(--mantine-color-blue-6); }

.sg-log-ts {
    color:           var(--mantine-color-dimmed);
    font-size:       10.5px;
    letter-spacing:  0.02em;
}

.sg-log-icon {
    width:           14px;
    height:          14px;
    display:         inline-block;
    -webkit-mask-position: center;
    mask-position:   center;
    -webkit-mask-repeat:   no-repeat;
    mask-repeat:     no-repeat;
    -webkit-mask-size:     contain;
    mask-size:       contain;
}

/* Icon shapes via masked SVG so the colour follows the row's level. */
.sg-log-icon.mdi-check-circle {
    background-color: var(--mantine-color-green-6);
    -webkit-mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2A10 10 0 1 0 22 12 10 10 0 0 0 12 2zm-1.5 14.5L5 11l1.41-1.41L10.5 13.67l7.09-7.08L19 8z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2A10 10 0 1 0 22 12 10 10 0 0 0 12 2zm-1.5 14.5L5 11l1.41-1.41L10.5 13.67l7.09-7.08L19 8z'/%3E%3C/svg%3E");
}
.sg-log-icon.mdi-alert-circle {
    background-color: var(--mantine-color-red-6);
    -webkit-mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm1 15h-2v-2h2zm0-4h-2V7h2z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm1 15h-2v-2h2zm0-4h-2V7h2z'/%3E%3C/svg%3E");
}
.sg-log-icon.mdi-information {
    background-color: var(--mantine-color-blue-6);
    -webkit-mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2z'/%3E%3C/svg%3E");
}
.sg-log-icon.mdi-circle-medium {
    background-color: var(--mantine-color-dimmed);
    -webkit-mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle fill='black' cx='12' cy='12' r='5'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle fill='black' cx='12' cy='12' r='5'/%3E%3C/svg%3E");
}

.sg-log-key {
    font-family:     inherit;
    font-size:       10.5px;
    padding:         1px 5px;
    border-radius:   3px;
    background:      light-dark(
                         var(--mantine-color-white),
                         var(--mantine-color-dark-6)
                     );
    border:          1px solid var(--mantine-color-default-border);
    color:           var(--mantine-color-text);
    white-space:     nowrap;
}

.sg-log-msg {
    color:           var(--mantine-color-text);
    white-space:     pre-wrap;
    word-break:      break-word;
}

.sg-log-dryrun {
    margin-left:     6px;
    padding:         0 5px;
    border-radius:   3px;
    background:      light-dark(
                         var(--mantine-color-yellow-1),
                         color-mix(in srgb, var(--mantine-color-yellow-9) 35%, transparent)
                     );
    color:           light-dark(
                         var(--mantine-color-yellow-9),
                         var(--mantine-color-yellow-2)
                     );
    font-size:       10px;
    text-transform:  uppercase;
    letter-spacing:  0.05em;
}

/* Brief green flash on the copy-log button after a successful clipboard
 * write — gives the user immediate visual feedback (the clientside
 * callback strips the class after 1.5s). */
.sg-log-copy-btn--ok {
    color:           var(--mantine-color-green-6) !important;
    background:      light-dark(
                         var(--mantine-color-green-1),
                         color-mix(in srgb, var(--mantine-color-green-9) 35%, transparent)
                     ) !important;
}

/* ============================================================
 * Mobile Controls + Logs bottom sheet (xs–sm, < md).
 *
 * The drawer holds a dmc.Tabs whose active panel must fill the
 * sheet height so the Controls form and the log stream each own
 * their internal ScrollArea — same flush, no-double-scroll shape
 * as the ``.ts-admin-drawer-body`` sheet on /admin/map/tilesets.
 * ============================================================ */
.sg-controls-drawer-body {
    padding:         0 !important;
    height:          100%;
    display:         flex;
    flex-direction:  column;
    overflow:        hidden;
}

/* dmc.Tabs root: column so the TabsList sits above a flexible panel. */
.sg-drawer-tabs {
    flex:            1 1 auto;
    min-height:      0;
    display:         flex;
    flex-direction:  column;
}

/* The active panel takes the remaining height; ``min-height: 0`` lets
 * the pane's own ScrollArea scroll instead of overflowing the sheet. */
.sg-drawer-tabs-panel {
    flex:            1 1 auto;
    min-height:      0;
    overflow:        hidden;
}
