/* =========================================
   UI Components (Header, Panel, Console)
   ========================================= */

/* Header */
.js-playground-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-unit);
    border-bottom: 1px solid var(--editor-border);
    background-color: var(--editor-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 10;
}

.js-playground-title {
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.js-playground-title::before {
    content: "JS";
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background-color: #f7df1e;
    color: #000;
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 4px;
}

/* Star Icon for Task Status */
.js-playground-star {
    margin-left: 8px;
    font-size: 1.2rem;
    color: #ccc; /* Default: Gray for not cleared */
    transition: color 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-block;
    cursor: default;
}

.js-playground-star.cleared {
    color: #fdd835; /* Gold for cleared */
    text-shadow: 0 0 5px rgba(253, 216, 53, 0.5);
    transform: scale(1.2);
}

/* Achievement Count */
.js-playground-star-count {
    font-size: 0.9rem;
    color: var(--app-text); /* デフォルト色 */
    margin-left: 4px;
    font-weight: normal;
    opacity: 0.8;
    transition: color 0.3s ease, transform 0.3s ease;
    display: inline-block;
}

/* [NEW] Cleared Count Style to match Star */
.js-playground-star-count.cleared {
    color: #fdd835; /* Gold */
    font-weight: bold;
    opacity: 1;
    text-shadow: 0 0 5px rgba(253, 216, 53, 0.3);
    /* 星に合わせて少し大きく */
    font-size: 1.1rem; 
    transform: translateY(1px); /* 位置微調整 */
}

.js-playground-controls {
    display: flex;
    gap: 10px;
}

/* Main Layout */
.js-playground-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-unit);
    gap: var(--spacing-unit);
    overflow: hidden;
}

@media (min-width: 1080px) {
    .js-playground-main {
        flex-direction: row;
    }
}

/* Editor Panel */
.js-playground-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--editor-border);
    border-radius: 8px;
    background-color: var(--editor-bg);
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.js-playground-panel:focus-within {
    box-shadow: 0 0 0 2px var(--accent-color);
}

.js-playground-panel-header {
    padding: 8px 12px;
    background-color: var(--editor-gutter-bg);
    border-bottom: 1px solid var(--editor-border);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--app-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.js-playground-panel-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* UI Controls (Buttons) */
.js-playground-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color-solid);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.js-playground-btn:hover { background-color: var(--btn-hover-bg); }
.js-playground-btn-primary { background-color: var(--accent-color-solid); color: white; border: 1px solid transparent; }
.js-playground-btn-primary:hover { background-color: #0d8de0; box-shadow: 0 2px 8px rgba(20, 158, 255, 0.4); }
.js-playground-btn-icon { width: 16px; height: 16px; fill: currentColor; }

.js-playground-theme-toggle {
    background: none; border: none; cursor: pointer; color: var(--app-text); padding: 8px;
    border-radius: 50%; transition: background 0.2s;
}
.js-playground-theme-toggle:hover { background-color: rgba(0,0,0,0.1); }

/* Panel Header Buttons */
.js-playground-panel-btn {
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--app-text);
    opacity: 0.7;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    font-weight: bold;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.js-playground-panel-btn:hover {
    opacity: 1;
    background-color: var(--btn-hover-bg);
    color: var(--accent-color-solid);
}

.js-playground-panel-btn:active {
    transform: translateY(1px);
}

/* Run Button in Panel */
.js-playground-panel-btn.run-btn {
    color: var(--accent-color-solid);
    border: 1px solid var(--accent-color-solid);
    opacity: 1;
    padding: 2px 10px;
    margin-right: 4px;
    display: flex;
    gap: 4px;
}

.js-playground-panel-btn.run-btn:hover {
    background-color: var(--accent-color-solid);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(20, 158, 255, 0.3);
}

.js-playground-panel-btn.run-btn svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.js-playground-running-bar {
    position: absolute; bottom: 0; left: 0; height: 3px; width: 0%;
    background-color: var(--accent-color-solid); transition: width 0.3s ease; z-index: 20;
}

.js-playground-processing .js-playground-running-bar {
    width: 100%; animation: shimmer 1s infinite linear;
    background: linear-gradient(to right, var(--accent-color-solid) 0%, #fff 50%, var(--accent-color-solid) 100%);
    background-size: 200% 100%;
}

@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.js-playground-status {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background-color: #ccc; transition: background-color 0.3s, transform 0.3s;
}
.js-playground-status.active { background-color: #4caf50; box-shadow: 0 0 8px #4caf50; }
.js-playground-status.error { background-color: #f44336; }

/* Console Output */
.js-playground-console-output {
    flex: 1;
    padding: 10px;
    font-family: var(--code-font-family);
    font-size: 13px;
    font-weight: var(--code-font-weight);
    overflow-y: auto;
    background-color: var(--console-bg);
    color: var(--console-text);
}

.js-playground-log-entry {
    padding: 4px 8px;
    border-bottom: 1px solid var(--editor-border);
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.2s ease-out;
}

.js-playground-log-entry.log { color: var(--console-text); }
.js-playground-log-entry.error { background-color: var(--console-error-bg); color: var(--console-error-text); }
body.dark-mode .js-playground-log-entry.error { background-color: var(--console-error-bg-dark); color: var(--console-error-text-dark); }
.js-playground-log-entry.info { background-color: var(--console-info-bg); }
body.dark-mode .js-playground-log-entry.info { background-color: var(--console-info-bg-dark); }

.js-playground-log-entry.alert { background-color: var(--console-alert-bg); color: var(--console-alert-text); }
body.dark-mode .js-playground-log-entry.alert { background-color: var(--console-alert-bg-dark); color: var(--console-alert-text-dark); }

.js-playground-log-entry.security { background-color: var(--console-security-bg); color: var(--console-security-text); }
body.dark-mode .js-playground-log-entry.security { background-color: var(--console-security-bg-dark); color: var(--console-security-text-dark); }

.js-playground-log-icon {
    margin-right: 8px;
    font-weight: bold;
    user-select: none;
    flex-shrink: 0;
    min-width: 20px;
}

/* System Messages (Question, Success) */
.js-playground-log-entry.system {
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
    font-family: 'Segoe UI', sans-serif;
    line-height: 1.5;
    display: block; 
    word-break: break-all;
    white-space: normal;
}

.js-playground-log-entry.system.question {
    background-color: #e3f2fd;
    color: #0d47a1;
    border-left: 4px solid #1976d2;
}

body.dark-mode .js-playground-log-entry.system.question {
    background-color: #152b3d;
    color: #82b1ff;
    border-left: 4px solid #2196f3;
}

.js-playground-log-entry.system.success {
    background-color: #e8f5e9;
    color: #1b5e20;
    border-left: 4px solid #43a047;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.dark-mode .js-playground-log-entry.system.success {
    background-color: #1b3320;
    color: #81c784;
    border-left: 4px solid #66bb6a;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }