/*
 * Copyright (c) 2021 - 2026 ThorVG project. All rights reserved.

 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

:root {
    --font-sans: "Open Sans", 'Noto Mono', 'DejaVu Sans Mono', monospace;
    --font-mono: "JetBrains Mono", Roboto Mono, monospace;

    --ctrl-item-padding: 1rem;
    --ctrl-layout-width: 320px;

    --ctrl-title-color: rgba(255, 255, 255, 0.89);
    --ctrl-background-color: #171717;
    --ctrl-surface-color: #242424;
    --ctrl-primary-color: #FFF;
    --ctrl-secondary-color: #6B6B6B;
    --ctrl-tertiary-color: #a8a8a8;
    --ctrl-hover-color: rgb(66, 66, 66);
    --ctrl-border-color: rgba(255, 255, 255, 0.125);
    --scrollbar-color: color-mix(in oklab, #0d0d0d 30%, transparent);
    --ctrl-scrollbar-color: color-mix(in oklab, #f0f0f0 30%, transparent);

    --popup-focused-color: #E5FF39;
    --popup-border-color: #000;
}

* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-color: var(--scrollbar-color) transparent;
    scrollbar-width: thin;
}

html, body {
    height: 100%;
}

body {
    color: #484848;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-flow: row nowrap;
    user-select: none;
    -webkit-user-select: none;
}

a {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: all 0.4s ease;
}

::selection {
    color: #fff;
    background: rgb(48, 48, 48);
}

hr {
    border: 0;
    border-bottom: 1px solid var(--ctrl-border-color);
}

.root-container {
    flex: 1 1 0;
    display: grid;
    grid-template-columns: 1fr var(--ctrl-layout-width);
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.root-container .hidden {
    display: none;
}

input[type=range] {
    -webkit-appearance: none;
    height: 5px;
    border-radius: 3px;
    background-color: #878787; /* progress bar's background color */
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    border: 1px solid;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background-color: #fff;
    cursor: pointer;
}

input[type=range]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    box-shadow: 0 0 3px #666;
    background-color: #fff;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    float: left;
}

.drawer {
    display: flex;
    flex-direction: column;
    width: var(--ctrl-layout-width);
    height: 100%;
    background-color: var(--ctrl-background-color);
    color: white;
    position: relative;
    overflow: hidden; /* No scroll */
    z-index: 2000;
}

.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 300;
}

.section-controls {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-color: var(--ctrl-scrollbar-color) transparent;
    padding-top: 18px;
    margin-bottom: 6rem;
}

.section-controls .inner-container.column, .section-controls .inner-container.row {
    width: 100%;
    padding-top: 0rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.125);
}

.section-controls .inner-container.row {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 12px;
}

.section-upload {
    position: absolute;
    width: 100%;
    bottom: 0;
    left: 0;
    background: var(--ctrl-surface-color);
    padding: 1.25rem 1rem;
    z-index: 2200;
}

.section-upload .inner-container {
    padding-top: 1.25rem;
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 12px;
}

.control-item:last-of-type {
    border-bottom-width: 1px;
}

.item-expand {
    display: flex;
    align-items: center;
    flex-direction: row;
    padding-left: var(--ctrl-item-padding);
    padding-right: var(--ctrl-item-padding);
    height: 3.2rem;
}

.expand-button {
    display: none; /*flex;*/
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    transition: all 0.2s;
    padding: 0;
    margin-right: 0.375rem;
    border-radius: 9999px;
    border: none;
    background-color: inherit;
    color: var(--ctrl-primary-color);
    font-size: 1rem;
}

.expand-button:hover {
    color: var(--ctrl-hover-color);
    background-color: var(--ctrl-surface-color);
}

.expand-icon {
    display: block;
    stroke: currentColor;
    fill: none;
    width: 1rem;
    height: 1rem;
    font-size: calc(1.5rem);
    transform: rotate(180deg);
    transition: transform 0.25s;
    vertical-align: middle;
}

h2.ctrl-title {
    margin: 0;
    flex: 1;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.03125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ctrl-title-color);
}

h4.ctrl-description {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.25rem;
    color: var(--ctrl-secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin: 0;
}

.ctrl-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.075);
    color: var(--ctrl-primary-color);
    border: none;
    border-radius: 0.5rem;
    height: 2.25rem;
    font-weight: 600;
    text-transform: uppercase;
    flex: 1;
}

.ctrl-button:hover {
    background-color: var(--ctrl-hover-color);
}

.ctrl-button img {
    width: 18px;
    height: auto;
}

.ctrl-button.trash {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.25rem;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    margin-top: 11px;
    margin-right: 1rem;
    align-self: center; /* 자기만 세로 중앙 정렬 */
    width: auto;
}

.ctrl-button.close {
    display: inline-flex;
    width: auto;
    box-sizing: content-box;
    flex: 0 0 auto; /* 중요: 기본 flex 속성 무효화 */
}

.ctrl-top-menu {
    justify-content: space-between;
    align-items: center;
    padding-left: var(--ctrl-item-padding);
    padding-right: var(--ctrl-item-padding);
    padding-bottom: 1.25rem;
}

.ctrl-top-menu .ctrl-button {
    padding: 0 0.8rem;
}

.ctrl-button-set {
    display: flex;
    gap: 12px;
}

.controls {
    position: relative;
    width: 100%;
    height: 100%;
    border-left: 1px solid var(--ctrl-border-color);
}

#zoom-slider-container, #progress-slider-container {
    margin-top: 0.3rem;
    width: 100%;
    display: flex;
    height: 2.25rem;
    align-items: center;
}

#zoom-slider, #progress-slider {
    width: 100%;
}

.progress-button-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(25%, 1fr));
    background: var(--ctrl-surface-color);
    border-radius: 0.5rem;
    padding: 0.25rem;
    align-items: center;
    margin-top: 0.625rem;
}

.progress-button {
    display: flex;
    align-items: center;
    -webkit-box-pack: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 0.5rem;
    color: var(--ctrl-primary-color);
    font-size: 0.875rem;
    font-weight: 600;
    height: 1.75rem;
    position: relative;
}

.progress-button:hover {
    background: rgb(48, 48, 48);
}

.progress-button svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: currentColor;
}

#aside-top #zoom-value.incorrect {
    outline-color: red;
    -webkit-animation: shake .5s linear;
}

#file-detail {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.line {
    display: flex;
    flex-direction: column;
    position: relative; /* trash의 위치 기준 */
    align-items: flex-start;
    gap: 4px;
    font-family: var(--font-sans);
}

.line-title {
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.2rem;
    color: var(--ctrl-secondary-color);
    margin: 0;
}

.line-content {
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.5rem;
    color: var(--ctrl-tertiary-color);
}

#files-list .container {
    padding-bottom: 64px;
    gap: 4px;
}

#files-list .line {
    align-items: center;
    padding: 4px 1rem 8px 1rem;
}

#files-list .line:hover {
    background-color: var(--ctrl-hover-color);
    cursor: pointer;
}

.line-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 4px;
    margin-right: 2.5rem;
}

.line-name,
.line-details {
    text-align: left;
    width: 100%;
    word-break: break-all;
}

.line-name {
    color: var(--ctrl-tertiary-color);
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.5rem;
}

.line-details {
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.2rem;
    color: var(--ctrl-secondary-color);
}

.trash {
    position: absolute;
    top: 0;
    right: 0;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.trash svg {
    fill: var(--ctrl-primary-color);
    width: 0.95rem;
    height: 0.95rem;
    font-size: calc(1 / 1.25 * 1.5rem);
}

.placeholder {
    padding: 0;
    width: 100%;
}

.preview {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#image-area {
    display: flex;
    flex: 1;
    background-color: #f6f6f6;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-sans);
    z-index: 1;
}

body.dark-mode #image-area {
    background-color: #1b2124;
    color: #f6f6f6;
}

#image-area.highlight {
    background-color: #272f34;
    color: #f6f6f6;
}

#image-placeholder {
    display: flex;
    width: 500px;
    height: 500px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 1.15rem;
    font-weight: 500;
    letter-spacing: .05em;
    text-align: center;
    gap: 1rem;
    color: #737373;
    cursor: pointer;
    border-radius: 0.5rem;
    background-color: rgba(0,0,0,0.07);
    border-image-slice: 1;
    border-image-repeat: round;
}

#image-placeholder.hidden {
    display: none;
}

body.dark-mode #image-placeholder {
    background-color: rgba(0,0,0,0.1);
    color: #5b6f7b;
    cursor: pointer;
}

@media (max-width: 1024px) {
    #image-placeholder {
        width: 400px;
        height: 400px;
    }
}

@media (max-width: 640px) {
    #image-placeholder {
        width: 300px;
        height: 300px;
    }
}

#image-file-selector {
    display: none;
}

#console-area {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 150px;
  padding: 6px 0;
  overflow-y: scroll;
  z-index: 500;
  background-color: #2C2C2C;
  border-top: 1px solid var(--ctrl-border-color);
  scrollbar-color: var(--ctrl-scrollbar-color) transparent;

  /* initial status: hidden + transparent */
  transform: translateY(100%);
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#console-area.show {
  transform: translateY(0);
  pointer-events: auto;
}

#console-area > span {
    display: block;
    font-size: 12px;
    font-family: var(--font-mono);
    -webkit-user-select: text;
    padding: 2px 14px;
    line-height:  23px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    user-select: text;
}

#console-area > span.console-type-inner {
    color: var(--ctrl-title-color);
}

#console-area > span.console-type-error {
    color: #B71C1C;
    background-color: #322a26;
}

#console-area > span.console-type-warning {
    color: #b38a29;
    background-color: #342f24;
}

#console-area > span::selection {
    background-color: rgba(255, 255, 255, 0.5);
}

#console-area > span.console-type-error::selection {
    color: #E53935;
}

#console-area > span.console-type-warning::selection {
    color: #FFF176;
}

#console-bottom-scroll {
    right: 16px;
    bottom: 16px;
    border-radius: 50%;
    border: 1px solid #e5e7ec;
    background: #fdfdfd;
    color: #e5e7ec;
    width: 32px;
    line-height: 32px;
    text-align: center;
}

#console-bottom-scroll:hover {
    border-color: #aab3bb;
    color: #aab3bb;
}

.info-area {
    display: flex;
    position: fixed;
    left: 20px;
    bottom: 0;
    width: 180px;
    height: 26px;
    justify-content: center;
    align-items: center;
    text-align: center;
    transform-origin: left top;
    padding: 0 16px;
    background-color: var(--ctrl-background-color);
    color: white;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    border-top: 1px solid var(--ctrl-border-color);
    border-left: 1px solid var(--ctrl-border-color);
    border-right: 1px solid var(--ctrl-border-color);
    white-space: nowrap;
    z-index: 301;
}

.info-area p {
    font-family: var(--font-sans);
    font-size: 13px;
}

.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 9999;
    background-color: #0003;
    font-family: var(--font-sans);
}

.popup > div {
    max-width: 600px;
    margin: 48px auto;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform .4s ease;
    transform: translateY(-48px);
}

.popup > div.faded {
    transform: none;
}

.popup > div > header {
    padding: 24px 24px 12px 24px;
    font-size: 18px;
    font-weight: 600;
    color: #000;
}

.popup > div > .input-group {
    position: relative;
    margin: 8px 24px;
    display: flex;
}

.popup > div > .input-group > * {
    line-height: 24px;
    padding: 8px 16px;
    border: 1px solid #000;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: block;
}

.popup > div > .input-group > span {
    border-radius: 3px 0 0 3px;
    border-right: none;
    color: #fff;
    background: #000;
    text-transform: uppercase;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1.2px;
}

.popup > div > .input-group > input {
    border-radius: 0 3px 3px 0;
    background: #fff;
    -webkit-appearance: none;
    flex: 1 1 auto;
    font-size: 15px;
    font-weight: 500;
}

#url-field {
    font-family: var(--font-sans);
    font-weight: 400;
}

#url-field::placeholder {
    color: #999;
    font-family: var(--font-sans);
}

.popup > div > .input-group > input:focus {
    outline: none;
    border-color: var(--popup-border-color);
}

.popup > div > .input-group:focus-within > span {
    color: #000;
    background: var(--popup-focused-color);
    border-color: var(--popup-border-color);
}

.posttext {
    padding: 8px 24px;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 24px;
    color: #000;
}

.posttext a {
    color: #5a8be4;
    word-break: break-all;
}

.posttext a:hover {
    text-decoration: underline;
}

.popup > div > footer {
    padding: 12px 24px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.popup-button {
    box-sizing: border-box;
    border: 1px solid var(--popup-border-color);
    background-color: var(--popup-border-color);
    color: white;
    padding: 8px 16px;
    border-radius: 3px;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-align: center;
}

.popup-button:hover {
    color: #000;
    background-color: var(--popup-focused-color);
}

@-webkit-keyframes shake {
    8%, 41% { -webkit-transform: translateX(-10px); }
    25%, 58% { -webkit-transform: translateX(10px); }
    75% { -webkit-transform: translateX(-5px); }
    92% { -webkit-transform: translateX(5px); }
    0%, 100% { -webkit-transform: translateX(0); }
}

lottie-player {
    position: fixed;
    width: 800px;
    height: 800px;
    overflow: hidden;
    display: block;
    z-index: 100;
    outline: 1px solid rgba(136, 136, 136, 0.3);
}

#renderer-select {
    position: relative;
    display: inline-block;
    flex-direction: column;
    justify-content: center;
    align-items: start;
    width: 100%;
    height: 2.25rem;
}

#renderer-dropdown {
    width: 100%;
    padding: 0 20px;
    border: none;
    background-color: rgb(48, 48, 48);
    color: var(--ctrl-title-color);
    height: 2.25rem;
    border-radius: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.2s;
    outline: none;
}

#renderer-select .arrow-icon {
    position: absolute;
    pointer-events: none;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: var(--ctrl-primary-color);
}

#renderer-dropdown:hover {
    color: var(--ctrl-primary-color);
    background-color: var(--ctrl-hover-color);
}

#renderer-dropdown:disabled {
    color: var(--ctrl-secondary-color);
    cursor: not-allowed;
}

#quality-select {
    position: relative;
    display: inline-block;
    flex-direction: column;
    justify-content: center;
    align-items: start;
    width: 100%;
    height: 2.25rem;
}

#quality-dropdown {
    width: 100%;
    padding: 0 20px;
    border: none;
    background-color: rgb(48, 48, 48);
    color: var(--ctrl-title-color);
    height: 2.25rem;
    border-radius: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 1rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

#quality-select .arrow-icon {
    position: absolute;
    pointer-events: none;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: var(--ctrl-primary-color);
}

#quality-dropdown:hover {
    color: var(--ctrl-primary-color);
    background-color: var(--ctrl-hover-color);
}

#renderer-dropdown {
    padding-right: 40px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
}

.actions {
    position: fixed;
    top: 16px;
    right: 80px;
    z-index: 1000;
    border: 1px solid var(--ctrl-border-color);
    border-radius: 4px;
    transition: right 0.3s ease-in-out;
}

.button {
    width: 40px;
    height: 40px;
    cursor: pointer;
    background-color: var(--ctrl-background-color);
    background-repeat: no-repeat;
    background-position: center;
    outline: 0;
    border: none;
}

.button:hover {
    background-color: var(--ctrl-hover-color);
}

.actions .button-stats {
    right: 18px;
    background-image: url(icon/stats.svg);
    background-size: 18px 18px;
    border-right: 1px solid var(--ctrl-border-color);
    border-radius: 3px 0 0 3px
}

.actions .button-dark {
    border-radius: 3px;
    right: 18px;
    background-image: url(icon/dark.svg);
    background-size: 18px 18px;
    border-right: 1px solid var(--ctrl-border-color);
    border-radius: 0;
}

.actions .button-history {
    border-radius: 3px;
    right: 18px;
    background-image: url(icon/history.svg);
    background-size: 18px 18px;
    border-radius: 0 3px 3px 0;
}

.action label {
    display: none;
}

@media (max-width: 480px) {
    .actions {
        display: none;
    }

    .ctrl-top-menu {
        display: flex;
    }
}

@media (min-width: 481px) {
    .actions {
        display: flex;
        /* apply .action right in main.js */
    }

    .ctrl-top-menu {
        display: none;
    }
}

@media (max-width: 1023px) {
    .root-container {
        grid-template-columns: 1fr;
    }

    .drawer {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        z-index: 500;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: none;
    }

    .drawer.open {
        transform: translateX(0);
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
    }

    .drawer-toggle {
        position: fixed;
        top: 16px;
        right: 20px;
        background-image: url(icon/menu.svg);
        background-size: 18px 18px;
        border-radius: 3px;
        border: 1px solid var(--ctrl-border-color);
        z-index: 200;
    }

    .drawer-backdrop.show {
        display: block;
    }
}

@media (min-width: 1024px) {
    .actions {
        display: flex;
        right: 340px;
    }

    .drawer {
        transition: none !important;
    }

    .drawer-toggle {
        display: none;
    }
}
