/* Koyu tema varsayılandır; açık tema <html data-theme="light"> ile etkinleşir */
:root {
    --bg: #0b0e17;
    --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(124, 116, 255, .12), transparent 60%),
               radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, .06), transparent 60%);
    --surface: #131826;
    --surface-2: #1a2032;
    --border: #252c41;
    --border-strong: #343d58;
    --text: #e7e9f3;
    --muted: #949cb6;
    --accent: #8b83ff;
    --accent-strong: #6d63ff;
    --btn-primary: #6259f5;
    --btn-primary-hover: #7169ff;
    --accent-soft: rgba(139, 131, 255, .14);
    --accent-text: #ffffff;
    --danger: #f97066;
    --danger-soft: rgba(249, 112, 102, .12);
    --warn: #fdb022;
    --warn-soft: rgba(253, 176, 34, .11);
    --ok: #47cd89;
    --ok-soft: rgba(71, 205, 137, .11);
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .18);
    --checker-a: #1c2233;
    --checker-b: #171c2b;
    --topbar-bg: rgba(19, 24, 38, .82);
    --toast-bg: #e7e9f3;
    --toast-text: #0b0e17;
    --qr-shadow: drop-shadow(0 10px 28px rgba(0, 0, 0, .45));
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #f4f5f9;
    --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(79, 70, 229, .07), transparent 60%);
    --surface: #ffffff;
    --surface-2: #f7f8fb;
    --border: #e3e6ee;
    --border-strong: #cfd4e0;
    --text: #151a2d;
    --muted: #667085;
    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --btn-primary: #4f46e5;
    --btn-primary-hover: #4338ca;
    --accent-soft: #eef0ff;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --warn: #b54708;
    --warn-soft: #fffaeb;
    --ok: #067647;
    --ok-soft: #ecfdf3;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
    --checker-a: #ffffff;
    --checker-b: #eceef4;
    --topbar-bg: rgba(255, 255, 255, .85);
    --toast-bg: #151a2d;
    --toast-text: #ffffff;
    --qr-shadow: drop-shadow(0 6px 18px rgba(16, 24, 40, .12));
    color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
    background: var(--bg-glow), var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text);
    font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Üst çubuk ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 28px;
    background: var(--topbar-bg);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark svg { width: 38px; height: 38px; display: block; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: #fff; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Tema düğmesi ---------- */
.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 64px; height: 34px;
    padding: 3px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    cursor: pointer;
    flex: none;
}
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .knob {
    position: absolute; top: 3px; left: 3px;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--btn-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
    transform: translateX(30px);
    transition: transform .22s ease;
}
:root[data-theme="light"] .theme-toggle .knob { transform: translateX(0); }
.theme-toggle svg {
    position: relative; z-index: 1;
    width: 16px; height: 16px; margin: 0 5px;
    fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    transition: stroke .2s;
}
:root:not([data-theme="light"]) .theme-toggle .i-moon,
:root[data-theme="light"] .theme-toggle .i-sun { stroke: #fff; }
.brand { flex: 1 1 auto; min-width: 0; }
.theme-toggle { order: 3; }
.topbar-actions { order: 2; }
@media (max-width: 700px) {
    .topbar { position: static; gap: 12px; }
    .theme-toggle { order: 2; }
    .topbar-actions { order: 3; width: 100%; }
    .topbar-actions .btn { flex: 1 1 0; padding: 7px 8px; font-size: 13px; }
    .brand p { display: none; }
}

.banner { padding: 12px 28px; font-weight: 600; }
.banner.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Yerleşim ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 24px;
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 28px 48px;
    align-items: start;
}
.controls { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.preview { position: sticky; top: 90px; }

@media (max-width: 1000px) {
    .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
    .preview { position: static; order: -1; }
    .topbar { padding: 12px 16px; }
}

/* ---------- Kartlar ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
details.card > summary { list-style: none; cursor: pointer; user-select: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
    content: "";
    margin-left: auto;
    width: 9px; height: 9px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform .15s;
}
details.card[open] > summary::after { transform: rotate(225deg); }
details.card[open] > summary { margin-bottom: 14px; }

.card-head { display: flex; align-items: center; gap: 10px; }
.card > .card-head:not(summary) { margin-bottom: 14px; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.step {
    display: inline-grid; place-items: center;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    font-size: 12px; font-weight: 700;
}
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 8px; font-weight: 650; }
h3.sub:first-of-type { margin-top: 0; }

/* ---------- Form ---------- */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: minmax(0, 1fr); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.field output { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.field.grow { flex: 1; }

input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="number"],
input[type="datetime-local"], select, textarea {
    width: 100%;
    padding: 9px 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; cursor: pointer; margin: 10px 0 4px; }
.row { display: flex; gap: 14px; margin-top: 14px; }
.row.two > * { flex: 1 1 0; min-width: 0; }
.row.align-end { align-items: flex-end; }
.align-self-end { align-self: flex-end; }
@media (max-width: 560px) { .row.two { flex-direction: column; } }

.card > .field, details.card > .field { margin-top: 14px; }

.hint { color: var(--muted); font-size: 12px; display: block; margin-top: 8px; }

.color-input {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 4px 6px 4px 4px;
}
.color-input input[type="color"] {
    width: 34px; height: 30px; padding: 0; border: none; background: none; cursor: pointer; border-radius: 6px; flex: none;
}
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,.15); border-radius: 6px; }
.color-input input.hex { border: none; background: transparent; padding: 4px 2px; font-family: Consolas, monospace; text-transform: uppercase; box-shadow: none; min-width: 0; }

/* ---------- Butonlar ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--btn-primary); border-color: var(--btn-primary); color: var(--accent-text); }
.btn.primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }

/* ---------- İçerik sekmeleri ---------- */
.type-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.type-tab {
    padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 13px;
    display: inline-flex; align-items: center; gap: 6px;
}
.type-tab svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.type-tab[aria-selected="true"] { background: var(--btn-primary); border-color: var(--btn-primary); color: var(--accent-text); }

/* ---------- Karolar ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.tiles.compact { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.tile {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 10px 4px 8px;
    border: 1.5px solid var(--border); border-radius: 11px;
    background: var(--surface-2); cursor: pointer;
    font-size: 11.5px; font-weight: 600; color: var(--muted);
    transition: border-color .12s, background .12s;
}
.tile svg { width: 40px; height: 40px; fill: var(--text); }
.tile:hover { border-color: var(--border-strong); }
.tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tile[aria-pressed="true"] svg { fill: var(--accent); }

/* ---------- Hazır tasarımlar ---------- */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.preset {
    border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2);
    padding: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600;
}
.preset:hover { border-color: var(--accent); }
.preset .swatch { width: 100%; aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.preset .swatch img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Dolgu düzenleyici ---------- */
.fill-editor { margin-top: 14px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 11px; }
.fill-editor .fe-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }
.fill-editor .fe-inherit-label { margin: 0; }
.fill-editor .fe-title { font-weight: 650; font-size: 13px; }
.fill-editor .fe-body { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; align-items: flex-end; }
.fill-editor .fe-body > .field { flex: 1 1 140px; }
.fill-editor.disabled .fe-body, .fill-editor.disabled .segmented { opacity: .45; pointer-events: none; }
.fill-editor .swap { flex: none; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button {
    border: none; background: transparent; padding: 5px 11px; border-radius: 7px;
    font-weight: 600; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
#eccLevels button { padding: 7px 14px; }
#eccLevels button small { display: block; font-weight: 500; font-size: 11px; opacity: .8; }

/* ---------- Logo alanı ---------- */
.dropzone {
    border: 2px dashed var(--border-strong); border-radius: 12px; padding: 18px;
    text-align: center; cursor: pointer; background: var(--surface-2);
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-empty small { display: block; color: var(--muted); margin-top: 4px; }
.dz-filled { display: flex; align-items: center; gap: 14px; text-align: left; }
.dz-filled img { width: 64px; height: 64px; object-fit: contain; border-radius: 8px; background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 12px 12px; border: 1px solid var(--border); }
.dz-filled strong { display: block; word-break: break-all; margin-bottom: 6px; }
.dz-actions { display: flex; gap: 6px; }

/* ---------- Önizleme ---------- */
.preview-card { padding: 16px; }
.stage {
    position: relative;
    border-radius: 12px;
    background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 20px 20px;
    border: 1px solid var(--border);
    min-height: 300px;
    display: grid; place-items: center;
    padding: 18px;
    overflow: hidden;
}
.stage img { width: 100%; height: auto; max-height: 62vh; object-fit: contain; display: block; filter: var(--qr-shadow); }
.stage img:not([src]) { visibility: hidden; }
.stage-msg {
    position: absolute; inset: 18px; display: grid; place-items: center; text-align: center;
    background: var(--surface); border-radius: 10px; padding: 20px; color: var(--danger); font-weight: 600;
}
.spinner {
    position: absolute; top: 12px; right: 12px; width: 18px; height: 18px;
    border: 2.5px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.chip b { color: var(--text); font-weight: 650; }

.warnings { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.warnings li { padding: 8px 11px; border-radius: 9px; font-size: 12.5px; font-weight: 550; }
.warnings li.ok { background: var(--ok-soft); color: var(--ok); }
.warnings li.warn { background: var(--warn-soft); color: var(--warn); }
.warnings li.danger { background: var(--danger-soft); color: var(--danger); }

.download { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.download-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.download-head h3 { margin: 0; font-size: 14px; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.inline-field select { width: auto; padding: 5px 8px; }
.download-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.download-buttons.secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
.download-buttons.secondary .btn { white-space: normal; text-align: center; }

.api { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 12.5px; }
.api summary { cursor: pointer; font-weight: 650; }
.api pre {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px;
    max-height: 220px; overflow: auto; font-size: 11.5px; white-space: pre-wrap; word-break: break-all;
}
.api code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.footnote { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 12px; }

/* ---------- Bildirim ---------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
    background: var(--toast-bg); color: var(--toast-text); padding: 10px 16px; border-radius: 10px; font-weight: 600;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
