/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2333;
    --border: #30363d;
    --border-light: #3d444d;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --accent: #58a6ff;
    --accent-glow: rgba(88, 166, 255, .15);
    --green: #3fb950;
    --green-dim: rgba(63, 185, 80, .15);
    --yellow: #d29922;
    --yellow-dim: rgba(210, 153, 34, .15);
    --red: #f85149;
    --red-dim: rgba(248, 81, 73, .15);
    --orange: #db6d28;
    --purple: #bc8cff;
    --radius: 10px;
    --radius-lg: 14px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, .4);
    --glass: rgba(22, 27, 34, .65);
    --glass-border: rgba(48, 54, 61, .6);
}

html {
    font-size: 15px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    overflow: hidden;
    animation: appFadeIn .5s ease;
}

/* ── Dot Grid Background ── */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image: radial-gradient(rgba(88, 166, 255, .06) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
}

/* ── Animations ── */
@keyframes appFadeIn {
    from {
        opacity: 0;
        transform: scale(.99);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(88, 166, 255, .2);
    }

    50% {
        box-shadow: 0 0 20px 4px rgba(88, 166, 255, .1);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(.9);
    }

    70% {
        transform: scale(1.02);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes badgeSlide {
    from {
        opacity: 0;
        transform: translateX(8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .4;
    }
}

@keyframes placeholderFloat {

    0%,
    100% {
        transform: translateY(0);
        opacity: .25;
    }

    50% {
        transform: translateY(-8px);
        opacity: .4;
    }
}

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

@keyframes borderShimmer {

    0%,
    100% {
        border-color: var(--glass-border);
    }

    50% {
        border-color: rgba(88, 166, 255, .25);
    }
}

/* ── Header ── */
header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    animation: slideDown .4s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-dim);
    text-decoration: none;
    transition: all .2s;
}

.back-btn:hover {
    color: var(--accent);
    background: var(--accent-glow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
}

.logo h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--green);
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--green-dim);
    border: 1px solid rgba(63, 185, 80, .2);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: statusPulse 2s ease-in-out infinite;
}

/* ── Main Layout ── */
main {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 0;
    height: calc(100vh - 57px);
}

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Glass Panels ── */
.panel {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, .15);
}

.panel-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-dim);
}

/* ── Request Panel ── */
.request-panel {
    border-bottom: 1px solid var(--glass-border);
    animation: slideDown .35s ease .05s backwards;
}

/* ── URL Bar ── */
.url-bar {
    display: flex;
    gap: 0;
    padding: 14px 20px;
    background: transparent;
    border-bottom: 1px solid var(--glass-border);
}

#method-select {
    font-family: var(--mono);
    font-size: .82rem;
    font-weight: 700;
    padding: 10px 14px;
    background: var(--bg);
    color: var(--green);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    min-width: 96px;
    text-align: center;
    transition: border-color .2s;
}

#method-select:focus {
    border-color: var(--accent);
}

#url-input {
    flex: 1;
    font-family: var(--mono);
    font-size: .85rem;
    padding: 10px 16px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: none;
    border-right: none;
    outline: none;
    transition: all .2s;
}

#url-input:focus {
    background: rgba(13, 17, 23, .9);
    box-shadow: 0 0 0 1px rgba(88, 166, 255, .15) inset;
}

#url-input::placeholder {
    color: var(--text-dim);
}

#send-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    font-family: var(--font);
    font-size: .85rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #7c6cff);
    color: #fff;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    overflow: hidden;
}

#send-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

#send-btn:hover {
    box-shadow: 0 4px 20px rgba(88, 166, 255, .3);
    transform: translateY(-1px);
}

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

#send-btn.loading {
    pointer-events: none;
    opacity: .6;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0;
    padding: 0 20px;
    background: transparent;
    border-bottom: 1px solid var(--glass-border);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    font-size: .78rem;
    font-weight: 500;
    padding: 10px 16px;
    color: var(--text-dim);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all .2s;
}

.tab:hover {
    color: var(--text);
}

.tab:active {
    transform: scale(.95);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab svg {
    opacity: .6;
}

.tab.active svg {
    opacity: 1;
}

/* ── Tab Content ── */
.tab-body {
    max-height: 220px;
    overflow-y: auto;
}

.tab-content {
    padding: 14px 20px;
    background: transparent;
}

/* ── Key-Value Rows ── */
.kv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.kv-header span {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    font-weight: 600;
}

.add-row-btn {
    font-size: .72rem;
    padding: 4px 12px;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(88, 166, 255, .2);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all .2s;
}

.add-row-btn:hover {
    background: rgba(88, 166, 255, .25);
    border-color: var(--accent);
}

.kv-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.kv-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
    flex-shrink: 0;
}

.kv-row input[type="text"],
.kv-key,
.kv-value {
    flex: 1;
    font-family: var(--mono);
    font-size: .8rem;
    padding: 7px 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.kv-row input[type="text"]:focus {
    border-color: rgba(88, 166, 255, .4);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, .08);
}

.remove-row-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all .15s;
    flex-shrink: 0;
}

.remove-row-btn:hover {
    color: var(--red);
    background: var(--red-dim);
}

/* ── Body Tab ── */
.body-type-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.body-type-bar label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: var(--text-dim);
    cursor: pointer;
    transition: color .15s;
}

.body-type-bar label:hover {
    color: var(--text);
}

.body-type-bar input[type="radio"] {
    accent-color: var(--accent);
}

#body-editor {
    width: 100%;
    min-height: 120px;
    font-family: var(--mono);
    font-size: .82rem;
    line-height: 1.6;
    padding: 12px 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
    outline: none;
    tab-size: 2;
    transition: border-color .2s;
}

#body-editor:focus {
    border-color: rgba(88, 166, 255, .4);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, .08);
}

/* ── Auth Tab ── */
.auth-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-section label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    font-weight: 600;
}

.auth-section select,
.auth-section input[type="text"],
.auth-section input[type="password"] {
    font-family: var(--mono);
    font-size: .82rem;
    padding: 8px 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: border-color .2s;
}

.auth-section select {
    cursor: pointer;
}

.auth-section input:focus,
.auth-section select:focus {
    border-color: rgba(88, 166, 255, .4);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, .08);
}

.auth-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

/* ── Response Panel ── */
.response-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp .35s ease .1s backwards;
}

.response-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--glass-border);
    background: transparent;
}

.response-tabs {
    display: flex;
    gap: 0;
}

.response-meta {
    display: flex;
    gap: 8px;
    font-family: var(--mono);
    font-size: .72rem;
}

.meta-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    animation: badgeSlide .3s ease backwards;
}

.meta-badge:nth-child(2) {
    animation-delay: .08s;
}

.meta-badge:nth-child(3) {
    animation-delay: .16s;
}

.meta-badge.status-2xx {
    background: var(--green-dim);
    color: var(--green);
}

.meta-badge.status-3xx {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.meta-badge.status-4xx {
    background: var(--red-dim);
    color: var(--red);
}

.meta-badge.status-5xx {
    background: var(--red-dim);
    color: var(--red);
}

.meta-badge.time {
    background: rgba(188, 140, 255, .1);
    color: var(--purple);
}

.meta-badge.size {
    background: rgba(88, 166, 255, .08);
    color: var(--accent);
}

/* ── Response Content ── */
.response-content {
    flex: 1;
    overflow: auto;
    padding: 0;
    background: var(--bg);
}

.placeholder-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: 100%;
    min-height: 200px;
    color: var(--text-dim);
    font-size: .88rem;
}

.placeholder-msg svg {
    opacity: .25;
    animation: placeholderFloat 4s ease-in-out infinite;
}

.placeholder-msg strong {
    color: var(--accent);
}

/* ── Example Chips ── */
.examples {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.examples-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-dim);
    font-weight: 600;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 520px;
}

.example-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-family: var(--font);
    font-size: .78rem;
    color: var(--text-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all .2s;
}

.example-chip:hover {
    border-color: var(--accent);
    color: var(--text);
    background: var(--surface-2);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}

.example-chip:active {
    transform: translateY(0) scale(.96);
}

.chip-method {
    font-family: var(--mono);
    font-size: .62rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
}

.chip-method.get {
    background: var(--green-dim);
    color: var(--green);
}

.chip-method.post {
    background: var(--yellow-dim);
    color: var(--yellow);
}

/* Spinner */
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* Response body */
#response-body {
    margin: 0;
    padding: 18px 20px;
    font-family: var(--mono);
    font-size: .8rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    background: var(--bg);
    overflow: auto;
    height: 100%;
}

/* JSON Syntax Highlighting */
.json-key {
    color: #79c0ff;
}

.json-string {
    color: #a5d6ff;
}

.json-number {
    color: #d2a8ff;
}

.json-bool {
    color: #ff7b72;
}

.json-null {
    color: var(--text-dim);
    font-style: italic;
}

/* Response headers table */
#response-headers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

#response-headers-table th {
    text-align: left;
    padding: 10px 20px;
    background: var(--surface);
    color: var(--text-dim);
    font-weight: 600;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
}

#response-headers-table td {
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: .78rem;
}

#response-headers-table td:first-child {
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
}

#response-headers-table tr:hover td {
    background: rgba(88, 166, 255, .03);
}

/* ── History Panel ── */
.history-panel {
    width: 260px;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--glass-border);
    background: var(--glass);
    animation: slideDown .4s ease .15s backwards;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, .15);
}

.history-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-dim);
}

#clear-history-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all .15s;
}

#clear-history-btn:hover {
    color: var(--red);
    background: var(--red-dim);
}

#history-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
}

.history-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: .8rem;
}

.history-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(48, 54, 61, .3);
    transition: all .2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: slideUp .25s ease backwards;
}

.history-item:hover {
    background: rgba(88, 166, 255, .04);
    border-color: rgba(88, 166, 255, .1);
}

.history-item:active {
    transform: scale(.98);
}

.history-item-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-method {
    font-family: var(--mono);
    font-size: .65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 44px;
    text-align: center;
}

.method-GET {
    background: var(--green-dim);
    color: var(--green);
}

.method-POST {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.method-PUT {
    background: rgba(88, 166, 255, .12);
    color: var(--accent);
}

.method-PATCH {
    background: rgba(188, 140, 255, .12);
    color: var(--purple);
}

.method-DELETE {
    background: var(--red-dim);
    color: var(--red);
}

.method-HEAD {
    background: rgba(139, 148, 158, .1);
    color: var(--text-dim);
}

.method-OPTIONS {
    background: rgba(139, 148, 158, .1);
    color: var(--text-dim);
}

.history-status {
    font-family: var(--mono);
    font-size: .65rem;
    margin-left: auto;
    opacity: .6;
}

.history-url {
    font-family: var(--mono);
    font-size: .68rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ── Utility ── */
.hidden {
    display: none !important;
}

/* ── Method Colors ── */
.method-color-GET {
    color: var(--green);
}

.method-color-POST {
    color: var(--yellow);
}

.method-color-PUT {
    color: var(--accent);
}

.method-color-PATCH {
    color: var(--purple);
}

.method-color-DELETE {
    color: var(--red);
}

/* ── Error display ── */
.error-msg {
    color: var(--red);
    padding: 20px;
    font-family: var(--mono);
    font-size: .82rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-msg .error-title {
    font-weight: 700;
    font-size: .88rem;
}

.error-msg .error-detail {
    color: var(--text-dim);
    font-size: .78rem;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    main {
        flex-direction: column;
    }

    .history-panel {
        width: 100%;
        min-width: 100%;
        border-left: none;
        border-top: 1px solid var(--glass-border);
        max-height: 180px;
    }
}