/* ============================================================================
   TERMINAL KIT :: w4ttz skin
   ----------------------------------------------------------------------------
   Retuned from the original green-on-black CRT theme to the roguelike's
   indigo void palette so the taskbar reads as another panel of the same site.

   Panel material is copied from the game's .alive-box rule:
     background  rgba(18, 11, 34, 0.7)
     border      1px rgba(157, 78, 221, 0.28)
     halo        cyan inner ring + wide cyan bloom + indigo falloff
     blur        backdrop-filter: blur(10px)

   Deliberately NOT ported: the game's outer frame / dome border. That is
   unique to the play page.
   ============================================================================ */

:root {
    /* Indigo void palette (mirrors roguelike/index.php) */
    --tk-bg-void: #0a0714;
    --tk-bg-deep: #120b22;
    --tk-bg-panel: #1a1030;
    --tk-bg-elevated: #221741;
    --tk-bg-input: #0d0820;

    --tk-purple-900: #2a1a4a;
    --tk-purple-700: #4c2a7a;
    --tk-purple-500: #7b3fa0;
    --tk-purple-400: #9d4edd;
    --tk-purple-300: #c77dff;
    --tk-purple-200: #e0aaff;

    --tk-holo-cyan: #00e5ff;
    --tk-holo-glow: #7df9ff;
    --tk-holo-soft: #a8f0ff;

    --tk-text: #e0aaff;
    --tk-text-bright: #f0d9ff;
    --tk-text-dim: #9d7ab8;
    --tk-text-faint: #5a4278;

    --tk-line: rgba(157, 78, 221, 0.28);
    --tk-panel-bg: rgba(18, 11, 34, 0.7);

    /* Legacy names kept so existing component rules still resolve */
    --tk-green: var(--tk-holo-cyan);
    --tk-green-dark: var(--tk-purple-500);
    --tk-green-darker: var(--tk-purple-700);
    --tk-green-darkest: var(--tk-purple-900);
    --tk-green-bg: rgba(0, 229, 255, 0.10);
    --tk-black: var(--tk-bg-void);
    --tk-gray-dark: var(--tk-bg-deep);
    --tk-gray: var(--tk-bg-panel);
    --tk-gray-light: var(--tk-bg-elevated);
    --tk-white: var(--tk-text-bright);
    --tk-red: #ff4d6d;
    --tk-yellow: #ffb347;
    --tk-green-btn: var(--tk-holo-glow);

    --tk-halo:
        0 0 2px rgba(0, 229, 255, 0.45),
        0 0 18px rgba(0, 229, 255, 0.16),
        0 0 42px rgba(0, 229, 255, 0.08),
        0 0 60px rgba(157, 78, 221, 0.14),
        inset 0 0 22px rgba(0, 229, 255, 0.07);
}

/* ============================================================================
   TASKBAR SHELL
   ============================================================================ */

#tk-taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 10px;
    background: var(--tk-panel-bg);
    border-top: 1px solid rgba(0, 229, 255, 0.32);
    box-shadow:
        0 -2px 14px rgba(0, 229, 255, 0.14),
        0 -1px 0 rgba(0, 229, 255, 0.22),
        inset 0 1px 0 rgba(0, 229, 255, 0.10);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9000;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 11px;
    color: var(--tk-text);
    transition: transform .28s cubic-bezier(.22, .61, .36, 1);
}

#tk-taskbar * {
    box-sizing: border-box;
}

/* Page content must clear the bar. --tk-h is used by the page wrappers. */
body {
    --tk-h: 38px;
}

.tk-taskbar-start,
.tk-taskbar-apps,
.tk-taskbar-systray {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.tk-taskbar-apps {
    flex: 1 1 auto;
    overflow: hidden;
}

.tk-taskbar-systray {
    flex: 0 0 auto;
    gap: 8px;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.tk-quick-launch-btn,
.tk-taskbar-app-button {
    font-family: inherit;
    font-size: 10px;
    letter-spacing: 0.1em;
    line-height: 1.5;
    color: var(--tk-text-dim);
    background: rgba(13, 8, 32, 0.72);
    border: 1px solid rgba(157, 78, 221, 0.34);
    border-radius: 5px;
    padding: 3px 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: color .18s ease, border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.tk-quick-launch-btn:hover,
.tk-taskbar-app-button:hover {
    color: var(--tk-holo-soft);
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.07);
}

.tk-quick-launch-btn:focus-visible,
.tk-taskbar-app-button:focus-visible,
#tk-music-btn:focus-visible,
.tk-mp-btn:focus-visible,
.tk-mp-action:focus-visible,
.tk-mp-url:focus-visible,
#tk-tab-handle:focus-visible {
    outline: 1px solid var(--tk-holo-cyan);
    outline-offset: 2px;
}

.tk-quick-launch-btn.active,
.tk-taskbar-app-button.active {
    color: var(--tk-holo-cyan);
    border-color: rgba(0, 229, 255, 0.65);
    background: rgba(0, 229, 255, 0.10);
    box-shadow: 0 0 9px rgba(0, 229, 255, 0.4), inset 0 0 8px rgba(0, 229, 255, 0.12);
}

/* Terminal launcher: >_ rendered from pseudo-elements */
#tk-terminal-quick-launch-btn {
    position: relative;
    width: 30px;
    height: 22px;
    padding: 0;
    background: rgba(13, 8, 32, 0.8);
    color: var(--tk-holo-cyan);
    border: 1px solid rgba(0, 229, 255, 0.45);
}

#tk-terminal-quick-launch-btn::before {
    content: '>';
    position: absolute;
    left: 7px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: var(--tk-holo-cyan);
    text-shadow: 0 0 6px rgba(0, 229, 255, 0.8);
}

#tk-terminal-quick-launch-btn::after {
    content: '';
    position: absolute;
    left: 17px;
    bottom: 7px;
    width: 7px;
    height: 2px;
    background: var(--tk-holo-cyan);
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.8);
    animation: tkBlink 1.1s steps(1) infinite;
}

@keyframes tkBlink {
    0%, 49%   { opacity: 1; }
    50%, 100% { opacity: .15; }
}

/* ============================================================================
   CLOCK
   ============================================================================ */

.tk-taskbar-time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
    padding-left: 10px;
    border-left: 1px solid rgba(157, 78, 221, 0.3);
}

#tk-current-time {
    color: var(--tk-holo-cyan);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

.tk-taskbar-time #tk-current-time {
    color: var(--tk-holo-cyan);
}

.tk-taskbar-time #tk-current-date {
    color: var(--tk-text-faint);
}

#tk-current-date {
    color: var(--tk-text-faint);
    font-size: 9px;
    letter-spacing: 0.06em;
}

/* ============================================================================
   MUSIC WIDGET
   ============================================================================ */

#tk-music-widget {
    position: relative;
    display: inline-flex;
    align-items: center;
}

#tk-music-btn {
    position: relative;
}

/* Playing indicator: a slow cyan pulse on the label */
#tk-music-btn.tk-playing {
    color: var(--tk-holo-cyan);
    border-color: rgba(0, 229, 255, 0.6);
    animation: tkMusicPulse 2.4s ease-in-out infinite;
}

@keyframes tkMusicPulse {
    0%, 100% { box-shadow: 0 0 6px rgba(0, 229, 255, 0.25); }
    50%      { box-shadow: 0 0 14px rgba(0, 229, 255, 0.6); }
}

/* ---------------------------------------------------------------------------
   The panel: expands up and outward from the button.
   --------------------------------------------------------------------------- */
#tk-music-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 236px;
    padding: 9px;
    display: flex;
    flex-direction: column;
    gap: 7px;

    background: var(--tk-panel-bg);
    border: 1px solid var(--tk-line);
    border-radius: 8px;
    box-shadow: var(--tk-halo);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    /* Collapsed by default. transform-origin keeps the growth anchored to the
       button so it appears to unfold upward/outward rather than fade in place. */
    transform-origin: bottom right;
    transform: translateY(6px) scale(0.94);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity .18s ease,
        transform .2s cubic-bezier(.22, .61, .36, 1),
        visibility 0s linear .2s;
    z-index: 9001;
}

#tk-music-panel.tk-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition:
        opacity .18s ease,
        transform .2s cubic-bezier(.22, .61, .36, 1),
        visibility 0s linear 0s;
}

.tk-mp-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(157, 78, 221, 0.22);
}

.tk-mp-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 9.5px;
    letter-spacing: 0.05em;
    color: var(--tk-purple-200);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tk-mp-expand {
    flex: 0 0 auto;
    font-family: inherit;
    font-size: 10px;
    color: var(--tk-text-dim);
    background: transparent;
    border: 1px solid rgba(157, 78, 221, 0.3);
    border-radius: 4px;
    padding: 1px 5px;
    cursor: pointer;
    transition: color .18s ease, border-color .18s ease;
}

.tk-mp-expand:hover {
    color: var(--tk-holo-cyan);
    border-color: rgba(0, 229, 255, 0.5);
}

.tk-mp-transport {
    display: flex;
    gap: 4px;
}

.tk-mp-btn {
    flex: 1 1 0;
    font-family: inherit;
    font-size: 10px;
    line-height: 1.6;
    text-align: center;
    color: var(--tk-text-dim);
    background: rgba(13, 8, 32, 0.72);
    border: 1px solid rgba(157, 78, 221, 0.34);
    border-radius: 4px;
    padding: 2px 0;
    cursor: pointer;
    transition: color .16s ease, border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.tk-mp-btn:hover {
    color: var(--tk-holo-soft);
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.07);
}

.tk-mp-play {
    flex: 1.4 1 0;
    color: var(--tk-holo-cyan);
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.08);
}

.tk-mp-off:hover {
    color: var(--tk-red);
    border-color: rgba(255, 77, 109, 0.6);
    background: rgba(255, 77, 109, 0.1);
}

.tk-mp-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

.tk-mp-label {
    flex: 0 0 auto;
    font-size: 9px;
    letter-spacing: 0.08em;
    color: var(--tk-text-faint);
    min-width: 34px;
}

#tk-mp-volume {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--tk-holo-cyan) 0%, var(--tk-purple-400) 100%);
    opacity: 0.55;
    cursor: pointer;
    transition: opacity .18s ease;
}

#tk-mp-volume:hover,
#tk-mp-volume:focus-visible {
    opacity: 1;
}

#tk-mp-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 9px;
    height: 13px;
    border-radius: 2px;
    background: var(--tk-holo-soft);
    border: 1px solid rgba(0, 229, 255, 0.85);
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.7);
}

#tk-mp-volume::-moz-range-thumb {
    width: 9px;
    height: 13px;
    border-radius: 2px;
    background: var(--tk-holo-soft);
    border: 1px solid rgba(0, 229, 255, 0.85);
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.7);
}

.tk-mp-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.tk-mp-action {
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 0.06em;
    line-height: 1.6;
    color: var(--tk-text-dim);
    text-decoration: none;
    background: rgba(13, 8, 32, 0.72);
    border: 1px solid rgba(157, 78, 221, 0.34);
    border-radius: 4px;
    padding: 2px 7px;
    cursor: pointer;
    white-space: nowrap;
    transition: color .16s ease, border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.tk-mp-action:hover {
    color: var(--tk-holo-soft);
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.07);
}

/* co0k? is the one call-to-action in the panel */
.tk-mp-cook {
    color: var(--tk-purple-200);
    border-color: rgba(199, 125, 255, 0.55);
    background: rgba(157, 78, 221, 0.14);
}

.tk-mp-cook:hover {
    color: var(--tk-text-bright);
    border-color: rgba(199, 125, 255, 0.9);
    background: rgba(157, 78, 221, 0.28);
    box-shadow: 0 0 10px rgba(157, 78, 221, 0.45);
}

.tk-mp-import {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.tk-mp-url {
    display: none;
    flex: 1 1 auto;
    min-width: 0;
    font-family: inherit;
    font-size: 9px;
    color: var(--tk-text-bright);
    background: var(--tk-bg-input);
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-radius: 4px;
    padding: 2px 5px;
}

.tk-mp-url.tk-show {
    display: block;
}

.tk-mp-url::placeholder {
    color: var(--tk-text-faint);
}

/* ============================================================================
   MOBILE: bottom sheet drawer
   ----------------------------------------------------------------------------
   The bar slides up from the bottom edge. A grab handle stays visible; the
   drawer itself is off-canvas until opened. The "imp0rtunez fr0m *" control is
   never built on mobile (see taskbar.js), so it needs no rule here.
   ============================================================================ */

#tk-tab-handle {
    display: none;
}

@media (max-width: 1023px), (pointer: coarse) {
    #tk-tab-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        left: 50%;
        bottom: 0;
        transform: translateX(-50%);
        width: 66px;
        height: 20px;
        padding: 0;
        margin: 0;
        background: var(--tk-panel-bg);
        border: 1px solid rgba(0, 229, 255, 0.32);
        border-bottom: none;
        border-radius: 10px 10px 0 0;
        box-shadow: 0 -2px 12px rgba(0, 229, 255, 0.22);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 8999;
        cursor: pointer;
        transition: transform .28s cubic-bezier(.22, .61, .36, 1), box-shadow .2s ease;
    }

    #tk-tab-handle span {
        display: block;
        width: 26px;
        height: 3px;
        border-radius: 2px;
        background: var(--tk-purple-300);
        box-shadow: 0 0 8px rgba(199, 125, 255, 0.8);
        opacity: .8;
    }

    /* When the drawer is open the handle rides up with it so it stays a
       target for closing. */
    body.tk-drawer-open #tk-tab-handle {
        transform: translateX(-50%) translateY(calc(-100% - 38px));
    }

    #tk-taskbar {
        height: auto;
        min-height: 44px;
        padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
        gap: 6px;
        flex-wrap: wrap;
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
        /* Off-canvas by default */
        transform: translateY(calc(100% + 2px));
        box-shadow: 0 -4px 20px rgba(0, 229, 255, 0.18);
    }

    #tk-taskbar.tk-open {
        transform: translateY(0);
    }

    /* Stacked layout: transport row, then the music widget full width */
    .tk-taskbar-systray {
        flex: 1 1 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .tk-taskbar-apps {
        display: none;
    }

    #tk-music-btn {
        font-size: 11px;
        padding: 5px 10px;
    }

    /* On touch the panel opens upward but must stay inside the viewport.
       Anchoring to the widget's LEFT edge (not right) is what keeps it on
       screen: the widget sits at the left of the systray, so right-aligning
       would push a 280px panel off the left side of a 390px phone. */
    #tk-music-panel {
        left: 0;
        right: auto;
        width: min(280px, calc(100vw - 24px));
        bottom: calc(100% + 10px);
    }

    .tk-taskbar-time {
        padding-left: 8px;
    }

    #tk-current-date {
        display: none;
    }
}

/* Very small screens: keep the clock legible, drop seconds */
@media (max-width: 380px) {
    #tk-current-time {
        font-size: 9.5px;
    }
    .tk-mp-cook,
    .tk-mp-action {
        font-size: 8.5px;
    }
}

/* ============================================================================
   WINDOWS (terminal + music player)
   ============================================================================ */

.tk-window {
    position: fixed;
    min-width: 280px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--tk-line);
    border-radius: 8px;
    background: var(--tk-panel-bg);
    box-shadow: var(--tk-halo);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    font-family: 'Fira Code', 'Courier New', monospace;
    z-index: 9999;
}

.tk-window.tk-hidden {
    display: none;
}

.tk-window-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 8px;
    background: rgba(13, 8, 32, 0.9);
    color: var(--tk-holo-cyan);
    border-bottom: 1px solid rgba(0, 229, 255, 0.28);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
    cursor: move;
    user-select: none;
}

.tk-window-title-bar:active {
    cursor: grabbing;
}

.tk-window-controls {
    display: flex;
    gap: 5px;
    cursor: default;
}

.tk-window-btn {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: .85;
    transition: opacity .16s ease, box-shadow .16s ease;
}

.tk-window-btn:hover {
    opacity: 1;
    box-shadow: 0 0 8px currentColor;
}

.tk-window-btn.close { background: var(--tk-red); }
.tk-window-btn.minimize { background: var(--tk-yellow); }
.tk-window-btn.maximize { background: var(--tk-green-btn); }
.tk-window-btn.playlist-toggle { background: var(--tk-purple-400); }

.tk-window-content {
    flex: 1 1 auto;
    overflow: auto;
    padding: 8px;
    color: var(--tk-text);
}

/* ============================================================================
   SCROLLBARS
   ============================================================================ */

.tk-window-content::-webkit-scrollbar,
.tk-terminal-body::-webkit-scrollbar,
.tk-player-playlist::-webkit-scrollbar {
    width: 8px;
}

.tk-window-content::-webkit-scrollbar-track,
.tk-terminal-body::-webkit-scrollbar-track,
.tk-player-playlist::-webkit-scrollbar-track {
    background: rgba(13, 8, 32, 0.8);
}

.tk-window-content::-webkit-scrollbar-thumb,
.tk-terminal-body::-webkit-scrollbar-thumb,
.tk-player-playlist::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--tk-purple-700), var(--tk-holo-cyan));
    border-radius: 4px;
}

.tk-window-content::-webkit-scrollbar-thumb:hover,
.tk-terminal-body::-webkit-scrollbar-thumb:hover,
.tk-player-playlist::-webkit-scrollbar-thumb:hover {
    background: var(--tk-holo-cyan);
}

/* ============================================================================
   RESIZE HANDLES
   ============================================================================ */

.tk-resize-handle { position: absolute; }
.tk-resize-handle-n { top: -5px; left: 10px; right: 10px; height: 10px; cursor: ns-resize; }
.tk-resize-handle-s { bottom: -5px; left: 10px; right: 10px; height: 10px; cursor: ns-resize; }
.tk-resize-handle-e { right: -5px; top: 10px; bottom: 10px; width: 10px; cursor: ew-resize; }
.tk-resize-handle-w { left: -5px; top: 10px; bottom: 10px; width: 10px; cursor: ew-resize; }
.tk-resize-handle-ne { top: -5px; right: -5px; width: 15px; height: 15px; cursor: nesw-resize; }
.tk-resize-handle-nw { top: -5px; left: -5px; width: 15px; height: 15px; cursor: nwse-resize; }
.tk-resize-handle-se { bottom: -5px; right: -5px; width: 15px; height: 15px; cursor: nwse-resize; }
.tk-resize-handle-sw { bottom: -5px; left: -5px; width: 15px; height: 15px; cursor: nesw-resize; }

/* ============================================================================
   TERMINAL
   ============================================================================ */

.tk-terminal {
    background: rgba(10, 7, 20, 0.92);
    border: 1px solid rgba(0, 229, 255, 0.3);
}

.tk-terminal:focus,
.tk-terminal *:focus {
    outline: none;
}

.tk-terminal .tk-window-title-bar {
    background: rgba(13, 8, 32, 0.92);
    color: var(--tk-holo-cyan);
    border-bottom: 1px solid rgba(0, 229, 255, 0.22);
}

.tk-terminal-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 8px;
    background: transparent;
    color: var(--tk-holo-glow);
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.tk-terminal-body:focus {
    outline: none;
}

.tk-terminal-inner {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tk-terminal-input-line {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.tk-terminal-prompt,
.tk-terminal-frozen-prompt {
    color: var(--tk-holo-cyan);
    text-shadow: 0 0 6px rgba(0, 229, 255, 0.55);
}

.tk-terminal-input {
    flex: 1 1 auto;
    background: transparent;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: inherit;
    color: var(--tk-holo-glow);
    caret-color: var(--tk-holo-cyan);
}

.tk-terminal-command-history {
    color: var(--tk-text-dim);
}

.tk-terminal-output {
    white-space: pre-wrap;
    word-break: break-word;
}

.tk-terminal-output.tk-tab-completion {
    color: var(--tk-purple-300);
}

.tk-terminal-frozen-line {
    white-space: pre-wrap;
    word-break: break-word;
}

.tk-terminal-frozen-prompt {
    color: var(--tk-purple-300);
}

.tk-terminal-title {
    color: var(--tk-holo-cyan);
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.tk-terminal-input.tk-password {
    -webkit-text-security: disc;
    text-security: disc;
}

.tk-terminal-output a {
    color: var(--tk-purple-200);
}

/* ============================================================================
   MUSIC PLAYER WINDOW
   ============================================================================ */

.tk-music-player {
    width: 320px;
}

.tk-player-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tk-player-display {
    background: rgba(10, 7, 20, 0.85);
    border: 1px solid rgba(157, 78, 221, 0.3);
    border-radius: 5px;
    padding: 7px;
}

.tk-player-song-title {
    color: var(--tk-purple-200);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tk-player-song-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tk-player-control-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tk-player-seek-bar::-moz-range-thumb {
    width: 9px;
    height: 13px;
    border-radius: 2px;
    background: var(--tk-holo-soft);
    border: 1px solid rgba(0, 229, 255, 0.85);
}

.tk-player-time {
    color: var(--tk-text-faint);
    font-size: 9.5px;
}

.tk-player-visualizer {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 40px;
    padding: 4px;
    background: rgba(10, 7, 20, 0.9);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 5px;
}

.tk-visualizer-bar {
    flex: 1 1 0;
    height: 0;
    border-radius: 1px 1px 0 0;
    background: linear-gradient(180deg, var(--tk-holo-cyan), var(--tk-purple-500));
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
    transition: height .09s linear;
}

.tk-player-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tk-player-button {
    font-family: inherit;
    font-size: 10px;
    color: var(--tk-text-dim);
    background: rgba(13, 8, 32, 0.72);
    border: 1px solid rgba(157, 78, 221, 0.34);
    border-radius: 4px;
    padding: 3px 7px;
    cursor: pointer;
    transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}

.tk-player-button:hover {
    color: var(--tk-holo-soft);
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.07);
}

.tk-player-button.active {
    color: var(--tk-holo-cyan);
    border-color: rgba(0, 229, 255, 0.6);
    background: rgba(0, 229, 255, 0.1);
}

.tk-player-button:active {
    background: rgba(0, 229, 255, 0.18);
}

.tk-music-player .tk-window-title-bar {
    color: var(--tk-purple-200);
    border-bottom-color: rgba(157, 78, 221, 0.4);
    text-shadow: 0 0 8px rgba(157, 78, 221, 0.6);
}

.tk-player-seek-bar {
    flex: 1 1 auto;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--tk-holo-cyan), var(--tk-purple-400));
    opacity: .6;
    cursor: pointer;
}

.tk-player-seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 9px;
    height: 13px;
    border-radius: 2px;
    background: var(--tk-holo-soft);
    border: 1px solid rgba(0, 229, 255, 0.85);
}

.tk-player-playlist {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid rgba(157, 78, 221, 0.26);
    border-radius: 5px;
    background: rgba(10, 7, 20, 0.75);
}

.tk-playlist-item {
    padding: 4px 7px;
    font-size: 10px;
    color: var(--tk-text-dim);
    cursor: pointer;
    border-bottom: 1px solid rgba(157, 78, 221, 0.12);
    transition: color .14s ease, background-color .14s ease;
}

.tk-playlist-item:hover {
    color: var(--tk-holo-soft);
    background: rgba(0, 229, 255, 0.06);
}

.tk-playlist-item.active {
    color: var(--tk-holo-cyan);
    background: rgba(0, 229, 255, 0.09);
    text-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
}

/* ============================================================================
   MATRIX RAIN
   ============================================================================ */

#matrixRain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

/* Load-bearing: the mobile terminal overlay and playlist rely on this. */
.tk-hidden {
    display: none !important;
}

.tk-dragging {
    cursor: grabbing !important;
    user-select: none !important;
}

.tk-no-select {
    user-select: none !important;
    -webkit-user-select: none !important;
}

#tk-terminal:focus,
#tk-terminal *:focus,
#tk-music-player:focus,
#tk-music-player *:focus,
#tk-taskbar:focus,
#tk-taskbar *:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* The taskbar's own controls opt back in to a visible focus ring for keyboard
   users; the blanket rule above is only there to kill the window chrome glow. */
#tk-music-btn:focus-visible,
#tk-terminal-quick-launch-btn:focus-visible,
.tk-mp-btn:focus-visible,
.tk-mp-action:focus-visible,
#tk-mp-volume:focus-visible,
#tk-tab-handle:focus-visible {
    outline: 1px solid var(--tk-holo-cyan) !important;
    outline-offset: 2px;
}

/* ============================================================================
   MOBILE TERMINAL OVERLAY
   ----------------------------------------------------------------------------
   terminal.js swaps to this full-screen overlay when innerWidth <= 768. It is
   a separate element from .tk-terminal, so it needs its own rules.
   ============================================================================ */

.tk-mobile-terminal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background-color: rgba(10, 7, 20, 0.97);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
    overflow: hidden;
}

.tk-mobile-terminal-overlay.tk-hidden {
    display: none !important;
}

.tk-mobile-terminal {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    font-family: 'Fira Code', 'Courier New', monospace;
    background-color: var(--tk-bg-void);
    color: var(--tk-holo-glow);
}

.tk-mobile-terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background-color: rgba(13, 8, 32, 0.95);
    border-bottom: 1px solid rgba(0, 229, 255, 0.3);
    flex-shrink: 0;
}

.tk-mobile-terminal-title {
    font-size: 15px;
    font-weight: bold;
    color: var(--tk-holo-cyan);
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.7);
}

.tk-mobile-terminal-close {
    background: transparent;
    border: 1px solid rgba(0, 229, 255, 0.5);
    color: var(--tk-holo-cyan);
    font-size: 20px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.tk-mobile-terminal-close:active {
    background: var(--tk-holo-cyan);
    color: var(--tk-bg-void);
}

.tk-mobile-terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
    font-size: 13px;
    line-height: 1.45;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.tk-mobile-line {
    margin-bottom: 2px;
    word-wrap: break-word;
    white-space: pre-wrap;
    color: var(--tk-holo-glow);
}

.tk-mobile-prompt-line {
    color: var(--tk-purple-200);
}

.tk-mobile-terminal-input-area {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: rgba(13, 8, 32, 0.95);
    border-top: 1px solid rgba(157, 78, 221, 0.3);
    flex-shrink: 0;
}

.tk-mobile-terminal-prompt {
    color: var(--tk-holo-cyan);
    font-size: 13px;
    white-space: nowrap;
    margin-right: 5px;
}

.tk-mobile-terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--tk-holo-glow);
    font-family: inherit;
    font-size: 16px;              /* 16px stops iOS auto-zoom on focus */
    caret-color: var(--tk-holo-cyan);
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

.tk-mobile-terminal-input::placeholder {
    color: var(--tk-text-faint);
}

.tk-mobile-terminal input,
.tk-mobile-terminal textarea {
    font-size: 16px !important;
}

.tk-mobile-terminal-controls {
    display: flex;
    justify-content: space-around;
    padding: 12px 15px;
    background-color: rgba(10, 7, 20, 0.98);
    border-top: 1px solid rgba(157, 78, 221, 0.3);
    flex-shrink: 0;
    gap: 10px;
}

.tk-mobile-ctrl-btn {
    background: rgba(26, 16, 48, 0.9);
    border: 1px solid rgba(157, 78, 221, 0.5);
    color: var(--tk-holo-glow);
    padding: 12px 20px;
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    border-radius: 4px;
    flex: 1;
    max-width: 80px;
    text-align: center;
}

.tk-mobile-ctrl-btn:active {
    background: var(--tk-holo-cyan);
    color: var(--tk-bg-void);
}

.tk-mobile-ctrl-c {
    background: rgba(60, 10, 20, 0.9);
    border-color: rgba(255, 77, 109, 0.55);
    color: var(--tk-red);
}

.tk-mobile-ctrl-c:active {
    background: var(--tk-red);
    color: var(--tk-bg-void);
}

.tk-mobile-terminal-output::-webkit-scrollbar {
    width: 6px;
}

.tk-mobile-terminal-output::-webkit-scrollbar-track {
    background: rgba(13, 8, 32, 0.9);
}

.tk-mobile-terminal-output::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--tk-purple-700), var(--tk-holo-cyan));
    border-radius: 3px;
}

@supports (padding: env(safe-area-inset-top)) {
    .tk-mobile-terminal-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
    .tk-mobile-terminal-controls {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    #tk-tab-handle {
        bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    #tk-taskbar,
    #tk-tab-handle,
    #tk-music-panel {
        transition: none;
    }
    #tk-terminal-quick-launch-btn::after,
    #tk-music-btn.tk-playing {
        animation: none;
    }
}

/* ============================================================================
   HOST-PAGE ISOLATION
   ----------------------------------------------------------------------------
   Some pages (DownGit, paste, ducky_gen) style bare `button` / `a` / `input`
   with !important padding, margin, height and font-size. Those rules leaked
   into the taskbar and the music panel and blew the layout apart. Everything
   below is scoped under #tk-taskbar (ID specificity) and uses !important so a
   host page cannot resize the widget.
   ============================================================================ */

#tk-taskbar button,
#tk-taskbar input,
#tk-taskbar a {
    margin: 0 !important;
    min-width: 0 !important;
    height: auto !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    letter-spacing: normal;
    text-transform: none !important;
    text-shadow: none !important;
    float: none !important;
}

#tk-taskbar .tk-quick-launch-btn,
#tk-taskbar .tk-taskbar-app-button {
    padding: 3px 8px !important;
    font-size: 10px !important;
    line-height: 1.5 !important;
    letter-spacing: 0.1em !important;
    color: var(--tk-text-dim) !important;
    background: rgba(13, 8, 32, 0.72) !important;
    border: 1px solid rgba(157, 78, 221, 0.34) !important;
    border-radius: 5px !important;
    box-shadow: none !important;
}

#tk-taskbar .tk-quick-launch-btn:hover,
#tk-taskbar .tk-taskbar-app-button:hover {
    color: var(--tk-holo-soft) !important;
    border-color: rgba(0, 229, 255, 0.5) !important;
    background: rgba(0, 229, 255, 0.07) !important;
}

#tk-taskbar .tk-quick-launch-btn.active,
#tk-taskbar .tk-taskbar-app-button.active {
    color: var(--tk-holo-cyan) !important;
    border-color: rgba(0, 229, 255, 0.65) !important;
    background: rgba(0, 229, 255, 0.10) !important;
    box-shadow: 0 0 9px rgba(0, 229, 255, 0.4), inset 0 0 8px rgba(0, 229, 255, 0.12) !important;
}

#tk-taskbar #tk-music-btn {
    padding: 3px 8px !important;
    font-size: 10px !important;
    line-height: 1.5 !important;
    letter-spacing: 0.1em !important;
    color: var(--tk-text-dim) !important;
    background: rgba(13, 8, 32, 0.72) !important;
    border: 1px solid rgba(157, 78, 221, 0.34) !important;
    border-radius: 5px !important;
    box-shadow: none !important;
}

#tk-taskbar #tk-music-btn:hover {
    color: var(--tk-holo-soft) !important;
    border-color: rgba(0, 229, 255, 0.5) !important;
    background: rgba(0, 229, 255, 0.07) !important;
}

#tk-taskbar #tk-music-btn.tk-playing {
    color: var(--tk-holo-cyan) !important;
    border-color: rgba(0, 229, 255, 0.6) !important;
}

/* --- The panel ----------------------------------------------------------- */

#tk-taskbar #tk-music-panel,
#tk-taskbar #tk-music-panel * {
    box-sizing: border-box !important;
}

#tk-taskbar #tk-music-panel {
    max-width: calc(100vw - 16px);
    overflow: hidden;
}

#tk-taskbar #tk-music-panel .tk-mp-header,
#tk-taskbar #tk-music-panel .tk-mp-transport,
#tk-taskbar #tk-music-panel .tk-mp-row,
#tk-taskbar #tk-music-panel .tk-mp-actions {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

#tk-taskbar #tk-music-panel .tk-mp-expand {
    padding: 1px 5px !important;
    font-size: 10px !important;
    line-height: 1.5 !important;
    color: var(--tk-text-dim) !important;
    background: transparent !important;
    border: 1px solid rgba(157, 78, 221, 0.3) !important;
    border-radius: 4px !important;
    box-shadow: none !important;
}

#tk-taskbar #tk-music-panel .tk-mp-expand:hover {
    color: var(--tk-holo-cyan) !important;
    border-color: rgba(0, 229, 255, 0.5) !important;
    background: transparent !important;
}

#tk-taskbar #tk-music-panel .tk-mp-btn {
    flex: 1 1 0 !important;
    padding: 2px 0 !important;
    font-size: 10px !important;
    line-height: 1.6 !important;
    letter-spacing: normal !important;
    text-align: center;
    color: var(--tk-text-dim) !important;
    background: rgba(13, 8, 32, 0.72) !important;
    border: 1px solid rgba(157, 78, 221, 0.34) !important;
    border-radius: 4px !important;
    box-shadow: none !important;
}

#tk-taskbar #tk-music-panel .tk-mp-btn:hover {
    color: var(--tk-holo-soft) !important;
    border-color: rgba(0, 229, 255, 0.5) !important;
    background: rgba(0, 229, 255, 0.07) !important;
}

#tk-taskbar #tk-music-panel .tk-mp-play {
    flex: 1.4 1 0 !important;
    color: var(--tk-holo-cyan) !important;
    border-color: rgba(0, 229, 255, 0.5) !important;
    background: rgba(0, 229, 255, 0.08) !important;
}

#tk-taskbar #tk-music-panel .tk-mp-off:hover {
    color: var(--tk-red) !important;
    border-color: rgba(255, 77, 109, 0.6) !important;
    background: rgba(255, 77, 109, 0.1) !important;
}

#tk-taskbar #tk-music-panel .tk-mp-action {
    padding: 2px 7px !important;
    font-size: 9px !important;
    line-height: 1.6 !important;
    letter-spacing: 0.06em !important;
    color: var(--tk-text-dim) !important;
    background: rgba(13, 8, 32, 0.72) !important;
    border: 1px solid rgba(157, 78, 221, 0.34) !important;
    border-radius: 4px !important;
    text-decoration: none !important;
    box-shadow: none !important;
}

#tk-taskbar #tk-music-panel .tk-mp-action:hover {
    color: var(--tk-holo-soft) !important;
    border-color: rgba(0, 229, 255, 0.5) !important;
    background: rgba(0, 229, 255, 0.07) !important;
    text-decoration: none !important;
}

#tk-taskbar #tk-music-panel .tk-mp-cook {
    color: var(--tk-purple-200) !important;
    border-color: rgba(199, 125, 255, 0.55) !important;
    background: rgba(157, 78, 221, 0.14) !important;
}

#tk-taskbar #tk-music-panel .tk-mp-cook:hover {
    color: var(--tk-text-bright) !important;
    border-color: rgba(199, 125, 255, 0.9) !important;
    background: rgba(157, 78, 221, 0.28) !important;
    box-shadow: 0 0 10px rgba(157, 78, 221, 0.45) !important;
}

/* The import control gets its own full-width line instead of squeezing
   next to co0k?. */
#tk-taskbar #tk-music-panel .tk-mp-import {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
}

#tk-taskbar #tk-music-panel .tk-mp-url {
    padding: 2px 5px !important;
    font-size: 9px !important;
    line-height: 1.5 !important;
    color: var(--tk-text-bright) !important;
    background: var(--tk-bg-input) !important;
    border: 1px solid rgba(0, 229, 255, 0.35) !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    width: auto !important;
}

#tk-taskbar #tk-music-panel #tk-mp-volume {
    height: 4px !important;
    padding: 0 !important;
    border: 0 !important;
    background: linear-gradient(90deg, var(--tk-holo-cyan) 0%, var(--tk-purple-400) 100%) !important;
    box-shadow: none !important;
    width: auto !important;
}

@media (max-width: 1023px), (pointer: coarse) {
    #tk-taskbar #tk-music-btn {
        font-size: 11px !important;
        padding: 5px 10px !important;
    }
}
