/* Same tokens as /logistic so the tools read as one family. */
:root {
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e2e4e9;
    --primary: #3b5bdb;
    --primary-dark: #2f47ad;
    --danger: #d64545;
    --radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); }

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }

.topnav { display: flex; align-items: center; gap: 16px; font-size: 0.9rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px; }

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    gap: 20px;
    align-items: start;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}

/* The preview follows the form down long control lists instead of leaving a
   tall gap of empty column beside it. */
.preview-panel { position: sticky; top: 20px; }

h1 { font-size: 1.4rem; margin-top: 0; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }

label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

label.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    margin-bottom: 10px;
}
label.checkbox input { width: auto; margin-top: 0; }

.field { margin-bottom: 18px; }
.field-label { margin-bottom: 6px; font-size: 0.9rem; font-weight: 600; color: var(--muted); }

input[type=text], input[type=number], select, textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
}

textarea { resize: vertical; word-break: break-all; }

input[type=range] { display: block; width: 100%; margin-top: 6px; }
input[type=file] { font-size: 0.9rem; }

output { font-weight: 400; color: var(--text); }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.btn, button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover, button:hover { background: #eef0f5; text-decoration: none; }

button, .btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button:hover, .btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

button.btn { background: #fff; color: var(--text); border-color: var(--border); }
button.btn:hover { background: #eef0f5; }

button.danger { background: #fff; color: var(--danger); border-color: #f3c3c3; }
button.danger:hover { background: #fdecec; }

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Body fill: single colour vs gradient. */
.seg { display: inline-flex; margin-bottom: 10px; }
.seg-btn {
    background: #fff;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 0;
    margin: 0;
}
.seg-btn:first-child { border-radius: 6px 0 0 6px; }
.seg-btn:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.seg-btn:hover { background: #eef0f5; }
.seg-btn.is-on { background: var(--primary); color: #fff; border-color: var(--primary); }
.seg-btn.is-on:hover { background: var(--primary-dark); }

.swatch-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }

.swatch { display: flex; flex-direction: column; gap: 4px; margin-bottom: 0; font-size: 0.8rem; }
.swatch input[type=color] {
    width: 54px;
    height: 34px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.swatch select { margin-top: 0; }
.swatch.wide { min-width: 150px; }
.swatch span { color: var(--muted); font-weight: 600; }

.eye-corner {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}
.corner-name { font-size: 0.85rem; font-weight: 600; color: var(--muted); min-width: 90px; }

.logo-state { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.logo-state img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}
.logo-state .hint { margin: 0; flex: 1; word-break: break-all; }

/* The checkerboard shows through wherever the code is transparent. */
.preview-frame {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #eceef2 25%, transparent 25%),
        linear-gradient(-45deg, #eceef2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eceef2 75%),
        linear-gradient(-45deg, transparent 75%, #eceef2 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    margin-bottom: 12px;
}

#qr-canvas { display: block; width: 100%; height: auto; border-radius: 4px; }

.hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }

.error {
    background: #fdecec;
    color: #a12a2a;
    border: 1px solid #f3c3c3;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    margin: 0 0 12px;
}

@media (max-width: 860px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .preview-panel { position: static; }
}

@media (max-width: 600px) {
    .topbar-inner { flex-direction: column; align-items: flex-start; }
    .card { padding: 16px; }
}

/* --------------------------------------------------- dynamic short links */

/* Under the download buttons: the offer to make the code dynamic on the
   public page, the save form on the redirector's. */
.dyn-panel, .qr-save {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.dyn-panel h2, .qr-save h2 { margin-top: 0; }
.dyn-panel form, .qr-save { margin: 0; }
.dyn-panel .hint:first-of-type { margin-top: 0; }

button:disabled, .btn:disabled { opacity: 0.55; cursor: not-allowed; }
button:disabled:hover { background: var(--primary); }

/* Content locked to a short link: editable-looking fields that are not. */
textarea.is-locked {
    background: #f4f5f7;
    color: var(--muted);
    cursor: not-allowed;
}
