@charset "UTF-8";

/* ══════════════════════════════════════════════
   GlitchPoet — レトロゲーム風スタイルシート
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DotGothic16&display=swap');

/* ── CSS Variables ── */
:root {
    --bg-deep: #0a0a12;
    --bg-panel: #12121e;
    --bg-panel-alt: #1a1a2e;
    --bg-input: #0e0e1a;
    --border: #2a2a4a;
    --border-glow: #4a4a8a;
    --text-primary: #d0d0e8;
    --text-secondary: #8888aa;
    --text-dim: #555577;
    --accent-blue: #7ec8e3;
    --accent-purple: #a78bfa;
    --accent-pink: #f472b6;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-green: #34d399;
    --glow-blue: rgba(126, 200, 227, 0.3);
    --glow-purple: rgba(167, 139, 250, 0.3);
    --font-retro: 'DotGothic16', monospace, sans-serif;
    --crt-scanline: rgba(0, 0, 0, 0.12);
    --msg-window-bg: linear-gradient(145deg, #0d0d1a 0%, #141428 50%, #0d0d1a 100%);
    --msg-window-border: linear-gradient(135deg, #4a4a8a, #7ec8e3, #a78bfa, #4a4a8a);
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-retro);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
}

/* ── CRT Scanline Overlay ── */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(0deg,
            transparent 0px,
            transparent 2px,
            var(--crt-scanline) 2px,
            var(--crt-scanline) 4px);
    opacity: 0;
    transition: opacity 0.3s;
}

body.crt-on::after {
    opacity: 1;
}

/* ── CRT Flicker ── */
@keyframes crtFlicker {

    0%,
    100% {
        opacity: 1;
    }

    92% {
        opacity: 1;
    }

    93% {
        opacity: 0.8;
    }

    94% {
        opacity: 1;
    }
}

body.crt-on {
    animation: crtFlicker 8s infinite;
}

/* ── Header ── */
.header {
    background: linear-gradient(135deg, var(--bg-panel) 0%, var(--bg-panel-alt) 100%);
    border-bottom: 2px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--msg-window-border);
    background-size: 300% 100%;
    animation: borderFlow 4s linear infinite;
}

@keyframes borderFlow {
    0% {
        background-position: 0% 0;
    }

    100% {
        background-position: 300% 0;
    }
}

.header-title {
    font-size: 1.6rem;
    letter-spacing: 0.15em;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ── Toggle Switch (CRT) ── */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-track {
    width: 36px;
    height: 18px;
    border-radius: 9px;
    background: var(--border);
    position: relative;
    transition: background 0.3s;
}

.toggle-switch input:checked+.toggle-track {
    background: var(--accent-blue);
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-primary);
    transition: transform 0.3s;
}

.toggle-switch input:checked+.toggle-track::after {
    transform: translateX(18px);
}

/* ── Layout ── */
.main-container {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    min-height: calc(100vh - 60px);
}

/* ── Panel Common ── */
.panel {
    padding: 1.2rem;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.panel:last-child {
    border-right: none;
}

.panel-section {
    margin-bottom: 1.5rem;
}

.panel-section-title {
    font-size: 0.85rem;
    color: var(--accent-blue);
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-section-title::before {
    content: '▶';
    font-size: 0.6rem;
}

/* ── Input Panel ── */
.input-panel {
    background: var(--bg-panel);
}

/* Text Input */
.text-input {
    width: 100%;
    min-height: 150px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-retro);
    font-size: 0.9rem;
    padding: 0.75rem;
    resize: vertical;
    line-height: 1.7;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.text-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 12px var(--glow-blue);
}

.text-input::placeholder {
    color: var(--text-dim);
}

/* File Button */
.file-load-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    background: var(--bg-panel-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-retro);
    transition: all 0.2s;
}

.file-load-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0.75rem;
}

.mode-tab {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-retro);
    transition: all 0.2s;
}

.mode-tab:first-child {
    border-radius: 4px 0 0 4px;
}

.mode-tab:last-child {
    border-radius: 0 4px 4px 0;
}

.mode-tab.active {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
}

/* Destruction Slider */
.slider-container {
    position: relative;
    margin: 0.5rem 0 1rem;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.destruction-value {
    font-size: 1.1rem;
    font-weight: bold;
    min-width: 3em;
    text-align: right;
}

.destruction-name {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    letter-spacing: 0.05em;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-purple);
    border: 2px solid #fff;
    box-shadow: 0 0 8px var(--glow-purple);
    cursor: pointer;
    transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-purple);
    border: 2px solid #fff;
    box-shadow: 0 0 8px var(--glow-purple);
    cursor: pointer;
}

/* Seed Input */
.seed-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.seed-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-retro);
    font-size: 0.85rem;
    width: 100%;
}

.seed-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.seed-random-btn {
    padding: 0.4rem 0.6rem;
    background: var(--bg-panel-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-retro);
    font-size: 0.8rem;
    transition: all 0.2s;
}

.seed-random-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 6px;
    font-family: var(--font-retro);
    font-size: 0.9rem;
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: #fff;
    box-shadow: 0 4px 15px rgba(167, 139, 250, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(167, 139, 250, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-panel-alt);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* Batch Count Selector */
.batch-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.batch-select {
    padding: 0.4rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-retro);
    font-size: 0.8rem;
}

/* ── Output Panel ── */
.output-panel {
    background: var(--bg-deep);
    display: flex;
    flex-direction: column;
}

/* Message Window (retro game style) */
.message-window {
    position: relative;
    margin: 0 0 1rem;
    padding: 3px;
    border-radius: 8px;
    background: var(--msg-window-border);
    background-size: 300% 300%;
    animation: borderFlow 4s linear infinite;
    min-height: 180px;
}

.message-window-inner {
    background: var(--msg-window-bg);
    border-radius: 6px;
    padding: 1.2rem 1.5rem;
    min-height: 174px;
    font-size: 1rem;
    line-height: 2;
    letter-spacing: 0.05em;
    white-space: pre-wrap;
    word-break: break-all;
    position: relative;
}

.message-window-inner .placeholder {
    color: var(--text-dim);
    font-style: normal;
}

.message-window-inner .cursor-blink {
    display: inline-block;
    width: 0.7em;
    height: 1.1em;
    background: var(--accent-blue);
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Annotations */
.annotation-highlight {
    position: relative;
    border-bottom: 2px dotted;
    cursor: help;
}

.annotation-highlight[data-mode="A1"] {
    border-color: #f472b6;
}

.annotation-highlight[data-mode="A2"] {
    border-color: #ef4444;
}

.annotation-highlight[data-mode="A3"] {
    border-color: #dc2626;
}

.annotation-highlight[data-mode="B1"] {
    border-color: #a78bfa;
}

.annotation-highlight[data-mode="B2"] {
    border-color: #f59e0b;
}

.annotation-highlight[data-mode="B3"] {
    border-color: #34d399;
}

.annotation-highlight[data-mode="C1"] {
    border-color: #7ec8e3;
}

.annotation-highlight[data-mode="C2"] {
    border-color: #38bdf8;
}

.annotation-highlight[data-mode="C3"] {
    border-color: #818cf8;
}

.annotation-highlight[data-mode="T1"] {
    border-color: #fb923c;
}

.annotation-highlight[data-mode="T2"] {
    border-color: #fbbf24;
}

/* Toggle Row */
.toggle-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.toggle-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-retro);
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

/* History & Bookmarks */
.history-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    line-height: 1.5;
}

.history-item:hover {
    border-color: var(--accent-purple);
    background: var(--bg-panel-alt);
}

.history-item.selected {
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px var(--glow-blue);
}

.history-bookmark {
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
    user-select: none;
}

.history-bookmark:hover {
    transform: scale(1.2);
}

.history-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-meta {
    color: var(--text-dim);
    font-size: 0.7rem;
    flex-shrink: 0;
}

/* Export Button */
.export-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ── Detailed Mode Panel ── */
.detail-panel {
    background: var(--bg-panel);
    border-top: 2px solid var(--border);
    padding: 1rem 1.5rem;
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.75rem;
}

.detail-panel.visible {
    display: grid;
}

.mode-card {
    background: var(--bg-panel-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    transition: all 0.2s;
}

.mode-card.enabled {
    border-color: var(--accent-purple);
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.15);
}

.mode-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.mode-card-name {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.mode-card-icon {
    font-size: 1.1rem;
}

.mode-card-id {
    color: var(--text-dim);
    font-size: 0.7rem;
    margin-left: 0.3rem;
}

.mode-card-toggle {
    cursor: pointer;
}

/* Mode Card Params */
.mode-params {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.mode-param-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.mode-param-label {
    min-width: 5em;
    text-align: right;
}

.mode-param-input {
    flex: 1;
    padding: 0.25rem 0.4rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: var(--font-retro);
    font-size: 0.75rem;
}

.mode-param-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.mode-param-select {
    flex: 1;
    padding: 0.25rem 0.4rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: var(--font-retro);
    font-size: 0.75rem;
}

.mode-prob-slider {
    width: 100%;
    height: 4px;
}

.mode-prob-value {
    font-size: 0.7rem;
    color: var(--accent-blue);
    min-width: 2.5em;
    text-align: right;
}

/* ── Diff display ── */
.diff-container {
    display: none;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.8;
}

.diff-container.visible {
    display: block;
}

.diff-del {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    text-decoration: line-through;
}

.diff-ins {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-glow);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .detail-panel {
        grid-template-columns: 1fr;
    }
}

/* ── Glow Animation ── */
@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 5px var(--glow-purple);
    }

    50% {
        box-shadow: 0 0 20px var(--glow-purple), 0 0 40px var(--glow-blue);
    }
}

.generating .btn-primary {
    animation: pulseGlow 1s ease-in-out infinite;
    pointer-events: none;
}

/* ── Annotation tooltip ── */
.anno-tooltip {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--accent-blue);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
    color: var(--accent-blue);
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    transform: translateY(-100%);
    margin-top: -6px;
}

/* ── Input mode indicator ── */
.input-mode-indicator {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

.input-mode-indicator.detected {
    color: var(--accent-green);
}

/* ── Other World Data ── */
.other-world-details {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.other-world-details summary {
    list-style: none;
    font-size: 0.85rem;
    color: var(--accent-orange);
    cursor: pointer;
    outline: none;
}

.other-world-details summary::-webkit-details-marker {
    display: none;
}

.other-world-details[open] summary {
    margin-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.3rem;
    display: block;
}

.other-world-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}