/* Code-theme page palette. CodeMirror, artwork, title auras and status colours keep
   their own palettes; removing data-site-theme restores the existing design. */
.editor-web-theme-note {
  margin: 12px 0 18px;
  color: #adc5df;
  font-size: .85rem;
  line-height: 1.65;
}

body[data-site-theme="midnight"] {
  --site-bg: #0b1426;
  --site-panel: #14223a;
  --site-inset: #101d32;
  --site-border: #304663;
  --site-text: #e2edff;
  --site-muted: #afc3dc;
  --site-accent: #86efcc;
  color-scheme: dark;
  color: var(--site-text);
  background: radial-gradient(ellipse at 85% 0, #163749 0, transparent 42%),
              radial-gradient(ellipse at 5% 12%, #1a2f55 0, transparent 48%), var(--site-bg);
  background-attachment: fixed;
}
body[data-site-theme="midnight"] .site-header {
  background: linear-gradient(115deg, #13253f, #102736);
  border-bottom-color: var(--site-border);
  box-shadow: 0 8px 30px #050c1b44;
}
body[data-site-theme="midnight"] .logo a { color: var(--site-accent); }
body[data-site-theme="midnight"] .site-header .nav-links a { color: #d5e5f8; }
body[data-site-theme="midnight"] .site-header .nav-links a:hover { color: var(--site-accent); }
body[data-site-theme="midnight"] .user-section { background: #101e34; border-color: var(--site-border); }
body[data-site-theme="midnight"] > footer { background: #0d192b; border-color: var(--site-border); color: var(--site-muted); }

body[data-site-theme="midnight"] :is(
  .mypage-card, .mypage-navigation, .shop-category-filter,
  .shop-item:not([data-emoji-pack-theme]), .post-board, .post-list-toolbar,
  .problem-list-page .board, .problem-detail-refresh,
  .home-hero-panel, .home-panel, .home-ranking-panel, .notification-box
) {
  background: var(--site-panel);
  border-color: var(--site-border);
  color: var(--site-text);
  box-shadow: 0 12px 32px #050c1b33;
}
body[data-site-theme="midnight"] :is(.mypage-profile-card, .home-hero-panel) {
  background: linear-gradient(115deg, #1a3153, #132d3c);
  border-color: #3c5977;
}
body[data-site-theme="midnight"] :is(
  .mypage-stat-item, .mypage-wallet-item, .mypage-overview-tile,
  .item-description-box, .post-board-item, .post-meta-chip,
  .problem-list-page .board-item, .problem-detail-refresh .code-submit
) { background: var(--site-inset); border-color: var(--site-border); }
body[data-site-theme="midnight"] :is(.post-board-item:hover, .problem-list-page .board-item:hover, .mypage-overview-tile:hover) {
  background: #1c3350;
  border-color: #628aab;
}
body[data-site-theme="midnight"] .problem-list-page .board-item.solved-problem:not(.student-solved-problem) .post-title,
body[data-site-theme="midnight"] .problem-list-page .board-item.solved-problem:not(.student-solved-problem) .problem-title-text:not(.level-event) {
  color: #c6ffe0;
}
body[data-site-theme="midnight"] .problem-list-page .board-item.solved-problem:not(.student-solved-problem):hover .post-title,
body[data-site-theme="midnight"] .problem-list-page .board-item.solved-problem:not(.student-solved-problem):hover .problem-title-text:not(.level-event) {
  color: #e1ffed;
}
body[data-site-theme="midnight"] .problem-list-page .board-item.solved-problem:not(.student-solved-problem) .solved-at {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--site-muted);
}
body[data-site-theme="midnight"] .problem-list-page .board-item.student-solved-problem {
  background: #173b36;
  border-color: #4da782;
  box-shadow: inset 5px 0 0 #78e0ad;
}
body[data-site-theme="midnight"] .problem-list-page .board-item.student-solved-problem:hover {
  background: #205044;
  border-color: #83dab0;
}
body[data-site-theme="midnight"] .problem-list-page .board-item.student-solved-problem :is(.post-title, .problem-title-text:not(.level-event), .solved-by-student) {
  color: #c6ffe0;
}
body[data-site-theme="midnight"] .post-board-item.is-boosted { border-left-color: #ffd37c; }
body[data-site-theme="midnight"] :is(.shop-category-tab.is-active, .mypage-navigation a[aria-selected="true"], .post-pagination-link.is-current) {
  background: #224855;
  border-color: #69bfae;
  color: #aeffe4;
}
body[data-site-theme="midnight"] :is(.mypage-page-heading, .shop-header) { background: transparent; }
body[data-site-theme="midnight"] .shop-grid { background: transparent; }
body[data-site-theme="midnight"] :is(.mypage-btn-primary, .post-write-btn, [data-shop-category="editor"] .purchase-btn:not(:disabled)) {
  background: #86efcc;
  color: #0c2932;
  border-color: #86efcc;
}
body[data-site-theme="midnight"] :is(.mypage-btn-primary, .post-write-btn, [data-shop-category="editor"] .purchase-btn:not(:disabled)):hover { background: #acffe3; }
body[data-site-theme="midnight"] .post-page-size-form { background: transparent; }
body[data-site-theme="midnight"] :is(.shop-title, .post-list-heading, .problem-list-page h2, .mypage-panel-heading h3, .item-name, .post-title-link) { color: var(--site-text); }
body[data-site-theme="midnight"] :is(.post-list-subtitle, .problem-list-subtitle, .mypage-panel-heading p, .mypage-stat-label, .item-description) { color: var(--site-muted); }
body[data-site-theme="midnight"] :is(.post-search-form, .post-page-size-form select, .shop-sort-select, .teacher-student-select) {
  background: var(--site-inset);
  color: var(--site-text);
  border-color: var(--site-border);
}
body[data-site-theme="midnight"] .post-search-input { color: var(--site-text); }
body[data-site-theme="midnight"] :is(.site-nav, .mypage-navigation, .post-list-toolbar, .shop-category-filter) :is(a, button, select, input):focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: 3px;
}

/* Post detail and AJAX-inserted comments share the same scoped palette. */
body[data-site-theme="midnight"] :is(.post-detail-card, .comments-card) {
  background: var(--site-panel);
  border-color: var(--site-border);
  color: var(--site-text);
  box-shadow: 0 12px 32px #050c1b33;
}
body[data-site-theme="midnight"] .post-detail-header {
  background: linear-gradient(115deg, #1a3153, #132d3c);
  border-color: var(--site-border);
  border-radius: 10px;
  padding: 16px;
}
body[data-site-theme="midnight"] :is(.post-content, .comments-card .comment-item) {
  background: var(--site-inset);
  border-color: var(--site-border);
  color: var(--site-text);
}
body[data-site-theme="midnight"] .comments-card .comment-reply-item { background: #12253c; }
body[data-site-theme="midnight"] :is(.post-detail-header .post-title, .comments-head h2, .comment-form-block h3, .comments-card .comment-content) { color: var(--site-text); }
body[data-site-theme="midnight"] :is(.comment-char-count, .comment-date, .comment-empty, .comment-login-guide) { color: var(--site-muted); }
body[data-site-theme="midnight"] :is(.comment-form-block, .comment-replies, .comment-empty) { border-color: var(--site-border); }
body[data-site-theme="midnight"] :is(.post-comment-form, .post-like-form, .post-boost-actions form) { background: transparent; }
body[data-site-theme="midnight"] :is(.comment-inline-edit-form, .comment-reply-form) {
  background: #182d46;
  border-color: #3f627d;
}
body[data-site-theme="midnight"] .comments-card textarea {
  background: #0c182b;
  color: var(--site-text);
  border-color: #3f5876;
  caret-color: var(--site-accent);
}
body[data-site-theme="midnight"] .comments-card textarea::placeholder { color: #9cb2ce; }
body[data-site-theme="midnight"] .comments-card textarea:focus {
  border-color: var(--site-accent);
  box-shadow: 0 0 0 2px #86efcc22;
}
body[data-site-theme="midnight"] :is(.post-action-list, .post-action-edit, .comment-inline-edit-cancel, .comment-count, .comment-reply-label) {
  background: #203e50;
  border-color: #416c7e;
  color: #aeffe4;
}
body[data-site-theme="midnight"] :is(.post-action-list, .post-action-edit, .comment-inline-edit-cancel):hover { background: #2a5361; }
body[data-site-theme="midnight"] :is(.comment-submit-btn, .comment-inline-edit-submit) {
  background: var(--site-accent);
  color: #0c2932;
  border-color: var(--site-accent);
}
body[data-site-theme="midnight"] :is(.comment-submit-btn, .comment-inline-edit-submit):hover { background: #acffe3; }
body[data-site-theme="midnight"] :is(.post-file-list a, .post-files-section .section-title, .comment-reply-toggle, .comment-reply-cancel, .comment-reply-mark, .comment-manage-link:not(.comment-manage-delete)) { color: var(--site-accent); }
body[data-site-theme="midnight"] .post-content a { color: #7dd3fc; }
body[data-site-theme="midnight"] .post-content pre { border-color: var(--site-border); }
body[data-site-theme="midnight"] .post-content pre code { background: #111d35; color: #dbeafe; }
body[data-site-theme="midnight"] .post-content :is(.hljs-keyword, .hljs-selector-tag, .hljs-literal) { color: #c4a7ff; }
body[data-site-theme="midnight"] .post-content :is(.hljs-string, .hljs-attr) { color: #86efcc; }
body[data-site-theme="midnight"] .post-content .hljs-number { color: #ffc58f; }
body[data-site-theme="midnight"] .post-content :is(.hljs-title, .hljs-built_in) { color: #7dd3fc; }
body[data-site-theme="midnight"] .post-content .hljs-comment { color: #9bb1d2; }
body[data-site-theme="midnight"] .post-detail-page :is(a, button, textarea):focus-visible { outline: 2px solid var(--site-accent); outline-offset: 3px; }

.site-theme-preview-banner {
  display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:8px 18px;
  padding:9px 18px; border-bottom:1px solid var(--site-border,#50636a);
  background:var(--site-panel,#1f292e); color:var(--site-text,#eef5f3); font-size:.84rem;
  box-shadow:0 6px 18px rgba(0,0,0,.12);
}
.site-theme-preview-banner strong,.site-theme-preview-banner a { color:var(--site-accent,#79dbc0); }
.site-theme-preview-banner a { font-weight:800; text-decoration:underline; text-underline-offset:3px; }
.site-theme-preview-banner form { margin:0; padding:0; border:0; background:transparent; }
.site-theme-preview-banner .site-theme-preview-stop { width:auto; margin:0; padding:6px 4px; border:0; border-radius:0; background:transparent; color:var(--site-accent,#79dbc0); font:inherit; font-weight:700; text-decoration:underline; text-underline-offset:3px; cursor:pointer; }
.site-theme-preview-banner .site-theme-preview-stop:hover { background:transparent; opacity:.78; }
.site-theme-preview-banner .site-theme-preview-stop:focus-visible { outline:2px solid var(--site-accent,#79dbc0); outline-offset:2px; }

@media (max-width: 600px) {
  body[data-site-theme="midnight"] .site-nav-inner .nav-links {
    width: 100%; margin: 0; padding: 0; justify-content: flex-start; flex-direction: row;
  }
  body[data-site-theme="midnight"] .site-nav-inner .nav-links li { width: auto; }
  body[data-site-theme="midnight"] .site-user-tools {
    max-width: 100%; flex-wrap: wrap; min-width: 0;
  }
  body[data-site-theme="midnight"] .user-section {
    max-width: 100%; min-width: 0; flex-wrap: wrap; white-space: normal;
  }
  body[data-site-theme="midnight"] .user-section p { overflow-wrap: anywhere; }
}
