.tool-page,
.tool-page__grid,
.tool-workspace {
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
}

:root {
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --bg2: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #4f46e5;
}

#tool-root {
    color: #1e293b;
}

#tool-root .stack,
#tool-root .f-stack {
    width: 100%;
    max-width: none;
    gap: 1rem;
}

#tool-root .lbl,
#tool-root label.lbl,
#tool-root .f-lbl {
    color: var(--text);
    font-weight: 600;
    margin-bottom: 0.35rem;
}

#tool-root .muted,
#tool-root .dz__sub,
#tool-root .dz__state,
#tool-root .dz__picked {
    color: var(--muted);
    font-size: 0.8125rem;
}

#tool-root .dz__title {
    color: var(--text);
    font-weight: 600;
}

#tool-root .ta,
#tool-root textarea.ta,
#tool-root .inp,
#tool-root input.inp,
#tool-root select.inp,
#tool-root .f-inp,
#tool-root .f-ta {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    color: var(--text);
}

#tool-root textarea.ta,
#tool-root .ta {
    min-height: clamp(8rem, 28vh, 22rem);
}

#tool-root pre.out,
#tool-root .out,
#tool-root .mono {
    width: 100%;
    max-width: 100%;
    min-height: 5rem;
    max-height: min(45vh, 28rem);
    overflow: auto;
    box-sizing: border-box;
    color: #1e293b;
}

#tool-root .dz { width: 100%; }
#tool-root .dz__sub { max-width: none; }
#tool-root .cols,
#tool-root .row,
#tool-root .stat-grid { width: 100%; }

#tool-root .row {
    gap: 0.65rem;
}

#tool-root .row .btn,
#tool-root .row .f-btn {
    flex-shrink: 0;
}

#tool-root .md-preview {
    width: 100%;
    min-height: clamp(6rem, 22vh, 16rem);
    color: var(--text);
}

#tool-root input[type="range"] {
    flex: 1;
    min-width: 8rem;
    max-width: 100%;
    accent-color: var(--accent);
}

#tool-root canvas,
#tool-root img:not(.dz-thumb img) {
    max-width: 100%;
    height: auto;
}

#tool-root strong,
#tool-root b {
    color: var(--text);
}

#tool-root p {
    color: #334155;
}

@media (max-width: 640px) {
    .tool-workspace { padding: 0.75rem; }
    #tool-root .row {
        flex-direction: column;
        align-items: stretch;
    }
    #tool-root .row .inp,
    #tool-root .row select.inp {
        max-width: none !important;
        width: 100%;
    }
    #tool-root .row .btn,
    #tool-root .row .btn--ghost,
    #tool-root .row .f-btn,
    #tool-root .row .f-btn-outline {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
    #tool-root .cropper-container,
    #tool-root .cropper-wrap-box,
    #tool-root .cropper-canvas,
    #tool-root .cropper-drag-box {
        max-width: 100% !important;
    }
    #pdf-links a {
        display: block;
        padding: 0.5rem 0;
        word-break: break-all;
    }
}

.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.wrap-row { gap: 0.5rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .cols { grid-template-columns: 1fr; } }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.65rem;
}
.stat-grid div {
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg2);
    text-align: center;
    color: var(--text);
}
.stat-grid strong { display: block; font-size: 1.25rem; color: var(--accent); }
.stat-grid span { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }

.qrbox { padding: 1rem; background: #ffffff; border-radius: 0.5rem; display: inline-block; min-height: 120px; border: 1px solid var(--border); }
.swatch { height: 48px; border-radius: 0.5rem; border: 1px solid var(--border); }
.md-preview {
    min-height: 120px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--bg2);
    color: var(--text);
}
.md-preview code { background: #eef2ff; color: #4338ca; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.9em; }

.dz {
    position: relative;
    border: 2px dashed var(--border-strong);
    border-radius: 0.75rem;
    padding: 1.5rem 1rem;
    margin-bottom: 0.25rem;
    background: var(--bg2);
    transition: border-color 0.15s, background 0.15s;
}
.dz:hover { border-color: #818cf8; background: #eef2ff; }
.dz--drag { border-color: var(--accent); background: rgb(99 102 241 / 0.08); box-shadow: 0 0 0 4px rgb(99 102 241 / 0.12); }
.dz--has-files { border-style: solid; border-color: #818cf8; background: #eef2ff; }

.dz__preview { display: none; justify-content: center; margin-bottom: 0.65rem; }
.dz__preview--show { display: flex; }
.dz__preview img { max-height: 140px; max-width: 100%; border-radius: 0.5rem; border: 1px solid var(--border); }

.dz-thumb {
    width: 52px; height: 52px; flex-shrink: 0;
    border-radius: 0.5rem; overflow: hidden;
    display: grid; place-items: center;
    background: #f1f5f9; border: 1px solid var(--border);
}
.dz-thumb--img img { width: 100%; height: 100%; object-fit: cover; }

.dz__hit {
    display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
    text-align: center; cursor: pointer; margin: 0;
}
.dz__ico { font-size: 2rem; line-height: 1; }
.dz__title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.dz__sub { font-size: 0.82rem; color: var(--muted); max-width: 36ch; }
.dz__native { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); opacity: 0; }
.dz__state { margin: 0.35rem 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; min-height: 1.2em; }
.dz--has-files .dz__state { color: var(--accent); font-weight: 600; }

.dz-queue {
    list-style: none; margin: 0.75rem 0 0; padding: 0;
    max-height: min(52vh, 420px); overflow-y: auto;
    border: 1px solid var(--border); border-radius: 0.5rem; background: var(--bg2);
    color: var(--text);
}
.dz-queue:empty { display: none; }
.dz-queue__item {
    display: grid; grid-template-columns: 52px 1fr auto; gap: 0.55rem;
    align-items: center; padding: 0.55rem;
    border-bottom: 1px solid var(--border); font-size: 0.86rem;
    color: var(--text);
}
.dz-queue__item:last-child { border-bottom: none; }
.dz-queue__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.dz-queue__meta { font-size: 0.75rem; color: var(--muted); }
.dz-queue__act button {
    min-width: 2rem; height: 2rem; border-radius: 0.375rem;
    border: 1px solid var(--border); background: var(--card);
    color: var(--text); cursor: pointer;
}
.dz-queue__act button:hover { border-color: var(--accent); color: var(--accent); }
.dz-clearall { width: 100%; margin-top: 0.65rem; }

/* Temizle butonları yalnızca dosya seçilince görünür */
#tool-root .dz-clear-one,
#tool-root .dz-clearall { display: none; }
#tool-root .dz--has-files .dz-clearall {
    display: inline-flex; align-items: center; justify-content: center;
}
#tool-root .dz--has-files .dz-clear-one {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; top: 0.55rem; right: 0.55rem;
    padding: 0.32rem 0.7rem; font-size: 0.78rem; gap: 0.3rem;
    border-radius: 0.5rem; line-height: 1;
}

/* Girdi hazır olmadan ana işlem butonu pasif */
#tool-root .btn:disabled,
#tool-root .btn[disabled],
#tool-root .f-btn:disabled,
#tool-root .f-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
    filter: grayscale(0.25);
}

/* Favori (aktif) */
.f-icon-btn.is-on {
    border-color: #fcd34d;
    background: #fffbeb;
    color: #d97706;
}
.f-icon-btn.is-on svg { fill: #f59e0b; }

/* Yukarı dön */
.f-back-top {
    position: fixed; right: 1.15rem; bottom: 1.15rem; z-index: 50;
    width: 2.85rem; height: 2.85rem;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9999px; border: 0; cursor: pointer;
    background: #4f46e5; color: #fff;
    box-shadow: 0 10px 28px rgb(79 70 229 / 0.38);
    opacity: 0; transform: translateY(10px);
    transition: opacity .22s ease, transform .22s ease, background .15s;
}
.f-back-top.is-on { opacity: 1; transform: translateY(0); }
.f-back-top:hover { background: #4338ca; }
[dir="rtl"] .f-back-top { right: auto; left: 1.15rem; }

/* Bildirim (toast) */
.f-toast {
    position: fixed; left: 50%; bottom: 1.6rem; z-index: 60;
    max-width: 90vw; padding: 0.72rem 1.15rem;
    border-radius: 0.8rem; background: #0f172a; color: #fff;
    font-size: 0.875rem; font-weight: 600;
    box-shadow: 0 12px 34px rgb(15 23 42 / 0.28);
    opacity: 0; transform: translate(-50%, 14px);
    transition: opacity .25s ease, transform .25s ease;
    pointer-events: none;
}
.f-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- QR Studio ---------- */
.qr-types {
    display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.qr-type {
    border: 1px solid var(--border); background: var(--card);
    color: var(--muted); font-weight: 600; font-size: 0.84rem;
    padding: 0.42rem 0.8rem; border-radius: 9999px; cursor: pointer;
    transition: all .15s;
}
.qr-type:hover { border-color: #818cf8; color: var(--accent); }
.qr-type.is-on { background: #eef2ff; border-color: #818cf8; color: #4338ca; }

.qr-grid {
    display: grid; grid-template-columns: 1fr; gap: 1.25rem;
}
@media (min-width: 860px) {
    .qr-grid { grid-template-columns: 1.15fr 0.85fr; align-items: start; }
}
.qr-panel { display: flex; flex-direction: column; gap: 0.8rem; }
.qr-fields { display: flex; flex-direction: column; gap: 0.5rem; }
.qr-sep { border: 0; border-top: 1px solid var(--border); margin: 0.4rem 0; }

.qr-style {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}
@media (min-width: 520px) { .qr-style { grid-template-columns: auto auto 1fr; } }
.qr-style__item { display: flex; flex-direction: column; gap: 0.3rem; }
.qr-style__item input[type="color"] {
    width: 100%; min-width: 3.5rem; height: 2.6rem; padding: 0.2rem;
    border: 1px solid var(--border); border-radius: 0.6rem; background: var(--card); cursor: pointer;
}
.qr-check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text); font-weight: 500; }

.qr-logo .dz { padding: 1rem; }
.qr-logo .dz__ico { font-size: 1.5rem; }

.qr-preview-col {
    display: flex; flex-direction: column; align-items: center; gap: 0.9rem;
    position: sticky; top: 1rem;
}
.qr-out {
    width: 100%; min-height: 220px;
    display: flex; align-items: center; justify-content: center;
    padding: 1.25rem; border: 1px solid var(--border); border-radius: 1rem;
    background:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%) -8px 0/16px 16px,
        linear-gradient(-45deg, #f1f5f9 25%, transparent 25%) -8px 0/16px 16px,
        linear-gradient(45deg, transparent 75%, #f1f5f9 75%) -8px 0/16px 16px,
        linear-gradient(-45deg, transparent 75%, #f1f5f9 75%) -8px 0/16px 16px,
        #ffffff;
}

#tool-root .json-editor-host .jsoneditor {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}

#tool-root .cad-stage {
    position: relative;
    overflow: hidden;
    height: min(70vh, 520px);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: #f8fafc;
    cursor: grab;
    touch-action: none;
}

#tool-root .cad-stage--drag { cursor: grabbing; }

#tool-root .cad-canvas,
#tool-root .cad-svg-host {
    display: block;
    width: 100%;
    height: 100%;
}

#tool-root .cad-svg-host svg {
    width: 100%;
    height: 100%;
}

#tool-root .cad-thumb-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    object-fit: contain;
}

#tool-root .cad-toolbar {
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.qr-out img { max-width: 100%; height: auto; border-radius: 0.4rem; box-shadow: 0 6px 20px rgb(15 23 42 / 0.12); }
.qr-dl-row { display: flex; gap: 0.5rem; width: 100%; }
.qr-dl-row .btn { flex: 1; }
.qr-hint { text-align: center; font-size: 0.78rem; }

.f-progress {
    width: 100%;
    height: 0.5rem;
    border-radius: 9999px;
    background: #e2e8f0;
    overflow: hidden;
}

.f-progress__bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #6366f1, #4f46e5);
    transition: width 0.15s ease;
}
