:root {
    --bg: #f4f7fb;
    --bg-accent: #e9eef5;
    --panel: rgba(255, 255, 255, 0.94);
    --line: rgba(115, 134, 161, 0.18);
    --line-strong: rgba(115, 134, 161, 0.28);
    --text: #1d2733;
    --muted: #667384;
    --primary: #2b6cb0;
    --primary-soft: rgba(43, 108, 176, 0.12);
    --primary-strong: #1f4f84;
    --danger: #9f2e2e;
    --danger-soft: #fff1ef;
    --success: #2d6c47;
    --shadow: 0 12px 28px rgba(26, 40, 58, 0.08);
    --radius: 16px;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(43, 108, 176, 0.10), transparent 22rem),
        radial-gradient(circle at bottom left, rgba(40, 89, 145, 0.08), transparent 24rem),
        linear-gradient(180deg, #fbfcfe 0%, var(--bg) 48%, var(--bg-accent) 100%);
}

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

a {
    color: inherit;
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

.app {
    width: min(1080px, calc(100% - 1rem));
    margin: 0 auto;
    padding: 0.75rem 0 2rem;
}

.card, .toolbar, .hero {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.8rem 0.9rem;
    margin-bottom: 0.75rem;
}

.app-logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    line-height: 0;
}

.app-logo img {
    display: block;
    width: auto;
    height: 91px;
    max-width: min(456px, 78vw);
}

.toolbar-actions, .button-row {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    border-radius: 999px;
    padding: 0.52rem 0.82rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #fff;
    border-color: transparent;
}

.hero, .card {
    padding: 0.95rem;
    margin-bottom: 0.75rem;
}

.eyebrow {
    display: inline-flex;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.66);
    color: var(--muted);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
}

h1 {
    margin: 0.65rem 0 0.35rem;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.15;
    font-family: inherit;
}

h2 {
    margin: 0 0 0.3rem;
    font-size: 0.98rem;
}

.muted, .helper {
    color: var(--muted);
}

.helper {
    font-size: 0.78rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    align-items: start;
}

.field {
    display: grid;
    gap: 0.35rem;
    align-self: start;
    align-content: start;
    justify-items: stretch;
}

.field.wide {
    grid-column: 1 / -1;
}

.field label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 3.05rem;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    border-radius: 12px;
    padding: 0.62rem 0.8rem;
    outline: none;
}

.multi-select {
    min-height: 8.8rem;
    align-self: start;
}

.field textarea {
    min-height: 8rem;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.preview {
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(248, 251, 255, 0.92);
    padding: 0.75rem 0.85rem;
}

.helper-spaced {
    margin-bottom: 1rem;
}

.helper-spaced-top {
    margin-top: 0.7rem;
}

.preview-spaced {
    margin-top: 0.8rem;
}

.button-row-spaced {
    margin-top: 0.8rem;
}

.button-row-split {
    justify-content: space-between;
    align-items: flex-start;
}

.hidden-input {
    display: none;
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1400;
    display: grid;
    gap: 0.6rem;
}

.toast {
    min-width: min(22rem, calc(100vw - 2rem));
    max-width: 28rem;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    background: rgba(23, 35, 49, 0.95);
    color: #fff;
    box-shadow: 0 16px 30px rgba(23, 35, 49, 0.2);
}

.toast.success { background: rgba(45, 108, 71, 0.96); }
.toast.error { background: rgba(159, 46, 46, 0.96); }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(18, 27, 39, 0.48);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 1500;
}

.modal-card {
    width: min(760px, 100%);
    max-height: min(88vh, 900px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 26px 60px rgba(17, 27, 39, 0.18);
    padding: 1rem;
}

.progress-shell {
    margin-top: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(233, 238, 245, 0.9);
    overflow: hidden;
}

.progress-bar {
    height: 0.8rem;
    width: 0%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-strong) 100%);
    transition: width 0.2s ease;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.7rem;
}

.log-box {
    margin-top: 0.8rem;
    min-height: 14rem;
    max-height: 22rem;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(248, 251, 255, 0.92);
    padding: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    white-space: pre-wrap;
}

@media (max-width: 860px) {
    .grid {
        grid-template-columns: 1fr;
    }
}
