:root {
    --brand-ink: #101935;
    --brand-sky: #4f8bf9;
    --brand-mint: #4fd1c5;
    --brand-amber: #f6ad55;
    --surface-base: #ffffff;
    --surface-elevated: rgba(255, 255, 255, 0.85);
    --border-muted: rgba(16, 25, 53, 0.12);
    --text-primary: #0f172a;
    --text-secondary: #4a5568;
    --shadow-soft: 0 20px 45px rgba(15, 23, 42, 0.12);
    --shadow-subtle: 0 10px 25px rgba(15, 23, 42, 0.08);
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

body {
    margin: 0;
    font-family: inherit;
    background: radial-gradient(circle at 0% 0%, rgba(79, 139, 249, 0.18) 0%, transparent 40%),
        radial-gradient(circle at 80% 10%, rgba(79, 209, 197, 0.2) 0%, transparent 45%),
        #f7f9ff;
    color: var(--text-primary);
    min-height: 100vh;
}

a {
    color: var(--brand-sky);
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

.app-header {
    background: linear-gradient(120deg, var(--brand-ink) 0%, #172952 45%, #1f3b6b 100%);
    color: #ffffff;
    padding: 3rem 1.5rem 4rem;
    box-shadow: var(--shadow-subtle);
}

.app-header a {
    color: #fff;
    font-weight: 600;
}


.app-main {
    padding: 0 1.5rem 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1240px;
    margin: -2.5rem auto 0;
    position: relative;
}

.hero-content {
    max-width: 840px;
    margin: 0 auto 2.5rem;
    text-align: center;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1240px;
    margin: 0 auto;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand-mark {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.brand-mark::before {
    content: "";
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(79, 139, 249, 0.85) 0%, rgba(79, 209, 197, 0.7) 100%);
    display: inline-block;
    box-shadow: 0 10px 20px rgba(79, 139, 249, 0.25);
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease;
}

.header-link:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
}

.hero-title {
    font-size: clamp(2.4rem, 3vw + 1.2rem, 3.4rem);
    font-weight: 700;
    margin: 1rem 0 0.75rem;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: 1.1rem;
    max-width: 640px;
    margin: 0 auto;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.6;
}

.hero-content.hero-compact {
    margin-bottom: 2rem;
}

.hero-content.hero-compact .hero-title {
    font-size: clamp(2rem, 2.6vw + 1rem, 2.6rem);
}

.hero-content.hero-compact .hero-subtitle {
    max-width: 520px;
    font-size: 1.05rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: flex-start;
    background: var(--surface-elevated);
    backdrop-filter: blur(16px);
    padding: 1.35rem 1.75rem;
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-muted);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 180px;
}

.form-field.large {
    flex: 1 1 260px;
}

.form-field label {
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.form-field input,
.form-field select {
    padding: 0.65rem 0.85rem;
    border: 1px solid rgba(16, 25, 53, 0.16);
    border-radius: 10px;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: rgba(79, 139, 249, 0.6);
    box-shadow: 0 0 0 3px rgba(79, 139, 249, 0.2);
}

.custom-size-fields {
    width: 100%;
}

.custom-size-inputs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.35rem;
}

.custom-size-inputs input {
    width: 120px;
}

.size-separator {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.custom-size-hint {
    margin: 0.45rem 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.search-input-group {
    display: flex;
    gap: 0.5rem;
}

.search-input-group input {
    flex: 1;
}

#search-feedback {
    min-height: 1rem;
    font-size: 0.85rem;
    color: #53606b;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.5rem;
}

.inline-actions {
    margin-left: auto;
}

.primary,
.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.4rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.35rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #f97362 0%, #ef4444 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(239, 68, 68, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.danger:disabled {
    background: #f2a39b;
    cursor: not-allowed;
    box-shadow: none;
}

.primary {
    background: linear-gradient(135deg, var(--brand-sky) 0%, #4363ff 100%);
    color: #fff;
    box-shadow: 0 14px 28px rgba(79, 139, 249, 0.28);
}

.primary:disabled {
    background: #afc8ff;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary {
    background-color: rgba(79, 139, 249, 0.08);
    color: var(--brand-ink);
    border: 1px solid rgba(79, 139, 249, 0.18);
}

.primary:hover:not(:disabled),
.secondary:hover:not(:disabled),
.danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
}

#status-message {
    min-height: 1.25rem;
    font-size: 0.95rem;
    color: #0f6cd7;
}

#frames-status {
    display: block;
    margin-top: 0.5rem;
    min-height: 1.25rem;
    color: #1f2933;
    font-size: 0.95rem;
}

.map-section {
    background: var(--surface-elevated);
    border-radius: 22px;
    box-shadow: var(--shadow-soft);
    padding: 1.35rem;
    border: 1px solid var(--border-muted);
}

#map-container {
    position: relative;
    width: 94%;
    margin: 0 auto;
    height: 600px;
    overflow: hidden;
    border-radius: 18px;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.maplibregl-ctrl-top-right {
    margin: 0.75rem 0.75rem 0 0;
}

#frame-overlay {
        position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4px solid rgba(139, 94, 60, 0.95);
    box-shadow:
        0 0 0 9999px rgba(65, 45, 28, 0.32),
        0 0 0 2px rgba(101, 68, 41, 0.8);
    background: rgba(255, 244, 231, 0.08);
    pointer-events: none;
    transition: width 0.25s ease, height 0.25s ease;
}

.preview {
    background: var(--surface-elevated);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    padding: 1.5rem 1.75rem 1.85rem;
    border: 1px solid var(--border-muted);
}

.preview.hidden {
    display: none;
}

.preview img {
    max-width: 100%;
    display: block;
    margin-bottom: 1rem;
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.22);
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1.4rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand-mint) 0%, #16b39e 100%);
    color: #083c3b;
    font-weight: 600;
    box-shadow: 0 14px 28px rgba(79, 209, 197, 0.28);
}

.table-section {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    padding: 1rem;
    overflow-x: auto;
}

#frames-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

#frames-table thead {
    background-color: #f0f4f9;
}

#frames-table th,
#frames-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dde3eb;
    text-align: left;
}

#frames-table th {
    font-weight: 700;
    cursor: pointer;
    position: relative;
    user-select: none;
}

#frames-table th.sorted-asc::after,
#frames-table th.sorted-desc::after {
    content: "";
    position: absolute;
    right: 0.75rem;
    font-size: 0.7rem;
}

#frames-table th.sorted-asc::after {
    content: "▲";
}

#frames-table th.sorted-desc::after {
    content: "▼";
}

#frames-table tbody tr:hover {
    background-color: #f8fafc;
}

#frames-table td[data-label]::before {
    content: attr(data-label);
    display: none;
    font-weight: 600;
    margin-right: 0.5rem;
}

#frames-table .empty {
    text-align: center;
    font-style: italic;
    color: #718096;
}

@media (max-width: 768px) {
    .app-main {
        padding: 1rem;
        margin: 0 auto;
        gap: 1.25rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .header-top {
        justify-content: center;
        text-align: center;
    }

    .header-link {
        margin-left: 0;
    }

    .hero-content {
        margin: 1.75rem auto 1.5rem;
        padding: 0 0.5rem;
    }

    .map-section,
    .preview {
        width: 100%;
    }

    #map-container {
        width: 100%;
        height: 480px;
    }

    #frames-table thead {
        display: none;
    }

    #frames-table,
    #frames-table tbody,
    #frames-table tr,
    #frames-table td {
        display: block;
        width: 100%;
    }

    #frames-table tr {
        margin-bottom: 0.75rem;
        border: 1px solid #dde3eb;
        border-radius: 8px;
        padding: 0.5rem 0.75rem;
    }

    #frames-table td {
        border: none;
        padding: 0.4rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    #frames-table td[data-label]::before {
        display: inline-block;
        color: #53606b;
    }
}

