* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    background: #0d1117;
    color: #e6edf3;
}
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #30363d;
}
.logo { font-weight: bold; font-size: 20px; letter-spacing: 0.05em; }
.header-link { color: #58a6ff; text-decoration: none; font-size: 14px; }
.site-footer {
    text-align: center;
    color: #8b949e;
    font-size: 12px;
    padding: 16px;
}

/* ---------- gate (password) ---------- */
.gate {
    max-width: 420px;
    margin: 60px auto;
    padding: 24px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
}
.gate h1 { font-size: 20px; margin-top: 0; }
.gate label { display: block; margin: 14px 0; font-size: 14px; }
.gate input[type="password"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #30363d;
    background: #0d1117;
    color: #e6edf3;
    font-size: 16px;
}
.gate button, .actions button, .actions .button {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    background: #238636;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.gate button:hover, .actions button:hover, .actions .button:hover { background: #2ea043; }
.error { color: #ff7b72; }

/* ---------- editor ---------- */
.editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .editor { grid-template-columns: 1fr; }
}
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 12px;
    font-size: 13px;
}
.controls label { display: flex; flex-direction: column; gap: 4px; }
.controls label.check { flex-direction: row; align-items: center; gap: 6px; padding-top: 18px; }
.controls input[type="text"], .controls select {
    padding: 7px;
    border-radius: 6px;
    border: 1px solid #30363d;
    background: #161b22;
    color: #e6edf3;
}
#code {
    width: 100%;
    min-height: 420px;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: #161b22;
    color: #e6edf3;
    font-family: Consolas, "Cascadia Mono", monospace;
    font-size: 14px;
    line-height: 1.55;
    resize: vertical;
}

/* ---------- stage / window (shared with viewer) ---------- */
#stage { border-radius: 12px; }
.bg-midnight { background: linear-gradient(135deg, #23272f, #05070a); }
.bg-ocean  { background: linear-gradient(135deg, #667eea, #764ba2); }
.bg-sunset { background: linear-gradient(135deg, #f6d365, #fda085); }
.bg-forest { background: linear-gradient(135deg, #134e5e, #71b280); }
.bg-candy  { background: linear-gradient(135deg, #ff9a9e, #fecfef); }
.bg-slate  { background: #334155; }
.bg-sand   { background: #e7e5e4; }
#window {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
#titlebar {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 14px;
    background: rgba(128, 128, 128, 0.15);
    position: relative;
}
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-r { background: #ff5f57; }
.dot-y { background: #febc2e; }
.dot-g { background: #28c840; }
#titlebar-name {
    position: absolute;
    left: 0; right: 0;
    text-align: center;
    color: #9aa0a6;
    font-size: 12px;
    pointer-events: none;
}
#preview { margin: 0; }
#preview-code {
    font-family: Consolas, "Cascadia Mono", monospace;
    line-height: 1.55;
    padding: 16px 22px;
    display: block;
}

.actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}
#save-status { font-size: 14px; color: #8b949e; }
#result { margin-top: 18px; }
#result label { font-size: 13px; display: block; }
.result-row { display: flex; gap: 8px; margin-top: 6px; }
.result-row input {
    flex: 1;
    padding: 9px;
    border-radius: 6px;
    border: 1px solid #30363d;
    background: #161b22;
    color: #e6edf3;
}
.result-row button {
    padding: 9px 14px;
    border: none;
    border-radius: 6px;
    background: #1f6feb;
    color: #fff;
    cursor: pointer;
}
.hint { font-size: 12px; color: #8b949e; }

/* ---------- viewer ---------- */
.viewer { max-width: 960px; margin: 24px auto; padding: 0 16px; }
