.app {
    margin-top: 1rem;
    margin-bottom: max(10vw, 4rem);
    padding-bottom: 2rem;
    border-radius: 8px;
    position: relative;
    outline: 1.5px solid var(--clr-border);
}

body.dark-mode .app {
    outline: none;
    box-shadow: 0px 0px 1px 2px var(--clr-secondary) inset;
}

.grain-container {
    position: fixed;
    inset: 0 0 auto 0;
    width: 100dvw;
    height: 100dvh;
    overflow: hidden;
    z-index: -100;
}

svg.grain {
    opacity: 1;
    position: absolute;
    min-height: 100%;
    width: 100%;
    inset: 0 0 auto 0;
}

body.dark-mode svg.grain {
    opacity: 0.15;
}

header,
form {
    padding: min(1.5rem, 5vw);
}

header {
    padding-bottom: 0;
}

/* Request */
.request-info {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.method {
    max-width: fit-content;
    margin-bottom: 1rem;
}

.request-info .url-field {
    width: 100%;
}

.request-info select {
    height: 100%;
}

.request-info textarea {
    min-height: 50px;
    max-height: 100px;
    width: 100%;
    resize: vertical;
}

.request-info-2 {
    margin-top: 1rem;
}

.request-info-2 .forms {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.req-body textarea,
.req-auth textarea {
    height: 130px;
    width: 100%;
    display: block;
    margin-top: 0.5rem;
    resize: none;
    font-size: 0.85rem;
}

.error-msg {
    color: crimson;
    margin-top: 0.5rem;
    display: block;
}

.request-info .send-btn {
    display: grid;
    place-content: center;
    background-color: #4bef7f;
    color: #151f24;
    padding: 0.4em 1.3em;
    border-radius: 100vmax;
    outline-offset: 2px;
    margin-bottom: 2px;
    transition: 120ms;
}

.request-info .send-btn:hover {
    opacity: 0.6;
}

.request-info.send-btn:active {
    scale: 0.99;
}

/* Response */
.bottom {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem;
}

.response-container,
.history {
    outline: 1.5px solid var(--clr-border);
    padding: min(1em, 5%);
    border-radius: 4px;
    max-height: fit-content;
    transition: 300ms;
}

.response-container {
    width: min(500px, 100%);
}

.history {
    width: min(300px, 100%);
}

.bottom.stack {
    flex-direction: column-reverse;
}

.bottom.stack .history,
.response-container {
    width: 100%;
}

@media (max-width: 768px) {
    .bottom {
        display: flex;
        flex-direction: column-reverse;
    }
    .response-container,
    .history {
        width: 100%;
        max-width: 100%;
    }
}

.history {
    overflow-y: scroll;
    max-height: 300px;
}

.history h3 {
    margin-bottom: 1rem;
}

.history ul {
    list-style: none;
    font-size: 0.8rem;
}

.history li {
    margin-bottom: 0.5rem;
    background-color: var(--clr-secondary-o);
    padding: 0.3em 0.6em;
    border-radius: 4px;
    cursor: pointer;
    transition: 150ms;
}

.history li:hover {
    background-color: var(--clr-secondary);
}

.history ul small {
    text-transform: uppercase;
}

.history ul p {
    max-width: 40ch;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ?? */
.clear-history-btn {
    width: 100%;
    display: block;
    margin-top: 1rem;
    padding: 0.6em;
    background-color: rgb(224, 35, 73);
    color: var(--clr-secondary);
}

/* Custom scrollbar for Webkit browsers */
::-webkit-scrollbar {
    width: 4px;
    height: 2px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--clr-primary);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--clr-accent);
}

@media (max-width: 650px) {
    .response-container {
        max-height: 300px;
    }
}

.response {
    display: none;
}

.response-container h3 {
    margin-bottom: 0.5rem;
}

.response__main {
    word-wrap: break-word;
    line-height: 2;
    background-color: transparent;
    color: var(--clr-primary);
    margin-top: 0rem;
    padding-bottom: 2rem;
    padding: 1rem;
    border-radius: 4px;
    border: 1.5px solid var(--clr-border);
    max-height: 150px;
    aspect-ratio: 19/9;
    width: 100% !important;
    overflow-y: scroll;
}

.json-text {
    margin-block: 1rem 0.5rem;
}

.response__header {
    display: flex;
    gap: 1rem;
}

.response__header section {
    display: flex;
    gap: 0.2rem;
    align-items: center;
}

.response__header p {
    padding: 0.1em 0.3em;
}

.toggle-layout-wrapper {
    display: block;
    margin-right: 1.5rem;
    margin-left: auto;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    border-radius: 5px;
    width: 70px;
    height: 30px;
    background-color: var(--clr-secondary-o);
}

.toggle-layout-wrapper box-icon {
    border-radius: 4px;
}

#toggle-layout {
    position: absolute;
    z-index: 2;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.layout-icons {
    display: grid;
    grid-template-columns: 50% 50%;
    justify-items: center;
    padding: 0.2em 0.1em;
    position: absolute;
    inset: 0;
}
.toggle-layout-wrapper .bg {
    position: absolute;
    width: 50%;
    height: 100%;
    inset: 0;
    background-color: #bdb9b9;
    z-index: -2;
    transition: 150ms;
}

body.dark-mode .toggle-layout-wrapper {
    background-color: var(--clr-secondary-o);
}

body.dark-mode .toggle-layout-wrapper .bg {
    background-color: var(--clr-secondary);
}

#toggle-layout:checked + .bg {
    left: 50%;
}

/* Response layout is stacked on small screens; remove toggle button */
@media (max-width: 768px) {
    .toggle-layout-wrapper {
        display: none;
    }
}
