* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #0682b4;
    --primary-dark: #02587c;
    --accent: #31b7e9;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 14px;
    --shadow: 0 4px 16px rgba(2, 88, 124, 0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
.site-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 12px rgba(2, 88, 124, 0.25);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.logo:hover {
    color: #fff;
}

.logo svg {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.site-header nav {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.site-header nav a {
    color: rgba(255, 255, 255, 0.9);
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background 0.2s;
}

.site-header nav a:hover,
.site-header nav a.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.container {
    width: min(1100px, 94%);
    margin: 0 auto;
}

main {
    flex: 1;
    padding: 2.2rem 0 3rem;
}

/* Hero */
.hero {
    text-align: center;
    padding: 2.6rem 1rem 1.4rem;
}

.hero h1 {
    font-size: clamp(1.8rem, 4.5vw, 2.9rem);
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 0.4rem;
}

.hero p {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 620px;
    margin: 0 auto;
}

/* Tool cards (landing) */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.4rem;
    margin-top: 2rem;
}

.tool-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.8rem 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(2, 88, 124, 0.15);
}

.tool-icon {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    margin-bottom: 0.9rem;
    color: #fff;
}

.tool-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
}

.tool-card p {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 0.9rem;
}

/* Form sections */
.section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.6rem 1.7rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.4rem;
}

.section h2 {
    font-size: 1.35rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.form-label {
    display: block;
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 0.35rem;
}

.field {
    margin-bottom: 1rem;
}

input[type="text"],
input[type="number"],
input[type="url"],
input[type="color"],
textarea,
select {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(49, 183, 233, 0.15);
}

textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
}

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

input[type="color"] {
    height: 46px;
    padding: 4px;
    cursor: pointer;
}

.inline-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
}

.hint {
    font-size: 0.83rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: none;
    cursor: pointer;
    padding: 0.7rem 1.3rem;
    border-radius: 9px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    transition: filter 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.12);
}

.btn-secondary {
    background: var(--bg);
    color: var(--primary-dark);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.83rem;
}

/* Output areas */
.output-wrap {
    margin-top: 1.1rem;
}

.output-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    margin-bottom: 0.55rem;
}

.output-title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.output-box {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem;
    word-break: break-all;
    white-space: pre-wrap;
    max-height: 260px;
    overflow-y: auto;
    user-select: all;
    cursor: pointer;
    border: 1px solid #1e293b;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.9rem;
}

.result-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.result-viz {
    background: var(--bg);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    text-align: center;
}

.result-viz img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 6px;
}

.result-info {
    padding: 0.55rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.result-info code {
    font-size: 0.8rem;
    color: var(--muted);
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Image preview */
.preview-wrap {
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #fff 0% 50%) 50% / 20px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
}

.preview-wrap img {
    max-width: 100%;
    max-height: 480px;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

canvas {
    display: block;
    max-width: 100%;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

video {
    width: 100%;
    border-radius: 10px;
    background: #000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Steps / file tool */
.steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.step {
    display: flex;
    gap: 0.8rem;
}

.step-num {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.step-body {
    flex: 1;
    background: var(--bg);
    border-radius: 10px;
    padding: 0.9rem 1rem;
}

.step-body strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--primary-dark);
}

/* Floating action */
.floating-actions {
    position: sticky;
    bottom: 1rem;
    display: flex;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 1.2rem;
    pointer-events: none;
}

.floating-actions .btn {
    pointer-events: auto;
    box-shadow: 0 6px 18px rgba(2, 88, 124, 0.25);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%) translateY(140%);
    background: #1e293b;
    color: #fff;
    padding: 0.7rem 1.3rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Footer */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255, 255, 255, 0.75);
    padding: 1.6rem 1.5rem;
    font-size: 0.88rem;
    margin-top: auto;
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-footer strong {
    color: #fff;
}

/* Responsive */
@media (max-width: 640px) {
    .site-header .container {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-header nav {
        width: 100%;
    }

    .site-header nav a {
        flex: 1;
        text-align: center;
        padding: 0.5rem;
    }

    .section {
        padding: 1.2rem;
    }
}