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

:root {
    --bg: #1a1a2e;
    --terminal-bg: #1c1c1c;
    --terminal-fg: #ffffff;
    --terminal-titlebar: #3d3d3d;
    --terminal-border: #4a4a4a;
    --prompt-user: #28c941;
    --prompt-path: #5ac8fa;
    --prompt-symbol: #ffffff;
    --timestamp: #8e8e93;
    --accent: #ffffff;
    --link: #5ac8fa;
    --text-muted: rgba(255, 255, 255, 0.5);
    --btn-close: #ff5f57;
    --btn-minimize: #febc2e;
    --btn-maximize: #28c840;
    --terminal-shadow: 0 25px 80px rgba(0, 0, 0, 0.35),
                       0 8px 30px rgba(0, 0, 0, 0.2);
    --terminal-radius: 10px;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-title: 'Space Mono', monospace;
}

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

body {
    background: var(--bg) url('bg.jpg') center center / cover no-repeat fixed;
    color: #333;
    font-family: var(--font-mono);
    min-height: 100vh;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 1.5rem;
}

/* --- Header --- */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2rem 0 1.5rem;
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
}

.site-title {
    font-family: var(--font-title);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: rgba(255, 255, 255, 0.85);
}

.site-title .dot {
    color: var(--accent);
}


/* --- Terminal --- */

.terminal-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0 3rem;
    position: relative;
}

.terminal {
    width: 820px;
    max-width: 90vw;
    min-width: 320px;
    min-height: 200px;
    height: 70vh;
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: var(--terminal-radius);
    overflow: hidden;
    box-shadow: var(--terminal-shadow);
    border: 1px solid rgba(255, 255, 255, 0.12);
    animation: terminalAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1) both forwards;
}

@keyframes terminalAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.terminal-titlebar {
    background: var(--terminal-titlebar);
    padding: 0 1rem;
    height: 38px;
    display: flex;
    align-items: center;
    user-select: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
}

.terminal-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

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

.btn-close { background: var(--btn-close); cursor: pointer; }
.btn-minimize { background: var(--btn-minimize); cursor: pointer; }
.btn-maximize { background: var(--btn-maximize); }

.terminal-title {
    flex: 1;
    text-align: center;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-mono);
}

.terminal-titlebar-spacer {
    width: 52px;
    flex-shrink: 0;
}

.terminal-body {
    background: var(--terminal-bg);
    padding: 1.25rem 1.5rem 1.5rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.terminal-body::-webkit-scrollbar {
    width: 6px;
}

.terminal-body::-webkit-scrollbar-track {
    background: transparent;
}

.terminal-body::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    z-index: 10;
}

.resize-tl { top: 0; left: 0; cursor: nwse-resize; }
.resize-tr { top: 0; right: 0; cursor: nesw-resize; }
.resize-bl { bottom: 0; left: 0; cursor: nesw-resize; }
.resize-br { bottom: 0; right: 0; cursor: nwse-resize; }
.resize-t { top: 0; left: 16px; right: 16px; width: auto; height: 6px; cursor: ns-resize; }
.resize-b { bottom: 0; left: 16px; right: 16px; width: auto; height: 6px; cursor: ns-resize; }
.resize-l { top: 16px; left: 0; bottom: 16px; height: auto; width: 6px; cursor: ew-resize; }
.resize-r { top: 16px; right: 0; bottom: 16px; height: auto; width: 6px; cursor: ew-resize; }

/* --- Posts --- */

.post {
    margin-bottom: 1.5rem;
    animation: postFadeIn 0.4s ease both;
}

.post:last-child {
    margin-bottom: 0;
}

@keyframes postFadeIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.post-prompt {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0;
    line-height: 1.6;
    font-size: 0.9rem;
}

.prompt-user {
    color: var(--prompt-user);
    font-weight: 500;
}

.prompt-at {
    color: var(--timestamp);
}

.prompt-host {
    color: var(--prompt-path);
    font-weight: 500;
}

.prompt-colon {
    color: var(--terminal-fg);
}

.prompt-path {
    color: var(--prompt-path);
    font-weight: 500;
}

.prompt-symbol {
    color: var(--prompt-symbol);
    margin-right: 0.5em;
}

.prompt-cmd {
    color: var(--accent);
    font-weight: 700;
}

.prompt-date {
    color: var(--timestamp);
    font-size: 0.75rem;
    margin-left: 0.5em;
}

.post-body {
    color: var(--terminal-fg);
    line-height: 1.7;
    font-size: 0.85rem;
    padding-left: 0;
    margin-top: 0.25rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.post-body a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: rgba(137, 180, 250, 0.3);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.2s;
}

.post-body a:hover {
    text-decoration-color: var(--link);
}

.post-separator {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
}

/* --- Images --- */

.post-images {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.post-thumb {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s;
    object-fit: cover;
}

.post-thumb:hover {
    opacity: 1;
}

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

/* --- Minimize --- */

.terminal-minimizing {
    animation: minimizeGenie 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}

.terminal-restoring {
    animation: restoreGenie 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.terminal-minimized {
    transform: scale(0.05) translateY(80vh) !important;
    opacity: 0 !important;
    pointer-events: none;
    animation: none !important;
}

@keyframes minimizeGenie {
    0% { transform: scale(1) translateY(0); opacity: 1; }
    100% { transform: scale(0.05) translateY(80vh); opacity: 0; }
}

@keyframes restoreGenie {
    0% { transform: scale(0.05) translateY(80vh); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* --- Dock --- */

.dock {
    position: fixed;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.dock-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: transform 0.2s ease;
}

.dock-item::after {
    content: none;
}

.dock-item img {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    object-fit: contain;
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.2s;
    cursor: default;
}

a.dock-item,
a.dock-item img {
    cursor: pointer !important;
}

a.dock-item {
    text-decoration: none;
}

.dock-item:hover img {
    transform: translateY(-4px) scale(1.15);
    opacity: 1;
}

.dock-active img {
    opacity: 1 !important;
    cursor: pointer;
}

.dock-active:hover img {
    opacity: 1 !important;
}

.dock-indicator {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

.dock-placeholder {
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.dock-separator {
    width: 1px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
    align-self: center;
}

/* --- Loading --- */

.terminal-loading {
    color: var(--timestamp);
    font-size: 0.85rem;
}

.cursor-blink {
    animation: blink 1s step-end infinite;
    color: var(--terminal-fg);
}

@keyframes blink {
    50% { opacity: 0; }
}

/* --- Footer --- */

.site-footer {
    position: fixed;
    bottom: 0.75rem;
    right: 1rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
}

/* --- Responsive --- */

@media (max-width: 640px) {
    html {
        font-size: 12px;
    }

    .page {
        padding: 0;
    }

    .site-header {
        padding: 1rem 1rem 0.5rem;
    }

    .site-title {
        font-size: 1rem;
    }

    .terminal-wrap {
        padding: 0.5rem;
    }

    .terminal {
        width: 100% !important;
        height: 50vh !important;
        max-width: 100%;
        border-radius: 12px;
        position: static !important;
    }

    .terminal-body {
        padding: 0.75rem;
    }

    .terminal-titlebar {
        height: 32px;
        padding: 0 0.75rem;
    }

    .terminal-title {
        font-size: 0.7rem;
    }

    .terminal-buttons span {
        width: 10px;
        height: 10px;
    }

    .resize-handle {
        display: none;
    }

    /* Dock → iOS home screen */
    .dock {
        position: static;
        transform: none;
        padding: 1rem 0;
    }

    .dock-container {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 16px 0;
        padding: 0 1rem;
        background: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
        border-radius: 0;
        justify-items: center;
    }

    .dock-item {
        gap: 4px;
    }

    .dock-item::after {
        content: attr(data-label);
        font-size: 0.65rem;
        color: rgba(255, 255, 255, 0.7);
        text-align: center;
        white-space: nowrap;
    }

    .dock-item img {
        width: 56px;
        height: 56px;
        border-radius: 13px;
    }

    .dock-item:hover img {
        transform: none;
    }

    .dock-separator {
        display: none;
    }

    .dock-indicator {
        display: none;
    }

    .dock-placeholder {
        width: 56px;
        height: 56px;
    }

    .post-thumb {
        max-width: 150px;
        max-height: 120px;
    }

    .post-prompt {
        font-size: 0.8rem;
    }

    .post-body {
        font-size: 0.78rem;
    }

    /* Minimize на мобиле — просто скрыть/показать */
    .terminal-minimized {
        transform: scale(0) !important;
        opacity: 0 !important;
    }
}
