:root {
    --bg-deep: #0d1117;
    --bg-panel: #161b22;
    --bg-elevated: #1c2128;
    --border: #30363d;
    --border-subtle: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #5968bb;
    --text-muted: #6e7681;
    --accent-blue: #c8d3e1;
    --accent-blue-hover: #32ff8d;
    --accent-green: #00ffa2;
    --accent-pink: #de145f;
    --accent-yellow: #ffc638;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2.5rem 1.25rem;
    line-height: 1.55;
}

/* ---------- Terminal Window ---------- */

.terminal-window {
    width: 100%;
    max-width: 720px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 16px 48px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 5rem);
}

/* Title bar */
.title-bar {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    user-select: none;
    flex-shrink: 0;
}

.traffic-lights {
    display: flex;
    gap: 7px;
    flex-shrink: 0;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: block;
}

    .dot.red {
        background: #ff5f56;
    }

    .dot.yellow {
        background: #ffbd2e;
    }

    .dot.green {
        background: #27c93f;
    }

.title {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.title-spacer {
    width: 52px;
}

/* Terminal body */
.terminal-body {
    padding: 1.4rem 1.6rem 1.6rem;
    font-size: 0.92rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    scroll-behavior: smooth;
}

/* ---------- Prompt lines ---------- */

.line {
    margin-bottom: 0.75rem;
    white-space: nowrap;
}

.prompt {
    color: var(--accent-green);
    font-weight: 400;
}

.separator {
    color: var(--text-secondary);
}

.path {
    color: var(--accent-blue);
    font-weight: 400;
}

.dollar {
    color: var(--text-primary);
    margin-right: 0.55rem;
}

.command {
    color: var(--text-primary);
}

/* ---------- Interactive input line ---------- */

.input-line {
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
    white-space: nowrap;
    cursor: text;
    padding: 0.35rem 0.4rem;
    margin-left: -0.4rem;
    margin-right: -0.4rem;
    border-radius: 4px;
    transition: background 0.12s ease;
}

    .input-line:hover,
    .input-line:focus-within {
        background: rgba(0, 255, 162, 0.04);
    }

    .input-line .dollar {
        margin-right: 0.4rem;
    }

#cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 400;
    caret-color: var(--accent-green);
    padding: 0;
    margin: 0;
    min-width: 0;
    -webkit-user-select: text;
    user-select: text;
}

    #cmd-input::selection {
        background: rgba(0, 255, 162, 0.25);
    }

.terminal-body,
.terminal-body * {
    -webkit-user-select: text;
    user-select: text;
}

::selection {
    background: rgba(0, 255, 162, 0.25);
}

/* ---------- History / command output ---------- */

#history {
    margin-top: 0.5rem;
}

.history-block {
    margin-bottom: 0.6rem;
}

.cmd-echo {
    margin-bottom: 0.25rem !important;
}

.cmd-output {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0.15rem 0 0.6rem 0;
    line-height: 1.5;
}

    .cmd-output.welcome {
        color: var(--text-muted);
        font-style: italic;
        margin-top: 1rem;
    }

/* ---------- Output / meta ---------- */

.output-block {
    margin-bottom: 1.6rem;
    color: var(--text-secondary);
    font-size: 0.72rem;
}

    .output-block .meta {
        margin-bottom: 0.35rem;
    }

.dir-entry {
    margin: 0.15rem 0;
    font-weight: 300;
}

.dir {
    color: var(--accent-blue);
    font-weight: 600;
}

/* ---------- Typography ---------- */

h1 {
    font-size: 1.55rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0.4rem 0 0.35rem;
    letter-spacing: -0.01em;
}

    h1::before {
        content: "# ";
        color: var(--accent-yellow);
        font-weight: 400;
    }

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.8rem;
    font-weight: 400;
}

h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-pink);
    margin: 1.6rem 0 0.7rem;
    letter-spacing: 0.01em;
}

    h2::before {
        content: "## ";
        color: var(--text-muted);
        font-weight: 500;
    }

h3 {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin: 1rem 0 0;
    letter-spacing: 0.01em;
}

    h3::before {
        content: "### ";
        color: var(--text-tertiary);
        font-weight: 400;
    }

p {
    color: var(--text-secondary);
    margin-bottom: 0.85rem;
    max-width: 64ch;
}

/* ---------- File list ---------- */

.section {
    margin-bottom: 0.4rem;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

    .file-list li {
        padding: 0.32rem 0.5rem;
        margin: 0 -0.5rem;
        border-radius: 5px;
        transition: background 0.12s ease;
    }

        .file-list li:hover {
            background: rgba(0, 255, 162, 0.05);
        }

.file-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.filename {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.12s ease;
    word-break: break-all;
    cursor: pointer;
}

    .filename:hover {
        color: var(--accent-blue-hover);
        text-underline-offset: 3px;
    }

    .filename::before {
        content: "--> ";
        color: var(--text-tertiary);
        font-weight: 400;        
    }

    .filename:hover::before {
        content: "--> ";
        color: var(--accent-blue-hover);
        text-decoration: none;
        font-weight: 400;
    }

.file-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

.download-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.12s ease;
}

    .download-link:hover {
        color: var(--accent-green);
    }

.meta-right {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ---------- Preview Frame ---------- */

.preview-frame {
    margin: 0.6rem 0 0.75rem 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-deep);
    overflow: hidden;
    animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

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

.preview-header {
    padding: 0.35rem 0.75rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}

.preview-body {
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
    background: #0a0e14;
    transition: background 0.25s ease;
}

.preview-body.bg-light {
    background: #e6e9ef;
}

.preview-body.bg-dark {
    background: #0a0e14;
}

    .preview-body img {
        max-width: 50%;
        max-height: 20%;
        object-fit: contain;
        border-radius: 2px;
        cursor: pointer;
        transition: opacity 0.15s ease;
    }

        .preview-body img:hover {
            opacity: 0.9;
        }

.preview-text-body {
    padding: 0.85rem 1rem;
    max-height: 300px;
    overflow: auto;
    text-align: left;
    min-height: 0;
    display: block;
}

.preview-text {
    margin: 0;
    max-height: 100%;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    cursor: pointer;
}

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


/* ---------- Gallery View ---------- */

.hidden {
    display: none !important;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.gallery-title {
    color: var(--accent-green);
    font-weight: 500;
}

.gallery-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.gallery-content {

}

.gallery-section {
    margin-bottom: 2.2rem;
}

.gallery-section:last-child {
    margin-bottom: 0.5rem;
}

.gallery-h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-pink);
    margin: 0 0 0.85rem;
    letter-spacing: 0.01em;
}

.gallery-h2::before {
    content: "## ";
    color: var(--text-muted);
    font-weight: 500;
}

.gallery-h3 {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin: 0 0 0.65rem;
    letter-spacing: 0.01em;
}

.gallery-h3::before {
    content: "### ";
    color: var(--text-tertiary);
    font-weight: 400;
}

.gallery-subsection {
    margin-bottom: 1.5rem;
}

.gallery-subsection:last-child {
    margin-bottom: 0;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.gallery-subsection .gallery-grid {
    margin-bottom: 0;
}

.gallery-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-deep);
    transition: border-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}

    .gallery-card:hover {
        border-color: var(--accent-green);
        transform: translateY(-2px);
    }

.gallery-thumb {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: #0a0e14;
    transition: background 0.15s ease;
}

.gallery-thumb.bg-light {
    background: #e6e9ef;
}

.gallery-thumb.bg-dark {
    background: #0a0e14;
}

    .gallery-thumb img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

.gallery-label {
    padding: 0.45rem 0.6rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* ---------- Image Modal ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    padding: 1.5rem;
    animation: modalFadeIn 0.18s ease;
}

    .modal.hidden {
        display: none !important;
    }

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-window {
    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - 3rem);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 24px 64px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

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

.modal-window .title-bar {
    flex-shrink: 0;
}

.modal-window .title {
    font-size: 0.8rem;
}

.modal-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 52px;
    justify-content: flex-end;
}

.modal-download-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 400;
    transition: color 0.12s ease;
    white-space: nowrap;
}

.modal-download-link:hover {
    color: var(--accent-green);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    background: var(--bg-deep);
    flex: 1;
    min-height: 200px;
    transition: background 0.15s ease;
}

.modal-body.bg-light {
    background: #e6e9ef;
}

.modal-body.bg-dark {
    background: #0a0e14;
}

    .modal-body img {
        max-width: 100%;
        max-height: min(70vh, 560px);
        object-fit: contain;
        border-radius: 2px;
    }

.modal .dot.red {
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}

    .modal .dot.red:hover {
        transform: scale(1.15);
        filter: brightness(1.15);
    }

.modal-text {
    margin: 0;
    width: 100%;
    max-height: min(70vh, 720px);
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
    padding: 0.25rem;
}



.gallery-thumb-text {
    background: #0a0e14;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-badge {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-yellow);
    letter-spacing: 0.06em;
    border: 1px solid var(--border);
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    background: var(--bg-elevated);
}

/* ---------- Links (global) ---------- */

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.12s ease;
}

    a:hover {
        color: var(--accent-blue-hover);
    }

    a:focus-visible {
        outline: 2px solid var(--accent-green);
        outline-offset: 2px;
    }

/* ---------- Selection ---------- */

.terminal-body,
.terminal-body * {
    -webkit-user-select: text;
    user-select: text;
}

::selection {
    background: rgba(0, 255, 162, 0.25);
    color: var(--text-primary);
}


/* ---------- Scrollbar (shared) ---------- */

.terminal-body::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.modal-text::-webkit-scrollbar,
.preview-text-body::-webkit-scrollbar,
.preview-text::-webkit-scrollbar {
    width: 8px;
}

.terminal-body::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.modal-text::-webkit-scrollbar-track,
.preview-text-body::-webkit-scrollbar-track,
.preview-text::-webkit-scrollbar-track {
    background: transparent;
}

.terminal-body::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.modal-text::-webkit-scrollbar-thumb,
.preview-text-body::-webkit-scrollbar-thumb,
.preview-text::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.modal-text::-webkit-scrollbar-thumb:hover,
.preview-text-body::-webkit-scrollbar-thumb:hover,
.preview-text::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
    body {
        padding: 0.75rem 0.6rem;
        align-items: stretch;
    }

    .terminal-window {
        border-radius: 8px;
        max-width: 100%;
        max-height: calc(100vh - 1.5rem);
    }

    .title-bar {
        padding: 0.55rem 0.85rem;
    }

    .title {
        font-size: 0.72rem;
    }

    .terminal-body {
        padding: 1.1rem 1rem 1.2rem;
        font-size: 0.86rem;
    }

    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 0.98rem;
    }

    .file-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .file-actions {
        padding-left: 0.1rem;
    }

    .line {
        white-space: normal;
        word-break: break-word;
    }

    .input-line {
        flex-wrap: wrap;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }

    .preview-body img {
        max-height: 200px;
    }

    .modal {
        padding: 0.75rem;
    }

    .modal-window {
        max-height: calc(100vh - 1.5rem);
    }

    .modal-body {
        padding: 1rem;
    }

        .modal-body img {
            max-height: min(60vh, 400px);
        }
}

@media (max-width: 380px) {
    html {
        font-size: 14px;
    }

    .traffic-lights {
        gap: 5px;
    }

    .dot {
        width: 10px;
        height: 10px;
    }

    .title-spacer {
        width: 40px;
    }
}
