/* Build Your Own Mosque (/mosque): the construction studio. Sky Garden glass and clay around a board that is always
   drawn in its own colours (the art keeps its look in every theme; the board's sky sets the mood). Dense: the bar, the
   kit, the board and the notebook share one screen on a desktop and stack on phones. Logical properties throughout so
   Arabic and Urdu mirror; the board itself never mirrors (a drawing, like a photo). */

.mq { --mq-r: 26px; display: grid; gap: 18px; }
.mq-art { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

/* ---------------- hero ---------------- */
.mq-hero {
    position: relative; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px 26px; align-items: end;
    padding: 18px 22px; border-radius: var(--radius-l); overflow: hidden;
    background:
        radial-gradient(60% 120% at 100% 0%, color-mix(in srgb, var(--sky) 28%, transparent), transparent 60%),
        radial-gradient(50% 90% at 0% 100%, color-mix(in srgb, var(--sun) 26%, transparent), transparent 60%),
        linear-gradient(150deg, var(--glass-strong), color-mix(in srgb, var(--sky-soft) 70%, var(--paper)));
    box-shadow: inset 0 0 0 1.5px var(--glass-edge), var(--shadow);
}
.mq-hero::after {
    content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 220px; height: 220px; opacity: .14; pointer-events: none;
    background: conic-gradient(from 22.5deg, var(--sky-deep) 0 12.5%, transparent 0 25%, var(--sky-deep) 0 37.5%, transparent 0 50%, var(--sky-deep) 0 62.5%, transparent 0 75%, var(--sky-deep) 0 87.5%, transparent 0);
    clip-path: polygon(50% 0, 61% 27%, 85% 15%, 73% 39%, 100% 50%, 73% 61%, 85% 85%, 61% 73%, 50% 100%, 39% 73%, 15% 85%, 27% 61%, 0 50%, 27% 39%, 15% 15%, 39% 27%);
}
.mq-isle {
    display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 999px; text-decoration: none;
    font-family: var(--font-display); font-weight: 600; font-size: .92rem; color: var(--sky-deep);
    background: var(--glass-strong); box-shadow: inset 0 0 0 1.5px var(--glass-edge), var(--shadow-s);
}
.mq-isle img { width: 34px; height: 34px; object-fit: contain; }
:root[data-theme="dark"] .mq-isle { color: #9FD6FF; }
.mq-hero h1 {
    margin: 8px 0 4px; font-family: var(--font-display); font-size: clamp(2rem, 4.4vw, 3.4rem); line-height: 1; letter-spacing: -.02em;
    background: linear-gradient(95deg, var(--sky-deep), var(--grape-deep) 45%, var(--coral-deep) 80%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root[data-theme="dark"] .mq-hero h1 { background-image: linear-gradient(95deg, #9FD6FF, #BCA8FF 45%, #FFB3A0 80%); }
:root[lang="ar"] .mq-hero h1, :root[lang="ur"] .mq-hero h1 { line-height: 1.45; letter-spacing: 0; }
.mq-lead { margin: 0; max-width: 720px; font-family: var(--font-read); font-size: 1.04rem; color: var(--ink-soft); }
.mq-hero-side { display: grid; gap: 10px; position: relative; z-index: 1; }
.mq-guide .k-mascot-svg { width: 56px; height: 70px; }
.mq-guide .k-bubble { font-size: .98rem; padding: 9px 13px; }
.mq-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.mq-facts li { display: grid; justify-items: center; padding: 6px 4px; border-radius: 16px; background: var(--paper); box-shadow: var(--shadow-s); text-align: center; }
.mq-facts b { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.1; color: var(--sky-deep); }
:root[data-theme="dark"] .mq-facts b { color: var(--sun); }
.mq-facts span { font-size: .72rem; font-weight: 700; color: var(--ink-soft); line-height: 1.15; }

/* ---------------- studio layout ---------------- */
.mq-studio {
    display: grid; gap: 12px; align-items: start;
    grid-template-columns: 236px minmax(0, 1fr) 278px;
    grid-template-areas: "bar bar bar" "kit stage side";
}
.mq-bar { grid-area: bar; }
.mq-kit { grid-area: kit; }
.mq-stage-wrap { grid-area: stage; }
.mq-side { grid-area: side; }
.mq-panel-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-family: var(--font-display); font-size: 1.05rem; }
.mq-panel-title small { font-family: var(--font-body); font-weight: 700; font-size: .78rem; color: var(--ink-soft); }

/* ---------------- the bar ---------------- */
.mq-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 22px;
    background: var(--glass-strong); box-shadow: inset 0 0 0 1.5px var(--glass-edge), var(--shadow);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.mq-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 14px; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.mq-seg-btn {
    display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 4px 10px; border: 0; border-radius: 11px; cursor: pointer;
    background: transparent; color: var(--ink-soft); font-family: var(--font-display); font-weight: 600; font-size: .92rem;
}
.mq-seg-btn svg, .mq-seg-btn .k-ico { width: 20px; height: 20px; flex: none; }
.mq-seg-btn[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 4px 10px -6px rgba(43, 35, 80, .5), inset 0 0 0 2px var(--sky); }
.mq-time--sunset .k-ico { color: #FF8A65; }
.mq-time--night .k-ico { color: #8D72F0; }
.mq-times .mq-seg-btn span { display: none; }
.mq-places { display: inline-flex; gap: 3px; }
.mq-place {
    position: relative; width: 52px; height: 38px; padding: 0; border: 0; border-radius: 11px; overflow: hidden; cursor: pointer; background: var(--sky-soft);
    box-shadow: inset 0 0 0 1.5px var(--line); transition: transform .2s var(--ease-bounce);
}
.mq-place svg { display: block; width: 100%; height: 100%; }
.mq-place span { position: absolute; inset: auto 0 0; padding: 0 2px; font-size: .58rem; font-weight: 800; line-height: 1.5; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); background: linear-gradient(transparent, rgba(30, 24, 70, .55)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mq-place:hover { transform: translateY(-2px); }
.mq-place[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--paper), 0 0 0 5px var(--sky); }
.mq[data-board="inside"] [data-outside-only] { opacity: .35; pointer-events: none; }
.mq-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: .9rem; color: var(--ink-soft); }
.mq-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mq-switch-track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: background .2s; }
.mq-switch-track i { position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); transition: inset-inline-start .2s var(--ease-bounce); }
.mq-switch input:checked + .mq-switch-track { background: var(--grape); }
.mq-switch input:checked + .mq-switch-track i { inset-inline-start: 21px; }
.mq-switch input:focus-visible + .mq-switch-track { outline: 4px solid var(--sun); outline-offset: 2px; }
.mq-switch-text { display: inline-flex; align-items: center; gap: 4px; }
.mq-switch-text svg { width: 20px; height: 20px; color: var(--grape); }
.mq-history { display: inline-flex; gap: 4px; }
.mq-icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 13px; background: var(--paper); color: var(--ink); cursor: pointer; box-shadow: 0 5px 10px -7px rgba(43, 35, 80, .6); }
.mq-icon-btn .k-ico { width: 22px; height: 22px; }
.mq-icon-btn:disabled { opacity: .38; cursor: default; }
.mq-flip-x .k-ico { transform: scaleX(-1); }
.mq-keep { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-inline-start: auto; }
.mq-chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px 4px 9px; border: 0; border-radius: 13px; cursor: pointer;
    background: var(--paper); color: var(--ink); font-family: var(--font-display); font-weight: 600; font-size: .9rem; box-shadow: 0 5px 10px -7px rgba(43, 35, 80, .6);
    transition: transform .2s var(--ease-bounce);
}
.mq-chip:hover { transform: translateY(-2px); }
.mq-chip svg, .mq-chip .k-ico { width: 20px; height: 20px; flex: none; }
.mq-chip--save { background: var(--sun); color: #2B2350; }
.mq-chip--quiet { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink-soft); }
.mq-seg-btn:focus-visible, .mq-place:focus-visible, .mq-icon-btn:focus-visible, .mq-chip:focus-visible, .mq-fam:focus-visible, .mq-piece-btn:focus-visible,
.mq-tool:focus-visible, .mq-cardchip:focus-visible, .mq-link-btn:focus-visible { outline: 4px solid var(--sun); outline-offset: 2px; }

/* ---------------- the kit ---------------- */
.mq-kit {
    position: sticky; top: 88px; display: grid; gap: 10px; padding: 12px; border-radius: var(--mq-r); max-height: calc(100vh - 100px); overflow: auto;
    background: var(--glass-strong); box-shadow: inset 0 0 0 1.5px var(--glass-edge), var(--shadow); scrollbar-width: thin;
}
.mq-kit .mq-panel-title { margin: 0; }
.mq-families { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.mq-fam {
    position: relative; display: grid; justify-items: center; gap: 1px; padding: 6px 2px 4px; border: 0; border-radius: 14px; cursor: pointer;
    background: var(--paper); color: var(--ink-soft); font-family: var(--font-display); font-weight: 600; font-size: .7rem; line-height: 1.1;
    box-shadow: inset 0 0 0 1.5px var(--line); transition: transform .2s var(--ease-bounce);
}
.mq-fam svg { width: 100%; height: 34px; filter: drop-shadow(0 3px 3px rgba(43, 35, 80, .25)); }
.mq-fam span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mq-fam small { position: absolute; top: 3px; inset-inline-end: 5px; font-size: .6rem; font-weight: 800; color: var(--ink-faint); }
.mq-fam:hover { transform: translateY(-2px); }
.mq-fam[aria-pressed="true"] { color: var(--ink); background: linear-gradient(180deg, var(--paper), var(--sky-soft)); box-shadow: inset 0 0 0 2.5px var(--sky); }
.mq-pieces { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px; border-radius: 18px; background: color-mix(in srgb, var(--sky) 10%, transparent); }
.mq-piece-btn {
    display: grid; gap: 2px; padding: 6px; border: 0; border-radius: 14px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
    background: var(--paper); color: var(--ink); font-family: var(--font-body); font-weight: 700; font-size: .74rem; line-height: 1.15; text-align: center;
    box-shadow: 0 6px 12px -9px rgba(43, 35, 80, .7); transition: transform .2s var(--ease-bounce), box-shadow .2s;
}
.mq-piece-btn.is-wide { grid-column: 1 / -1; }
.mq-piece-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 0 0 2px var(--sky), 0 10px 16px -10px rgba(43, 35, 80, .7); }
.mq-piece-btn:active { cursor: grabbing; }
.mq-thumb { display: grid; place-items: center; height: 74px; border-radius: 10px; background: radial-gradient(circle at 50% 120%, #DFF3FF, #F6FBFF 70%); }
.mq-piece-btn.is-wide .mq-thumb { height: 44px; }
:root[data-theme="dark"] .mq-thumb { background: radial-gradient(circle at 50% 120%, #4B5FB0, #3A3486 70%); }
.mq-thumb svg { display: block; width: 100%; height: 64px; filter: drop-shadow(0 4px 4px rgba(43, 35, 80, .22)); }
.mq-piece-btn.is-wide .mq-thumb svg { height: 34px; }
.mq-kit-hint { margin: 0; font-size: .78rem; font-weight: 600; color: var(--ink-faint); }

/* ---------------- the board ---------------- */
.mq-stage-wrap { display: grid; gap: 6px; min-width: 0; }
.mq-stage {
    position: relative; border-radius: 28px; overflow: hidden; isolation: isolate; background: #BFE6FF;
    box-shadow: 0 0 0 6px var(--paper), 0 0 0 8px color-mix(in srgb, var(--sky) 45%, transparent), var(--shadow-l);
    color-scheme: light;
}
.mq-board { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.mq-board:focus-visible { box-shadow: inset 0 0 0 5px var(--sun); }
.mq-piece { cursor: grab; outline: none; }
.mq-piece:active { cursor: grabbing; }
.mq-hit { fill: transparent; }
.mq-piece:hover > use { filter: brightness(1.05) drop-shadow(0 0 6px rgba(255, 255, 255, .8)); }
.mq-piece.is-selected > use { filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 10px rgba(255, 79, 160, .7)); }
.mq-piece:focus-visible > .mq-hit { stroke: #FFC84A; stroke-width: 5; stroke-dasharray: 10 6; }
.mq-piece.is-new > use { animation: mq-land .45s var(--ease-bounce); transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes mq-land { 0% { transform: translateY(-24px) scale(.85); opacity: .3; } 100% { transform: none; opacity: 1; } }
.mq-sel { fill: none; stroke: #FF4FA0; stroke-width: 3; stroke-dasharray: 9 6; animation: mq-ants 1s linear infinite; pointer-events: none; }
@keyframes mq-ants { to { stroke-dashoffset: -30; } }
.mq-guides { pointer-events: none; }
.mq-grid { opacity: 0; transition: opacity .2s; }
.mq-axis { stroke: #FF4FA0; stroke-width: 2.5; stroke-dasharray: 12 8; opacity: 0; transition: opacity .2s; }
.mq-snapline { stroke: #FFC84A; stroke-width: 3; stroke-dasharray: 14 8; opacity: 0; }
.mq.is-dragging .mq-grid { opacity: .55; }
.mq.is-mirror .mq-axis { opacity: .5; }
.mq.is-axis .mq-axis { opacity: 1; stroke-width: 4; }
.mq.is-line .mq-snapline { opacity: 1; }
.mq-tint, .mq-glow { pointer-events: none; }
.mq-glow { mix-blend-mode: screen; }

.mq-qibla {
    position: absolute; top: 58px; left: 50%; transform: translateX(-50%); display: none; align-items: center; gap: 6px; margin: 0; padding: 4px 12px 4px 8px;
    border-radius: 999px; background: rgba(255, 255, 255, .88); color: #1A6F5B; font-family: var(--font-display); font-weight: 700; font-size: .8rem; white-space: nowrap;
    box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .4); pointer-events: none;
}
.mq-qibla svg { width: 16px; height: 16px; }
.mq[data-board="inside"] .mq-qibla { display: inline-flex; }
.mq-empty {
    position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 6px; max-width: min(380px, 80%);
    padding: 16px 20px; border-radius: 22px; text-align: center; background: rgba(255, 255, 255, .9); color: #2B2350; box-shadow: 0 16px 30px -16px rgba(43, 35, 80, .6);
    pointer-events: auto;
}
.mq-empty b { font-family: var(--font-display); font-size: 1.15rem; }
.mq-empty span { font-family: var(--font-read); font-size: .92rem; color: #554B86; }
.mq-loading, .mq-error { position: absolute; inset: auto 0 14px; margin: 0; text-align: center; font-weight: 700; color: #2B2350; }
.mq-error { display: none; color: #E0503F; background: rgba(255, 255, 255, .9); padding: 10px; inset: 40% 10% auto; border-radius: 16px; }
.mq[data-state="ready"] .mq-loading, .mq[data-state="error"] .mq-loading { display: none; }
.mq[data-state="error"] .mq-error { display: block; }
.mq:not([data-state="ready"]) .mq-kit, .mq:not([data-state="ready"]) .mq-bar, .mq:not([data-state="ready"]) .mq-side { opacity: .55; pointer-events: none; }
.mq:not([data-state="ready"]) .mq-empty { display: none; }

.mq-tools {
    position: absolute; z-index: 3; display: flex; align-items: center; gap: 4px; padding: 5px 6px 5px 12px; border-radius: 16px;
    background: rgba(255, 255, 255, .95); color: #2B2350; box-shadow: 0 12px 24px -12px rgba(43, 35, 80, .7), inset 0 0 0 1.5px rgba(255, 79, 160, .35);
}
.mq-tools-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); font-size: .82rem; margin-inline-end: 4px; }
.mq-tool { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 11px; background: #F1ECFF; color: #2B2350; cursor: pointer; }
.mq-tool svg, .mq-tool .k-ico { width: 20px; height: 20px; }
.mq-tool:hover { background: #E2D9FF; }
.mq-tool:disabled { opacity: .3; cursor: default; }
.mq-tool--remove { background: #FFE8E4; color: #C63A2A; }
.mq-tool--done { background: #DDF8EE; color: #1A8F70; }
.mq-hint { margin: 2px 0 0; font-family: var(--font-read); font-weight: 600; font-size: .9rem; color: var(--ink-soft); text-align: center; }
.mq-keys { margin: 0; font-size: .76rem; color: var(--ink-faint); text-align: center; }

.mq-ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; opacity: .75; filter: drop-shadow(0 12px 14px rgba(43, 35, 80, .4)); }
.mq-ghost.is-over { opacity: .95; }
.mq-ghost svg { overflow: visible; }

/* ---------------- the side: numbers, card, notebook, finishing ---------------- */
.mq-side { display: grid; gap: 10px; }
.mq-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mq-stat, .mq-sym { padding: 8px 10px; border-radius: 18px; background: var(--glass-strong); box-shadow: inset 0 0 0 1.5px var(--glass-edge), var(--shadow-s); }
.mq-stat { display: grid; }
.mq-stat b { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.1; color: var(--grape-deep); }
:root[data-theme="dark"] .mq-stat b { color: var(--sun); }
.mq-stat span { font-size: .74rem; font-weight: 700; color: var(--ink-soft); }
.mq-sym { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.mq-sym-ring {
    --pct: 0%; position: relative; display: grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 50%;
    background: conic-gradient(var(--grape) var(--pct), color-mix(in srgb, var(--grape) 16%, var(--paper)) 0); transition: --pct .4s;
}
.mq-sym-ring i { position: absolute; inset: 6px; border-radius: 50%; background: var(--paper); }
.mq-sym-ring b { position: relative; font-family: var(--font-display); font-size: .84rem; }
.mq-sym-ring.is-perfect { background: conic-gradient(#FFC84A 100%, transparent 0); box-shadow: 0 0 16px rgba(255, 200, 74, .8); }
.mq-sym-text { display: grid; line-height: 1.2; }
.mq-sym-text b { font-family: var(--font-display); }
.mq-sym-text small { font-size: .75rem; color: var(--ink-soft); font-weight: 600; }
.mq-card {
    position: relative; padding: 14px 16px; border-radius: 22px; color: #2B2350;
    background: linear-gradient(160deg, #FFFDF6, #FFF0CF); box-shadow: 0 16px 28px -18px rgba(150, 100, 20, .7), inset 0 0 0 1.5px rgba(227, 158, 0, .3);
}
.mq-card::before {
    content: ""; position: absolute; inset-inline-end: 12px; top: 12px; width: 28px; height: 28px; opacity: .35;
    background: #E39E00; clip-path: polygon(50% 0, 61% 27%, 85% 15%, 73% 39%, 100% 50%, 73% 61%, 85% 85%, 61% 73%, 50% 100%, 39% 73%, 15% 85%, 27% 61%, 0 50%, 27% 39%, 15% 15%, 39% 27%);
}
.mq-card.is-new { animation: mq-card .6s var(--ease-bounce); }
@keyframes mq-card { 0% { transform: rotate(-3deg) scale(.9); } 100% { transform: none; } }
.mq-card-ribbon { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 4px; padding: 2px 10px; border-radius: 999px; background: #FF7F6E; color: #fff; font-weight: 800; font-size: .74rem; }
.mq-card-ribbon .k-ico { width: 14px; height: 14px; }
.mq-card h3 { margin: 0 0 4px; padding-inline-end: 32px; font-family: var(--font-display); font-size: 1.12rem; }
.mq-card p { margin: 0; font-family: var(--font-read); font-size: .94rem; line-height: 1.45; color: #4A4177; }
.mq-notebook { padding: 12px; border-radius: 22px; background: var(--glass-strong); box-shadow: inset 0 0 0 1.5px var(--glass-edge), var(--shadow-s); }
.mq-cards { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.mq-cardchip {
    min-height: 30px; padding: 3px 9px; border: 0; border-radius: 10px; cursor: pointer; font-family: var(--font-body); font-weight: 700; font-size: .74rem;
    background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-faint);
}
.mq-cardchip:not(.is-open) span { filter: blur(.4px); opacity: .55; }
.mq-cardchip.is-open { background: #FFF3CF; color: #6A4A00; box-shadow: inset 0 0 0 1.5px rgba(227, 158, 0, .45); }
.mq-cardchip.is-current { background: #FFC84A; color: #2B2350; }
.mq-note { margin: 8px 0 0; font-size: .76rem; font-weight: 600; color: var(--ink-faint); }
.mq-finish { display: grid; gap: 6px; padding: 12px; border-radius: 22px; background: var(--glass); box-shadow: inset 0 0 0 1.5px var(--glass-edge); }
.mq-done { width: 100%; justify-content: center; }
.mq-status { min-height: 1.2em; margin: 0; font-size: .82rem; font-weight: 700; color: var(--mint-deep); text-align: center; }
:root[data-theme="dark"] .mq-status { color: #7FE3C8; }
.mq-privacy { display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: .76rem; font-weight: 600; color: var(--ink-soft); }
.mq-privacy .k-ico { width: 1.2em; height: 1.2em; flex: none; }

/* ---------------- templates ---------------- */
.mq-templates-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 10px; }
.mq-templates-head h2 { margin: 0; }
.mq-templates-head p { margin: 0; flex: 1 1 320px; font-family: var(--font-read); color: var(--ink-soft); }
.mq-link-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--grape-deep); font-weight: 800; cursor: pointer; }
:root[data-theme="dark"] .mq-link-btn { color: var(--sun); }
.mq-link-btn .k-ico { width: 18px; height: 18px; }
.mq-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.mq-tpl {
    display: grid; grid-template-rows: auto 1fr; border-radius: 26px; overflow: hidden;
    background: linear-gradient(165deg, var(--paper) 40%, var(--ts)); box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--t) 22%, transparent), var(--shadow);
    transition: transform .25s var(--ease-bounce);
}
.mq-tpl:hover { transform: translateY(-4px); }
.mq-tpl-art { position: relative; }
.mq-tpl-art svg { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; }
.mq-tpl-art .mq-tpl-inside {
    position: absolute; inset-inline-end: 10px; bottom: -22px; width: 36%; border-radius: 12px; border: 3px solid var(--paper);
    box-shadow: 0 10px 18px -10px rgba(43, 35, 80, .7); transform: rotate(3deg);
}
.mq-tpl-text { display: grid; align-content: start; gap: 4px; padding: 12px 16px 16px; }
.mq-tpl-style { margin: 0; padding-inline-end: 38%; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--td); }
:root[lang="ar"] .mq-tpl-style, :root[lang="ur"] .mq-tpl-style { text-transform: none; letter-spacing: 0; }
:root[data-theme="dark"] .mq-tpl-style { color: var(--t); }
.mq-tpl h3 { margin: 0; font-family: var(--font-display); font-size: 1.2rem; line-height: 1.15; }
.mq-tpl-text p:not(.mq-tpl-style) { margin: 0 0 6px; font-family: var(--font-read); font-size: .92rem; color: var(--ink-soft); }
.mq-tpl .k-btn { justify-self: start; }

/* ---------------- dialogs ---------------- */
.mq-dialog { width: min(520px, calc(100vw - 32px)); }
.mq-dialog--wide { width: min(760px, calc(100vw - 32px)); }
.mq-dialog-body { display: grid; gap: 12px; padding: 22px; }
.mq-dialog h2 { margin: 0; font-family: var(--font-display); font-size: 1.5rem; }
.mq-dialog-preview svg { display: block; width: 100%; height: auto; border-radius: 16px; }
.mq-field { display: grid; gap: 4px; font-weight: 700; }
.mq-field input { min-height: 46px; padding: 8px 14px; border: 0; border-radius: 14px; font: inherit; color: var(--ink); background: var(--paper); box-shadow: inset 0 0 0 2px var(--line); }
.mq-field input:focus { outline: 4px solid var(--sun); outline-offset: 1px; }
.mq-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.mq-designs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; max-height: 60vh; overflow: auto; }
.mq-design { display: grid; gap: 6px; padding: 8px; border-radius: 18px; background: var(--paper); box-shadow: var(--shadow-s); }
.mq-design-art svg { display: block; width: 100%; height: auto; border-radius: 12px; }
.mq-design-text { display: grid; }
.mq-design-text b { font-family: var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mq-design-text small { color: var(--ink-soft); font-weight: 600; }
.mq-design-actions { display: flex; align-items: center; gap: 6px; }
.mq-designs-empty { margin: 0; padding: 20px; text-align: center; font-family: var(--font-read); color: var(--ink-soft); }
.mq-print-sheet { display: none; }

/* ---------------- smaller screens ---------------- */
@media (max-width: 1640px) {
    .mq-chip[data-export] span, .mq-chip[data-print] span, .mq-chip[data-reset] span { display: none; }
    .mq-chip[data-export], .mq-chip[data-print], .mq-chip[data-reset] { padding: 4px 9px; }
}
@media (max-width: 1240px) {
    .mq-studio { grid-template-columns: 212px minmax(0, 1fr) 250px; }
}
@media (max-width: 1100px) {
    .mq-studio { grid-template-columns: 212px minmax(0, 1fr); grid-template-areas: "bar bar" "kit stage" "side side"; }
    .mq-side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .mq-stats { grid-column: 1 / -1; grid-template-columns: 1fr 1fr 2fr; }
    .mq-sym { grid-column: auto; }
    .mq-hero { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .mq-studio { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "stage" "kit" "side"; }
    .mq-kit { position: static; max-height: none; }
    .mq-families { display: flex; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
    .mq-fam { flex: 0 0 74px; }
    .mq-pieces { display: flex; overflow-x: auto; scrollbar-width: none; }
    .mq-piece-btn { flex: 0 0 108px; touch-action: pan-x; }
    .mq-piece-btn.is-wide { flex-basis: 190px; }
    .mq-side { grid-template-columns: 1fr; }
    .mq-stats { grid-template-columns: 1fr 1fr; }
    .mq-sym { grid-column: 1 / -1; }
    .mq-keep { margin-inline-start: 0; }
    .mq-keys { display: none; }
    .mq-hero { padding: 14px; }
    .mq-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .mq-bar { gap: 6px; padding: 6px; }
    .mq-seg-btn { padding: 4px 9px; }
    .mq-switch-text { font-size: .8rem; }
    .mq-chip { padding: 4px 9px; }
    .mq-chip:not(.mq-chip--save) span { display: none; }
    .mq-places { order: 5; width: 100%; justify-content: space-between; }
    .mq-place { flex: 1; }
    .mq-stage { border-radius: 18px; }
    .mq-tools-name { display: none; }
    .mq-qibla { top: 40px; font-size: .68rem; }
    .mq-empty { padding: 10px 12px; }
    .mq-empty span { display: none; }
    /* On a phone the building plot comes first: Noor's spoken welcome stays, the long lead and the kit facts step aside. */
    .mq-lead, .mq-facts { display: none; }
    .mq-hero h1 { margin-bottom: 4px; }
}
@media (prefers-reduced-motion: reduce) {
    .mq-sel, .mq-piece.is-new > use, .mq-card.is-new { animation: none; }
    .mq-place, .mq-chip, .mq-fam, .mq-piece-btn, .mq-tpl, .mq-switch-track i { transition: none; }
}

/* ---------------- printing: the design only, outside then inside ---------------- */
@media print {
    @page { margin: 12mm; }
    .k-crumbs, .sg-mainsite, .k-foot, .k-top { display: none !important; }
    .mq > :not(.mq-print-sheet) { display: none !important; }
    .mq-print-sheet { display: block !important; color: #2B2350; }
    .mq-print-sheet h1 { margin: 0 0 6mm; font-family: var(--font-display); font-size: 20pt; text-align: center; }
    .mq-print-sheet figure { margin: 0 0 6mm; break-inside: avoid; text-align: center; }
    .mq-print-sheet img { display: block; width: 100%; height: auto; max-height: 120mm; object-fit: contain; border-radius: 4mm; }
    .mq-print-sheet figcaption, .mq-print-sheet p { margin-top: 2mm; font-size: 10pt; text-align: center; }
}
