:root {
    --purple: #ab82c5;
    --purple-dim: rgba(171,130,197,0.18);
    --bg: #0b1320;
    --panel-bg: rgba(11, 16, 28, 0.97);
    --text: #e8e0f0;
    --text-dim: #7a7090;
    --error: #e07070;
    --radius: 4px;
}

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


body {
    background: var(--bg);
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
    overflow: hidden;
    height: 100dvh;
}

#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

#ui-panel {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 25%;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    scrollbar-width: none;
    background: var(--panel-bg);
    border: 1px solid rgba(171,130,197,0.15);
    border-radius: var(--radius);
    padding: 24px 20px;
    z-index: 20;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

#ui-panel::-webkit-scrollbar {
    display: none;   
}

#panel-handle { display: none; }
#panel-inner { display: contents; }

.panel-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 10px;
    color: #fff;
}

.panel-intro {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-dim);
    margin-bottom: 18px;
}

#ui-panel h1 {
    font-size: clamp(14px, 2vw, 20px);
    margin: 0 0 10px 0;
    line-height: 1.3;
}

#ui-panel p {
    font-size: clamp(12px, 1.4vw, 15px);
    margin: 0 0 12px 0;
    line-height: 1.5;
}

#origin-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(171,130,197,0.3);
    border-radius: 4px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s;
}

#origin-input:focus { border-color: var(--purple); }
#origin-input::placeholder { color: var(--text-dim); }

#find-btn {
    width: 100%;
    padding: 11px;
    background: var(--purple);
    border: none;
    border-radius: 4px;
    color: #0b1320;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    position: relative;
}

#find-btn:hover { opacity: 0.88; }
#find-btn:active { transform: scale(0.98); }
#find-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#find-btn .btn-label { transition: opacity 0.15s; }
#find-btn.loading .btn-label { opacity: 0; }
#find-btn .spinner {
    display: none;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 18px; height: 18px;
    border: 2px solid rgba(11,19,32,0.3);
    border-top-color: #0b1320;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
#find-btn.loading .spinner { display: block; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

#error-msg {
    display: none;
    margin-top: 10px;
    padding: 9px 12px;
    background: rgba(224,112,112,0.12);
    border: 1px solid rgba(224,112,112,0.3);
    border-radius: 8px;
    color: var(--error);
    font-size: 13px;
    line-height: 1.4;
}
#error-msg.visible { display: block; }

#result {
    margin-top: 18px;
    display: none;
    animation: fadeUp 0.35s ease forwards;
}

#result.visible { display: block; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

#result img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
}

/*
.result-bird-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #fff;
}

.result-tagline {
    font-size: 13px;
    color: var(--purple);
    margin-bottom: 10px;
    line-height: 1.4;
}

.result-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.stat-pill {
    flex: 1;
    padding: 8px 10px;
    background: rgba(171,130,197,0.1);
    border: 1px solid rgba(171,130,197,0.2);
    border-radius: 8px;
    text-align: center;
}
.stat-pill .stat-num {
    font-size: 16px;
    font-weight: 600;
    color: var(--purple);
    display: block;
}
.stat-pill .stat-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
    */

.result-copy {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.learn-btn {
  display: block;
  text-align: center;
  width: 100%;
  padding: 10px;
  background: var(--purple);
  color: #0b1320;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  transition: opacity 0.2s;
}
.learn-btn:hover {
  opacity: 0.85;
}

/* mobile panle */
#panel-toggle {
    display: none;
}


@media (max-width: 640px) {
    #ui-panel {
        position: fixed;
        top: auto;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 60dvh;
        /* max-height: 30dvh; */
        border-radius: 20px 20px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        border-top: 1px solid rgba(171,130,197,0.2);
        padding: 0 0 env(safe-area-inset-bottom, 16px);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        transition: max-height 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    }

    #ui-panel.collapsed {
        max-height: 15dvh;
    }

    #ui-panel.has-result {
        max-height: 90dvh;
    }

    #panel-handle {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 10px 20px 8px;
        cursor: pointer;
        gap: 7px;
        flex-shrink: 0;
    }

    .handle-bar {
        width: 36px;
        height: 4px;
        background: rgba(171,130,197,0.3);
        border-radius: 2px;
    }

    .handle-row {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .handle-title {
        font-size: 15px;
        color: #fff;
        font-family: 'DM Sans', sans-serif;

    }

    .handle-chevron {
        font-size: 18px;
        color: var(--purple);
        transition: transform 0.3s;
        line-height: 1;
    }

    #ui-panel.collapsed #panel-inner {
        display: none;
    }

    #ui-panel.collapsed #panel-handle {
        display: block;
        margin-bottom: 0;
    }

    #ui-panel:not(.collapsed) .handle-chevron {
        transform: rotate(180deg);
    }

    /* Scrollable inner on mobile */
    #panel-inner {
        display: block;
        flex: 1;
        overflow-y: auto;
        padding: 4px 20px 16px;
        scrollbar-width: none;
    }
    #panel-inner::-webkit-scrollbar { display: none; }

    .panel-title { 
        font-size: 20px; 
        margin-bottom: 6px; 
    }

    .panel-intro {
        font-size: 12px;
        margin-bottom: 14px;
        color: var(--text-dim);
    }

    #origin-input {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 14px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    #find-btn {
        padding: 15px;
        font-size: 16px;
        border-radius: 10px;
    }

    #result img { height: auto; }
    .result-bird-name { font-size: 22px; }
    .stat-pill .stat-num { font-size: 18px; }

    .learn-btn {
        padding: 14px;
        font-size: 15px;
        border-radius: 10px;
    }
}