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

:root {
    --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", "Fira Code", monospace;

    --bg: #f5f5f7;
    --surface: #ffffff;
    --sidebar-bg: #fafafa;
    --border: rgba(0, 0, 0, 0.07);

    --accent: #0071e3;
    --success: #30d158;
    --danger: #ff3b30;

    --t1: #1d1d1f;
    --t2: #6e6e73;
    --t3: #aeaeb2;

    --sidebar-w: 220px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--t1);
    -webkit-font-smoothing: antialiased;
}


.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}


.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 12px;
    flex-shrink: 0;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 6px;
}

.brand-mark {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.brand-name {
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--t1);
}


.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--t2);
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, color 0.12s;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--t1);
}

.nav-item.active {
    background: var(--surface);
    color: var(--t1);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.nav-item.active svg {
    opacity: 1;
}

.sidebar-bottom {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 14px 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-bottom-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.brand-by {
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--t1);
    letter-spacing: 0.01em;
}

.bracket {
    color: #5b2d8e;
}

.sidebar-author {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--t2);
    line-height: 1.2;
}

.sidebar-author-name {
    font-weight: 700;
    color: var(--t1);
}

.sidebar-year {
    font-size: 0.72rem;
    color: var(--t3);
}

.sidebar-back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    background: #5b2d8e;
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 20px;
    width: fit-content;
    transition: background 0.15s, transform 0.1s;
}

.sidebar-back-link:hover {
    background: #6e35a8;
    transform: translateY(-1px);
}


.main-wrap {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}


.panel {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.panel.active {
    display: flex;
}


.panel-header {
    padding: 28px 40px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.panel-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--t1);
    margin-bottom: 2px;
}

.panel-sub {
    font-size: 0.8125rem;
    color: var(--t2);
}


.chat-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
    background: var(--bg);
    scroll-behavior: smooth;
}

.chat-wrap::-webkit-scrollbar {
    width: 4px;
}

.chat-wrap::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 820px;
}

.message {
    max-width: 65%;
    padding: 11px 16px;
    border-radius: 14px;
    font-size: 0.9375rem;
    line-height: 1.55;
    animation: msgIn 0.18s ease both;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background: var(--accent);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

.message.ai {
    background: var(--surface);
    color: var(--t1);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.message.error {
    background: #fff2f2;
    color: var(--danger);
    border: 1px solid rgba(255, 59, 48, 0.15);
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

.message .label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.5;
    margin-bottom: 3px;
}

.message .content {
    white-space: pre-wrap;
    word-break: break-word;
}


.compose-area {
    padding: 12px 40px 8px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.compose {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 820px;
}

.compose-input {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--t1);
    background: var(--bg);
    outline: none;
    max-height: 120px;
    line-height: 1.45;
    transition: border-color 0.15s, box-shadow 0.15s;
    scrollbar-width: none;
}

.compose-input::-webkit-scrollbar {
    display: none;
}

.compose-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
    background: var(--surface);
}

.compose-input::placeholder {
    color: var(--t3);
}

input.compose-input {
    height: 36px;
    max-height: 36px;
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #5b2d8e;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s, transform 0.1s;
}

.send-btn:hover {
    background: #6e35a8;
}

.send-btn:active {
    transform: scale(0.92);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.compose-hint {
    font-size: 0.7rem;
    color: var(--t3);
    margin-top: 6px;
    padding-bottom: 4px;
    max-width: 820px;
}

.weatherai-compose {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.weatherai-body {
    display: flex;
    flex-direction: column;
}

.weatherai-inputs {
    max-width: 820px;
}

.weatherai-city-field {
    width: 160px;
    flex-shrink: 0;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--t1);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.45;
    align-self: stretch;
}

.weatherai-city-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
    background: var(--surface);
}

.weatherai-city-field::placeholder {
    color: var(--t3);
}


.weatherai-question {
    flex: 1;
    resize: none;
    max-height: 100px;
}

.weatherai-btn {
    margin-top: 0;
    align-self: flex-end;
    height: 44px;
}


.form-body {
    padding: 32px 40px 48px;
    overflow-y: auto;
    flex: 1;
    background: var(--bg);
}

.form-cols {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
    max-width: 600px;
}

.search-field {
    flex: 1;
}

.search-row .action-btn {
    margin-top: 0;
}


.field {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--t1);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    resize: none;
}

.field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.09);
}

.field::placeholder {
    color: var(--t3);
}


.action-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 22px;
    background: #5b2d8e;
    color: #ffffff;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.12s, transform 0.1s;
    white-space: nowrap;
    margin-top: 12px;
    position: relative;
    z-index: 1;
}

.action-btn:hover {
    background: #6e35a8;
}

.action-btn:active {
    transform: scale(0.97);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}


.result-area {
    margin-top: 24px;
    max-width: 820px;
}

.chatbot-answer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 2px solid var(--success);
    border-radius: 12px;
    padding: 20px 24px;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--t1);
    animation: msgIn 0.2s ease;
}

.chatbot-answer strong {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--success);
    margin-bottom: 10px;
}


.weather-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 32px;
    animation: msgIn 0.2s ease;
    max-width: 640px;
}

.weather-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
}

.weather-icon {
    width: 52px;
    height: 52px;
}

.weather-location {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.weather-condition {
    font-size: 0.875rem;
    color: var(--t2);
    margin-top: 2px;
}

.weather-temp {
    font-size: 4.5rem;
    font-weight: 200;
    letter-spacing: -0.05em;
    line-height: 1;
    margin: 14px 0 24px;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.weather-detail {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
}

.weather-detail-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--t3);
    margin-bottom: 5px;
}

.weather-detail-value {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.weather-updated {
    margin-top: 16px;
    font-size: 0.72rem;
    color: var(--t3);
}


.error-message {
    background: #fff2f2;
    color: var(--danger);
    border: 1px solid rgba(255, 59, 48, 0.15);
    border-left: 2px solid var(--danger);
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 0.875rem;
    line-height: 1.5;
    animation: msgIn 0.18s ease;
    max-width: 480px;
}


.loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.spinner {
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.55s linear infinite;
}

.spinner.dark {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000;
        --surface: #1c1c1e;
        --sidebar-bg: #111111;
        --border: rgba(255, 255, 255, 0.08);
        --t1: #f5f5f7;
        --t2: #98989d;
        --t3: #48484a;
        --accent: #0a84ff;
    }

    .weather-detail {
        background: #2c2c2e;
    }

    .nav-item.active {
        background: #2c2c2e;
        box-shadow: none;
    }

    .nav-item:hover {
        background: rgba(255, 255, 255, 0.05);
    }
}


.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    flex-shrink: 0;
    transition: background 0.12s;
}

.hamburger:hover {
    background: var(--bg);
}

.hamburger span {
    display: block;
    height: 1.5px;
    background: var(--t1);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}


.sidebar-open .hamburger span:nth-child(1) {
    transform: translateY(5.5px) rotate(45deg);
}

.sidebar-open .hamburger span:nth-child(2) {
    opacity: 0;
}

.sidebar-open .hamburger span:nth-child(3) {
    transform: translateY(-5.5px) rotate(-45deg);
}


.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99;
    backdrop-filter: blur(2px);
    animation: fadeOverlay 0.2s ease;
}

@keyframes fadeOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}


@media (max-width: 1024px) {
    .weather-details {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-cols {
        grid-template-columns: 220px 1fr;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-w: 200px;
    }

    .panel-header {
        padding: 20px 24px 16px;
    }

    .compose-area {
        padding: 10px 24px 8px;
    }

    .form-body {
        padding: 24px 24px 40px;
    }

    .chat-wrap {
        padding: 24px 24px;
    }

    .weather-details {
        grid-template-columns: repeat(3, 1fr);
    }

    .message {
        max-width: 75%;
    }
}

@media (max-width: 680px) {

    html {
        height: 100%;
    }

    body {
        height: 100%;
    }

    .app {
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
    }

    .mobile-topbar {
        display: flex;
        padding-top: max(14px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .main-wrap {
        overflow: hidden;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .panel {
        flex: 1;
        min-height: 0;
        height: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.14);
        width: 260px;
        min-width: 260px;
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-open .sidebar-overlay {
        display: block;
    }

    .nav-item {
        padding: 11px 12px;
        font-size: 0.9375rem;
        border-radius: 10px;
        min-height: 44px;
    }

    .panel-header {
        display: none;
    }

    .chat-wrap {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 16px 14px;
    }

    .chat-messages {
        gap: 10px;
        max-width: 100%;
    }

    .message {
        max-width: 88%;
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    .compose-area {
        padding: 10px 14px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        max-height: 35dvh;
        flex-shrink: 0;
    }

    .compose {
        gap: 8px;
        max-width: 100%;
    }

    .compose-input {
        font-size: 1rem;
        padding: 10px 14px;
        border-radius: 22px;
        max-height: 80px;
    }

    .send-btn {
        width: 42px;
        height: 42px;
        flex-shrink: 0;
    }

    .compose-hint {
        font-size: 0.68rem;
        max-width: 100%;
    }

    .weatherai-inputs {
        flex-wrap: wrap;
        align-items: stretch;
        gap: 8px;
    }

    .weatherai-city-field {
        width: 100%;
        flex: 1 1 100%;
    }

    .weatherai-inputs .compose-input {
        flex: 1 1 0;
        min-width: 0;
    }

    .weatherai-inputs .send-btn {
        flex-shrink: 0;
        align-self: stretch;
    }

    .form-body {
        padding: 16px 14px 24px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    .form-cols {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .field {
        font-size: 1rem;
        min-height: 44px;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 24px;
        min-height: 44px;
        border-radius: 12px;
        font-size: 0.9375rem;
        margin-top: 8px;
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
        max-width: 100%;
        gap: 8px;
    }

    .search-row .action-btn {
        margin-top: 0;
    }

    .weather-card {
        padding: 18px 16px;
        border-radius: 14px;
        max-width: 100%;
    }

    .weather-temp {
        font-size: 3.5rem;
        margin: 10px 0 18px;
    }

    .weather-location {
        font-size: 1.1rem;
    }

    .weather-details {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .weather-detail {
        padding: 10px 6px;
    }

    .weather-detail-value {
        font-size: 0.9rem;
    }

    .weather-detail-label {
        font-size: 0.6rem;
    }

    .result-area {
        margin-top: 16px;
        max-width: 100%;
    }

    .chatbot-answer {
        padding: 16px 18px;
        font-size: 0.9rem;
    }

    .error-message {
        max-width: 100%;
    }
}

@media (max-width: 360px) {
    .weather-details {
        grid-template-columns: repeat(2, 1fr);
    }

    .panel-title {
        font-size: 1.1rem;
    }

    .message {
        max-width: 95%;
    }
}

.mobile-footer {
    display: none;
}

@media (max-width: 680px) {
    .mobile-footer {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 16px max(10px, env(safe-area-inset-bottom));
        background: var(--surface);
        border-top: 1px solid var(--border);
        flex-shrink: 0;
    }

    .mobile-footer-brand {
        font-family: var(--mono);
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--t1);
    }

    .mobile-footer-sep {
        font-size: 0.75rem;
        color: var(--t3);
    }

    .mobile-footer-made {
        font-size: 0.75rem;
        color: var(--t2);
    }

    .mobile-footer-made strong {
        color: var(--t1);
        font-weight: 700;
    }

    .mobile-footer-link {
        font-size: 0.75rem;
        font-weight: 600;
        color: #fff;
        background: #5b2d8e;
        text-decoration: none;
        padding: 3px 10px;
        border-radius: 20px;
        transition: background 0.15s;
    }

    .mobile-footer-link:hover {
        background: #6e35a8;
    }
}
