:root {
    --bg: #0f1724;
    --card: #0b1220;
    --accent: #7dd3fc;
    --muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-2: rgba(255, 255, 255, 0.03);
    --radius: 10px; /* slightly smaller for mobile-first */
    --shadow: 0 8px 28px rgba(2, 6, 23, 0.6);
    --ui: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue";
    --max-width: 1100px;
    --gutter: 12px; /* mobile baseline */
    --font-size-base: 14px; /* mobile baseline */
    --control-height: 48px; /* mobile baseline */
}

/* Reset & base */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--ui);
    font-size: var(--font-size-base);
    background:
        radial-gradient(900px 500px at 90% 90%, rgba(99, 102, 241, 0.04), transparent 12%),
        linear-gradient(180deg, var(--bg), #071022 60%);
    color: #e6eef8;
    padding: 12px;
    display: flex;
    justify-content: center;
}

/* Header / titles */
.header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: var(--gutter);
    flex-wrap: wrap;
}

h1 {
    font-size: 18px;
    margin: 0;
    padding: 8px 12px;
    color: #fff;
}

h2 {
    font-size: 14px;
    margin: 0;
    padding: 8px 12px;
    color: var(--accent);
    font-weight: 600;
}

/* Card */
.card {
    background: linear-gradient(180deg, var(--card), rgba(11, 18, 32, 0.7));
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px) saturate(1.05);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Layout (mobile stacked by default) */
.sidebar { width: 100%; }
.main    { width: 100%; }

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-left: 0; /* mobile: remove left padding for full width */
    width: 100%;
}

label {
    font-size: 0.9em;
    color: var(--muted);
    margin-bottom: 6px;
}

select,
textarea,
input[type="text"],
input[type="email"],
input[type="number"] {
    width: 100%;
    min-height: var(--control-height);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    color: #e6eef8;
    border: 1px solid rgba(255,255,255,0.04);
    padding: 12px 14px;
    border-radius: 10px;
    outline: none;
    font-size: 1em;
    transition: box-shadow .15s ease, transform .08s ease, border-color .12s ease;
}

select {
    background: var(--card) !important;
    color: #e6eef8 !important;
    appearance: none;
    padding-right: 44px;
}

textarea {
    min-height: 80px;
    padding: 12px;
    line-height: 1.5;
    resize: vertical;
}

/* Rows */
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex-direction: column; /* mobile stacked */
}

.form-row > * { flex: 1; min-width: 0; }

.input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Buttons */
.bak,
input[type="submit"] {
    height: var(--control-height);
    min-width: 160px;
    background: linear-gradient(90deg, var(--accent), #6ee7b7 80%);
    color: #042028;
    border: none;
    padding: 0 18px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.08);
    transition: transform .12s ease, box-shadow .12s ease;
}
.bak:hover,
input[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(45, 212, 191, 0.12);
}
.bak:active,
input[type="submit"]:active { transform: translateY(0); }

/* Audio */
audio {
    width: 100%;
    margin-top: 6px;
    background: var(--glass-2);
    border-radius: 10px;
    padding: 8px;
}

audio::-webkit-media-controls-panel { background-color: var(--card) !important; }
audio::-webkit-media-controls-play-button,
audio::-webkit-media-controls-volume-slider,
audio::-webkit-media-controls-mute-button { filter: invert(1); }

/* Text output */
#text_output {
    background: linear-gradient(180deg, rgba(255,255,255,0.015), rgba(255,255,255,0.01));
    padding: 12px;
    border-radius: 10px;
    color: var(--muted);
    min-height: 64px;
    max-height: 220px; /* slightly smaller on mobile */
    overflow-y: auto;
    white-space: pre-wrap;
    border: 1px solid rgba(255,255,255,0.02);
}

/* Small utilities */
.small { font-size: 0.9em; color: var(--muted); }
.center { display: flex; align-items: center; justify-content: center; }

/* Custom audio players (hidden by default on mobile until shown) */
#customAudioPlayer,
#customAudioPlayer2 {
    display: none;
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    margin-top: 12px;
}

#customAudioPlayer button,
#customAudioPlayer2 button {
    background: var(--accent);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    color: #042028;
    margin-right: 12px;
}

#seekBar, #seekBar2 { vertical-align: middle; width: 40%; margin-right: 12px; }
#timeDisplay, #timeDisplay2 { color: var(--muted); }

/* Weather cards: single column on mobile */
.weather-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.weather-item {
    background: var(--glass);
    border-radius: var(--radius);
    padding: 12px;
    color: #e6eef8;
    text-align: center;
    box-shadow: 0 4px 16px rgba(2, 6, 23, 0.4);
}

.weather-item h3 { margin: 0 0 6px; color: var(--accent); }
.weather-item img { width: 72px; height: 72px; vertical-align: middle; }

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 36, 0.85);
    backdrop-filter: blur(8px) saturate(1.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: var(--accent);
    font-weight: 600;
    font-size: 1.2em;
    letter-spacing: 0.5px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active { opacity: 1; visibility: visible; }

.spinner {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(125, 211, 252, 0.2);
    border-top: 5px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Navbar: mobile-friendly full width near top */
.navbar {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: linear-gradient(90deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01));
    border-radius: calc(var(--radius) + 2px);
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.04);
    backdrop-filter: blur(8px) saturate(1.05);
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.6);
}

.nav-left { display: flex; align-items: center; gap: 8px; }
.nav-brand {
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--accent);
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.06), rgba(110, 231, 183, 0.02));
}

.nav-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.nav-tab {
    padding: 6px 10px;
    border-radius: 8px;
    background: transparent;
    color: #dceeff;
    cursor: pointer;
    border: 1px solid transparent;
    font-weight: 600;
    transition: background .15s ease, transform .08s ease, border-color .12s ease;
}

.nav-tab:hover { transform: translateY(-2px); background: rgba(255,255,255,0.02); }

.nav-tab.active {
    background: linear-gradient(90deg, var(--accent), #6ee7b7 60%);
    color: #042028;
    box-shadow: 0 6px 18px rgba(45, 212, 191, 0.06);
    border-color: rgba(255,255,255,0.04);
}

/* Focus styles */
select:focus,
textarea:focus,
input[type="submit"]:focus,
input[type="text"]:focus {
    box-shadow: 0 8px 28px rgba(125, 211, 252, 0.12);
    border-color: rgba(125, 211, 252, 0.28);
    outline: none;
}

/* ---------- Larger screens (min-width breakpoints) ---------- */

/* Medium screens — adapt spacing, show two-column weather and form rows */
@media (min-width: 700px) {
    :root {
        --gutter: clamp(12px, 2.6vw, 28px);
        --radius: 12px;
        --font-size-base: clamp(14px, 1.2vw, 16px);
        --control-height: clamp(44px, 3.6vw, 56px);
    }

    body { padding: clamp(16px, 3vw, 40px); }

    .header { gap: 12px; }

    h1 { font-size: clamp(20px, 2.2vw, 28px); padding: 10px 16px; }
    h2 { font-size: clamp(14px, 1.6vw, 16px); padding: 10px 16px; }

    .card { padding: clamp(12px, 2vw, 22px); }

    .form-row { flex-direction: row; }

    .weather-container { grid-template-columns: 1fr 1fr; gap: 16px; }

    #text_output { max-height: 300px; }

    .spinner { width: 64px; height: 64px; margin-bottom: 16px; }
}

/* Large screens — centered layout and wider navbar */
@media (min-width: 900px) {
    body { padding: clamp(16px, 3vw, 40px); }

    .navbar {
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: min(980px, calc(100% - 40px));
        padding: 10px 14px;
        border-radius: calc(var(--radius) + 4px);
        box-shadow: 0 12px 36px rgba(2, 6, 23, 0.6);
    }

    /* On wide screens make a two-column config area (keeps change minimal) */
    #configScreen > .card {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
        align-items: start;
    }

    #configScreen > .card > .card { padding: 16px; border-radius: 6px; }

    .form-row { gap: 12px; }
}

/* Extra large screens — keep max-width */
@media (min-width: 1200px) {
    body { max-width: var(--max-width); margin: 0 auto; }
}
