/*
 * CSS NAMING CONVENTIONS
 * 
 * 1. Module-prefix pattern: .module-element or #module-element
 *    - Example: .scroll-loading, .scroll-spinner, #scroll-trigger
 *    - Avoid generic names like .loading-indicator or .spinner
 * 
 * 2. CSS Custom Properties (Variables)
 *    - All colors and reusable values in :root
 *    - Example: --color-primary, --color-bg, --max-width
 * 
 * 3. Naming style: kebab-case only (no camelCase or snake_case)
 * 
 * 4. Semantic naming: reflect purpose and module ownership
 *    - Good: .scroll-loading, .post-header, .ticker-track
 *    - Bad: .blue-box, .big-text, .container-1
 */

/*@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');*/

@font-face {
  font-family: 'PxPlusVGA';
  src: url('fonts/Web437_IBM_VGA_8x16.woff') format('woff2');
  font-weight: normal;
  font-style: normal;
}

:root {
    --color-bg: #000000;
    --color-bg-alt: #001a1a;
    --color-primary: #00FFFF;
    --color-accent: #FFFF00;
    --color-positive: #00FF00;
    --color-negative: #FF0000;
    --color-hover: #FF00FF;
    --color-accent-glow: rgba(255, 255, 0, 0.3);
    --max-width: 80%;

    --copperbar-h: 56px;
    --command-prompt-h: 56px;
}

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

body {
    background-color: var(--color-bg);
    color: var(--color-primary);
    font-family: 'PxPlusVGA', monospace;
    font-size: 16px;
    line-height: 32px;
    /* padding: 20px; */
    overflow-x: hidden;

    width: 100%;
    height: 100%;
    margin: 0;
    
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
}

header {
    text-align: center;
    margin: 0 auto 40px;    
    margin-top: 80px;
    /* max-width: var(--max-width); */
    border: 2px solid var(--color-primary);
    padding: 20px;
    background-color: #000000;
}

header h1 {
    color: var(--color-accent);
    font-size: 40px;
    margin-bottom: 10px;
    text-shadow: 2px 2px var(--color-primary);
}

header p {
    color: var(--color-primary);
    font-size: 20px;
}

header .header-tagline-box {
    color: var(--color-primary);
    padding: 15px;
    margin: 15px auto;
    text-align: center;
    /* max-width: var(--max-width); */
    font-size: 16px;    
}

header .header-tagline-box p {
    margin: 0;
}

header .header-tagline-box p:not(:last-child) {
    margin-bottom: 5px;
}

main {
    /* max-width: var(--max-width); */
    margin: 0 auto;
}

article {
    border: 2px solid var(--color-primary);
    padding: 15px;
    margin-bottom: 20px;
    background-color: var(--color-bg-alt);
}

article:hover {
    border-color: var(--color-accent);
    box-shadow: 0 0 10px var(--color-accent-glow);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-primary);
}

.post-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.post-author {
    color: var(--color-accent);
    font-weight: bold;
}

.post-timestamp {
    color: var(--color-primary);
    font-size: 20px;
}

.post-content {
    color: var(--color-primary);
    margin-bottom: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.post-content p {
    margin-bottom: 10px;
}

.post-content a {
    color: var(--color-accent);
    text-decoration: underline;
    transition: all 0.2s ease;
}

.post-content a:hover {
    color: var(--color-hover);
    text-shadow: 0 0 5px var(--color-hover);
}

.post-download {
    color: var(--color-accent);
    text-decoration: underline;
    cursor: pointer;
}

.post-download:hover {
    color: var(--color-hover);
    text-shadow: 0 0 5px var(--color-hover);
}

.post-content pre {
    background-color: var(--color-bg);
    border: 1px solid var(--color-positive);
    padding: 10px;
    margin: 10px 0;
    overflow-x: auto;
    font-family: 'PxPlusVGA', monospace;
    font-size: 20px;
    line-height: 1.4;
    color: var(--color-positive);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.post-images {
    display: grid;
    gap: 10px;
    margin: 15px 0;
}

.post-images img,
.post-images video {
    /* max-width: 100%; */
    height: auto;
    border: 1px solid var(--color-primary);
    display: block;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--color-accent);
    font-weight: bold;
}

/* Error state */
.error {
    border: 2px solid var(--color-negative);
    background-color: var(--color-bg);
    color: var(--color-negative);
    padding: 15px;
    margin: 20px auto;
    /* max-width: var(--max-width); */
    text-align: center;
}

/* Focus styles */
a:focus-visible,
img:focus-visible,
video:focus-visible,
button:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Form elements */
button, input, select, textarea {
    font-family: 'PxPlusVGA', monospace;
    color: var(--color-primary);
    background-color: var(--color-bg);
    border: 1px solid var(--color-primary);
    padding: 5px 10px;
}

button:hover {
    background-color: var(--color-bg);
    border-color: var(--color-accent);
}

/* Stock ticker */
#ticker-container {
    background-color: var(--color-bg-alt);
    border: 2px solid var(--color-positive);
    border-bottom: 2px solid var(--color-positive);
    padding: 8px;    
    overflow: hidden;
    position: fixed;
    left: 0; 
    top: 0;    
    z-index: 200;
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
}

#breakingnews-container {
    position: fixed;
    left: 0;
    bottom: var(--command-prompt-h, 56px);
    width: 100%;
    /* padding: 8px;     */
    height: 80px;

    display: flex;
    align-items: stretch;

    pointer-events: none;

    overflow: hidden;
    z-index: 200;

    background-color: red;
    font-size: 150%;
    color: white;
    font-weight: bold;
    text-transform: uppercase;
}

.breakingnews-label {
    flex: 0 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    background-color: white;
    color: #cc0000;
}

.breakingnews-marquee {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.breakingnews {
    display: flex;
    width: max-content;
    will-change: transform;
}

.breakingnews.is-running {
    animation: marquee 55s linear infinite;
}

.breakingnews span {
    white-space: pre;
    padding-right: 4rem;
}

@keyframes marquee {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-50%, 0, 0); }
}

.ticker-track {
    display: inline-flex;
    white-space: nowrap;
    will-change: transform;
}

.ticker-track.ticker-animate {
    animation: scroll-ticker linear infinite;
}

@keyframes scroll-ticker {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

.ticker-item {
    display: inline-block;
    margin-right: 2ch;
}

.ticker-symbol {
    color: var(--color-primary);
    font-family: 'PxPlusVGA', monospace;
}

.ticker-value {
    font-family: 'PxPlusVGA', monospace;
}

.ticker-positive {
    color: var(--color-positive);
}

.ticker-negative {
    color: var(--color-negative);
}

.ticker-neutral {
    color: #808080;
}

.ticker-neutral.ticker-blink-off {
    opacity: 0;
}

/* Loading indicator */
.scroll-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 40px 20px;
    color: var(--color-primary);
}

.scroll-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--color-primary);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.scroll-loading p {
    font-size: 20px;
    color: var(--color-primary);
}

/* Load more trigger */
#scroll-trigger {
    height: 20px;
    margin-top: 40px;
}

/* Command prompt */
.command-prompt-form {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: var(--command-prompt-h, 56px);
    z-index: 250;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    background-color: var(--color-bg);
    border-top: 2px solid var(--color-primary);
}

.command-prompt-sigil {
    flex: 0 0 auto;
    color: var(--color-positive);
    font-family: 'PxPlusVGA', monospace;
    font-size: clamp(1rem, 1.2vw + 0.5rem, 1.3rem);
    text-transform: uppercase;
    white-space: nowrap;
}

.command-prompt-input-wrap {
    flex: 1 1 auto;
    position: relative;
    display: block;
}

#command-input {
    width: 100%;
    font-family: 'PxPlusVGA', monospace;
    font-size: clamp(1rem, 1.2vw + 0.5rem, 1.3rem);
    padding: 6px 8px;
    background-color: var(--color-bg);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    outline: none;
}

#command-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-glow);
}

.command-prompt-caret {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-primary);
    font-family: 'PxPlusVGA', monospace;
    font-size: clamp(1rem, 1.2vw + 0.5rem, 1.3rem);
    line-height: 1;
    pointer-events: none;
    animation: command-caret-blink 1s steps(2, start) infinite;
}

#command-input:focus + .command-prompt-caret,
#command-input:not(:placeholder-shown) + .command-prompt-caret {
    display: none;
}

@keyframes command-caret-blink {
    50% { opacity: 0; }
}

#feed.search-loading {
    opacity: 0.6;
}

.search-header {
    color: var(--color-accent);
    font-size: 1.1rem;
    margin: 12px 0 16px;
    text-transform: uppercase;
    scroll-margin-top: 100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.search-header-close {
    font-family: 'PxPlusVGA', monospace;
    font-size: 1rem;
    color: var(--color-accent);
    background: var(--color-bg);
    border: 1px solid var(--color-accent);
    padding: 4px 10px;
    cursor: pointer;
    text-transform: uppercase;
}

.search-header-close:hover {
    color: var(--color-bg);
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.search-result {
    display: block;
    border: 1px solid var(--color-primary);
    padding: 12px 16px;
    margin-bottom: 12px;
    color: var(--color-primary);
    text-decoration: none;
    background-color: var(--color-bg-alt);
    scroll-margin-top: 100px;
}

.search-result:hover {
    border-color: var(--color-accent);
    background-color: var(--color-bg);
}

.search-result-meta {
    color: var(--color-positive);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.search-result-snippet {
    color: var(--color-primary);
    line-height: 1.4;
    word-break: break-word;
}

.search-result mark {
    background-color: var(--color-accent);
    color: var(--color-bg);
    padding: 0 2px;
}

.mainmenu {
    /* font-size: 200%; */
    font-size: clamp(1.1rem, 3vw + 0.5rem, 2rem);
    margin-top: 16px;
    
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.mainmenu a, a:visited {
    border: 1px solid cyan;
    padding: 16px 64px;
    text-transform: uppercase;
    color: white;
    text-decoration: none;
}

.mainmenu a:hover {
    text-decoration: underline;
    color: var(--color-accent);
    background-color: var(--color-primary);
}

/* ============================================
    ANSI GRAPHICS RENDERING
    Rendered via escapes.js → canvas → data URL image
    ============================================ */

.ansi-art-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.bg-effect {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none; /* TODO may want to add interactivity later? */
    background: 0;
    width:100%;
    height:100%;
    padding:0;
    margin:0;
    overflow:hidden;
}

.main-content {
    z-index:100;
    position: relative;
    display: block;
    width: min(90%,1400px);
    margin: 0 auto;
    /* Clear the fixed breaking-news ticker (80px) + command prompt (56px)
       so the last items in any view (search results, single post, end of
       feed) are scrollable above them. */
    padding-bottom: 160px;
}

@keyframes copper-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.15); }
}


.copperbar {
    width: 100%;
    height: var(--copperbar-h);
    position: fixed;
    overflow: hidden;

    background: linear-gradient(
      to bottom,
      #000 0%,
      #5a0000 5%,
      #c40000 15%,
      #ff4747 30%,
      #ff7d7d 50%,
      #ff4747 70%,
      #c40000 85%,
      #5a0000 95%,
      #000 100%
    );

    box-shadow: 0 0 8px rgba(255,64,64,0.6);
}

@keyframes copper-hue {
    0%   { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

@keyframes copper-sine {
  0%   { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.0000), 0); }
  5%   { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.0245), 0); }
  10%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.0955), 0); }
  15%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.2061), 0); }
  20%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.3455), 0); }
  25%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.5000), 0); }
  30%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.6545), 0); }
  35%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.7939), 0); }
  40%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.9045), 0); }
  45%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.9755), 0); }
  50%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 1.0000), 0); }
  55%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.9755), 0); }
  60%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.9045), 0); }
  65%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.7939), 0); }
  70%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.6545), 0); }
  75%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.5000), 0); }
  80%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.3455), 0); }
  85%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.2061), 0); }
  90%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.0955), 0); }
  95%  { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.0245), 0); }
  100% { transform: translate3d(0, calc(10vh + (80vh - var(--copperbar-h)) * 0.0000), 0); }
}

.bar1 { animation: copper-sine 3.0s linear infinite, copper-hue 6s linear infinite; }
.bar2 { animation: copper-sine 3.0s linear infinite, copper-hue 6s linear infinite; animation-delay: -0.1s, -1s; }
.bar3 { animation: copper-sine 3.0s linear infinite, copper-hue 6s linear infinite; animation-delay: -0.2s, -2s; }
.bar4 { animation: copper-sine 3.0s linear infinite, copper-hue 6s linear infinite; animation-delay: -0.3s, -3s; }
.bar5 { animation: copper-sine 3.0s linear infinite, copper-hue 6s linear infinite; animation-delay: -0.4s, -4s; }
.bar6 { animation: copper-sine 3.0s linear infinite, copper-hue 6s linear infinite; animation-delay: -0.5s, -5s; }

#effect-canvas
{
    width:100%;
    height:100%;
    display:none;
}

#copperbar-container
{
    display:none;
    width: 100%;
    height: 100%;
    inset: 0;
}
/* Post actions (likes/retweets) — counts come from /api, share is client-side */
.post-actions {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #333;
  font-size: 12px;
  color: #888;
  align-items: center;
  flex-wrap: wrap;
}

.post-action {
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-action svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.post-action.post-likes svg {
  fill: #e91e63;
}

.post-action.post-retweets svg {
  fill: #4caf50;
}

.post-action.post-share svg {
  fill: #2196f3;
}

.post-action.is-active {
  color: var(--color-accent);
}

.post-action.is-active.post-likes svg {
  fill: var(--color-accent);
}

.post-action.is-active.post-retweets svg {
  fill: var(--color-accent);
}

.post-action.is-busy {
  opacity: 0.5;
  cursor: progress;
}

/* Single post view */
.single-post-back {
  margin-bottom: 20px;
  padding: 10px;
}

.single-post-back a {
  color: #0f0;
  text-decoration: none;
  font-size: 14px;
}

.single-post-back a:hover {
  text-decoration: underline;
}

/* Share toast */
.share-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: #0f0;
  padding: 12px 24px;
  border-radius: 4px;
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}

.share-toast-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Old-school visitor counter, sits inside the header */
#visitor-counter {
    margin: 16px auto 12px;
    padding: 6px 14px;
    text-align: center;
    border: 1px dashed var(--color-positive);
    color: var(--color-positive);
    background-color: #000;
    font-size: 18px;
    letter-spacing: 2px;
    width: fit-content;
    line-height: 1.2;
}

#visitor-counter[hidden] {
    display: none;
}

.visitor-counter-label {
    color: var(--color-primary);
}

.visitor-counter-value {
    color: var(--color-positive);
    font-weight: bold;
    text-shadow: 0 0 4px var(--color-positive);
}

/* ============================================
   File area (secret N S A keyboard activation)
   ============================================ */

.file-area-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow: hidden;
}

.file-area-panel {
    width: min(720px, 100%);
    /* Pin to a fixed slice of the viewport so the panel doesn't jump
       when DIZ expanders open/close — the body scrolls instead. */
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
    background-color: var(--color-bg);
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 24px rgba(0, 255, 255, 0.35);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.file-area-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 2px solid var(--color-primary);
    background-color: var(--color-bg-alt);
}

.file-area-title {
    color: var(--color-accent);
    font-size: 22px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.file-area-close {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 2px 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 18px;
}

.file-area-close:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.file-area-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    /* Retro chunky scrollbar in the cyan/black palette */
    scrollbar-color: var(--color-primary) var(--color-bg);
    scrollbar-width: auto;
}

.file-area-body::-webkit-scrollbar {
    width: 14px;
}

.file-area-body::-webkit-scrollbar-track {
    background: var(--color-bg);
    border-left: 1px solid var(--color-primary);
}

.file-area-body::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border: 2px solid var(--color-bg);
}

.file-area-body::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

.file-area-loading,
.file-area-empty,
.file-area-error {
    color: var(--color-primary);
    text-align: center;
    padding: 24px 8px;
}

.file-area-error {
    color: var(--color-negative);
    border: 1px dashed var(--color-negative);
}

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

.file-area-item {
    border: 1px solid var(--color-primary);
    background-color: var(--color-bg-alt);
    padding: 8px 12px;
    margin-bottom: 8px;
}

.file-area-item:last-child {
    margin-bottom: 0;
}

.file-area-row {
    display: grid;
    grid-template-columns: minmax(13ch, 1fr) 10ch 8ch 8ch 5ch;
    gap: 12px;
    align-items: baseline;
    font-size: 18px;
    white-space: nowrap;
}

.file-area-namebox {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.file-area-preview-btn,
.file-area-action-btn {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 0 4px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.file-area-preview-btn:hover,
.file-area-action-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.file-area-preview-placeholder,
.file-area-action-placeholder {
    display: inline-block;
}

.file-area-link {
    color: var(--color-accent);
    text-decoration: underline;
    white-space: pre;
}

.file-area-link:hover {
    color: var(--color-hover);
    text-shadow: 0 0 5px var(--color-hover);
}

.file-area-link-dir {
    color: var(--color-primary);
}

.file-area-item-dir {
    border-color: var(--color-accent);
}

.file-area-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 12px;
    border-bottom: 1px dashed var(--color-primary);
    margin-bottom: 12px;
    color: var(--color-primary);
    font-size: 16px;
}

.file-area-back {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 0 6px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
}

.file-area-back:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.file-area-path {
    color: var(--color-accent);
    word-break: break-all;
}

.file-area-size {
    color: var(--color-primary);
    text-align: right;
}

.file-area-date {
    color: var(--color-primary);
    opacity: 0.85;
}

.file-area-downloads {
    color: var(--color-positive);
    text-align: right;
}

.file-area-diz {
    margin: 4px 0 6px 12px;
    padding: 0;
}

.file-area-diz-summary {
    cursor: pointer;
    color: var(--color-secondary, #888);
    font-family: 'PxPlusVGA', monospace;
    font-size: 14px;
    list-style: none;
    user-select: none;
    padding: 2px 0;
}

.file-area-diz-summary::-webkit-details-marker {
    display: none;
}

.file-area-diz-summary:hover {
    color: var(--color-primary);
}

.file-area-diz-body {
    margin: 4px 0 0 0;
    padding: 6px 8px;
    border-left: 2px solid var(--color-secondary, #444);
    font-size: 14px;
    line-height: 1.2;
    max-height: 320px;
    overflow: auto;
}

.file-area-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--color-primary);
    color: var(--color-primary);
    font-size: 14px;
    text-align: right;
    opacity: 0.7;
    background-color: var(--color-bg-alt);
}

body.file-area-open {
    overflow: hidden;
}

/* ============================================
   Preview dialog (layered on top of file area)
   ============================================ */

.preview-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background-color: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    overflow: hidden;
}

.preview-dialog-panel {
    width: min(960px, 100%);
    max-height: calc(100vh - 64px);
    background-color: var(--color-bg);
    border: 2px solid var(--color-accent);
    box-shadow: 0 0 24px var(--color-accent-glow);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.preview-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 2px solid var(--color-accent);
    background-color: var(--color-bg-alt);
}

.preview-dialog-title {
    color: var(--color-accent);
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    margin-right: 12px;
}

.preview-dialog-close {
    background: transparent;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    padding: 2px 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 18px;
    flex: 0 0 auto;
}

.preview-dialog-close:hover {
    background-color: var(--color-accent);
    color: var(--color-bg);
}

.preview-dialog-body-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

.preview-dialog-body {
    padding: 16px;
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
    scrollbar-color: var(--color-accent) var(--color-bg);
}

/* Tap-to-navigate zones for touch devices. Hidden (pointer-events: none) on
   mouse/desktop so left-clicks on the preview content don't flip pages. On
   coarse pointers (touchscreens) they capture taps on the outer ~30% of each
   side; the middle stays free for scrolling and text selection. */
.preview-dialog-nav-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    pointer-events: none;
    background: transparent;
    z-index: 1;
}

.preview-dialog-nav-zone-prev { left: 0; }
.preview-dialog-nav-zone-next { right: 0; }

@media (pointer: coarse) {
    .preview-dialog-nav-zone {
        pointer-events: auto;
        cursor: pointer;
    }
}

.preview-dialog-body::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

.preview-dialog-body::-webkit-scrollbar-track {
    background: var(--color-bg);
    border-left: 1px solid var(--color-accent);
}

.preview-dialog-body::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border: 2px solid var(--color-bg);
}

.preview-dialog-loading,
.preview-dialog-error {
    color: var(--color-primary);
    text-align: center;
    padding: 24px 8px;
}

.preview-dialog-error {
    color: var(--color-negative);
    border: 1px dashed var(--color-negative);
}

.preview-dialog-ansi {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.preview-dialog-text {
    color: var(--color-primary);
    background-color: var(--color-bg);
    font-family: 'PxPlusVGA', monospace;
    font-size: 18px;
    line-height: 1.3;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* CP437 art (NFO/DIZ) — columns must stay aligned, so don't wrap.
   Inline overflow handles long banners; the dialog body already scrolls. */
.preview-dialog-cp437 {
    white-space: pre;
    word-break: normal;
    overflow-x: auto;
}

.preview-dialog-image {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
}
