:root {
    /* Night Garden パレット */
    --bg-base:      #151915;
    --bg-surface:   #222b20;
    --bg-header:    #1a2418;

    --accent-jade:  #3dd68c;
    --accent-ruby:  #e85d75;
    --accent-gold:  #c4a54a;
    --accent-teal:  #73daca;

    --text-primary: #c8d6c0;
    --text-content: #dae5d6;
    --text-muted:   #5a6858;
    --text-dark:    #3a4538;

    /* フォントサイズ */
    --fs-aa: 12px;
    --fs-aa-line: 12px;
    --fs-header-comment: 12px;
    --fs-desc: 12px;
    --fs-comment-aa: 10px;

    /* レイアウト */
    --header-height: 48px;
    --footer-height: 64px;
}

@font-face {
    font-family: "Saitamaar";
    src:
        local('Saitamaar'), url("Saitamaar.woff2") format("woff2");
    font-display: swap;
    font-size: var(--fs-aa);
    line-height: var(--fs-aa-line);
}

body {
    touch-action: manipulation;
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

.main-comment{
    color: var(--text-content);
    overflow-x: hidden; /* 旧Safari向けフォールバック */
    overflow-x: clip;   /* BFC/scroll-container不生成でクリップ（Chrome90+/FF81+/Safari16.4+） */

    pre {
        font-family: "Saitamaar";
        font-size: var(--fs-aa);
        line-height: var(--fs-aa-line);
        padding-top: 2px;
        overflow: clip;    /* Bootstrapの overflow:auto を上書き、scroll-container不生成 */
        touch-action: pan-y; /* 横スワイプをJSへ委譲（CSSは継承しないため明示必要） */
        user-select: none;
        text-rendering: optimizeSpeed;
        -webkit-font-smoothing: none;
    }
}

#head-container{
    z-index: 2;
    background-color: var(--bg-header);
    height: var(--header-height);
}

#main-container {
    margin-top: var(--header-height);
    margin-bottom: var(--footer-height);
    min-height: calc(100dvh - var(--header-height) - var(--footer-height));
    z-index: 1;
}

.catalog {
    background-size: auto;
    background-position: right bottom var(--footer-height);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* クイックアクセス */
.quick-access {
    margin-bottom: 8px;
}

.quick-access-label {
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent-jade);
    opacity: 0.6;
    padding: 0 16px 4px;
}

.quick-access-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(61, 214, 140, 0.08), rgba(34, 43, 32, 0.85));
    border-left: 3px solid var(--accent-jade);
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
    animation: qa-fade-in 0.3s ease;
}

@keyframes qa-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.quick-access-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.quick-access-title {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-access-sub {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.quick-access-series {
    font-size: 11px;
    color: var(--accent-ruby);
    opacity: 0.8;
}

.quick-access-bm {
    font-size: 11px;
    color: var(--accent-teal);
    opacity: 0.8;
}

.btn-jade {
    color: var(--bg-base);
    background: var(--accent-jade);
    border: none;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 14px;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.btn-jade:hover {
    color: var(--bg-base);
    background: var(--accent-jade);
    opacity: 0.85;
}

/* catalog カードリスト */
.thread-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.thread-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(34, 43, 32, 0.75);
    border-left: 3px solid transparent;
    transition: border-color 0.2s ease;
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
}

.thread-card:hover {
    border-left-color: var(--accent-jade);
}

.thread-card .thread-title {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.thread-res-count {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 400;
    opacity: 0.6;
}

.thread-card .thread-desc {
    color: var(--accent-jade);
    font-size: var(--fs-desc);
    opacity: 0.7;
}

.thread-card .thread-action .btn {
    font-size: 13px;
}

/* シリーズグルーピング */
.series-group {
    margin-bottom: 2px;
}

.series-header {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: rgba(34, 53, 38, 0.7);
    border-left: 3px solid var(--accent-jade);
    cursor: pointer;
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
    user-select: none;
    transition: background 0.2s ease;
}

.series-header:hover {
    background: rgba(34, 63, 42, 0.8);
}

.series-header .series-label {
    color: var(--accent-jade);
    font-size: 13px;
    font-weight: 500;
}

.series-header .series-count {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 8px;
}

.series-header .series-toggle {
    color: var(--text-muted);
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.series-header.open .series-toggle {
    transform: rotate(90deg);
}

.series-body {
    display: none;
    padding-left: 12px;
}

.series-body.open {
    display: block;
}

.series-body .thread-card {
    border-left-color: rgba(61, 214, 140, 0.1);
}

/* 検索バー */
.search:focus {
    border-bottom: 2px solid var(--accent-jade) !important;
    transition: border-bottom 0.3s ease;
}

.search::placeholder {
    color: rgba(61, 214, 140, 0.5);
}

.view {
    background-position: right bottom var(--footer-height);
    background-attachment: fixed;
    background-repeat: no-repeat;
    touch-action: pan-y; /* 縦スクロールをコンポジタスレッドに委譲、横スワイプはJSへ */
}

/* view ヘッダ装飾 */
#head-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, var(--accent-jade), transparent);
}

/* view フッタ装飾 */
.view-footer {
    position: fixed !important;
    bottom: 0;
}

.view-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, var(--accent-ruby), transparent);
}

/* ヘッダ情報非表示 */
.header-comment {
    display: none;
}

/* 本編/コメント区切り */
.comment-type-main {
    margin-top: 16px;
    border-left: 2px solid var(--accent-jade);
    padding-left: 8px;
}

.comment-type-comment {
    margin-top: 4px;
    margin-bottom: 4px;
    margin-left: 16px;
    margin-right: 16px;
    padding: 4px 12px;
    opacity: 0.45;
    background: rgba(34, 43, 32, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(90, 104, 88, 0.3);
    max-width: fit-content;
}

.comment-type-comment .main-comment pre {
    font-size: var(--fs-comment-aa);
    line-height: var(--fs-comment-aa);
    margin: 0;
}

/* コマ分割 */
.comment-type-main.koma-split {
    border-left: none;
    padding-left: 0;
}

.koma-frame,
.koma-gap {
    margin: 0;
    border-left: 3px solid var(--accent-jade);
    padding-left: 8px;
}

.koma-gap {
    border-left-color: rgba(61, 214, 140, 0.12);
}

.koma-dot-blank {
    border-left-color: rgba(61, 214, 140, 0.12);
}

/* フローティングページ送り */
.floating-nav {
    position: fixed;
    right: 20px;
    bottom: 70px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.floating-nav .btn {
    width: 80px;
    height: 80px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: var(--bg-header);
    border: 1px solid var(--text-muted);
    color: var(--text-primary);
    border-radius: 12px;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.floating-nav .btn:hover {
    opacity: 0.85;
    color: var(--accent-jade);
    border-color: var(--accent-jade);
}

/* フッタバー */
.footer-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 100%;
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
}

.footer-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.footer-sep {
    width: 1px;
    height: 24px;
    background: var(--text-dark);
    flex-shrink: 0;
}

#page-indicator {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

/* フォントサイズ切替 */
.fs-toggle {
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
}

.fs-btn {
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
    font-size: 11px;
    padding: 2px 8px;
    line-height: 1.4;
}

.fs-btn:hover {
    color: var(--accent-jade);
    border-color: var(--accent-jade);
}

.fs-btn-active {
    color: var(--accent-jade);
    border-color: var(--accent-jade);
    background: rgba(61, 214, 140, 0.15);
}

/* ブックマーク保存フィードバック */
.bookmark-saved {
    color: var(--accent-ruby);
    transition: color 0.3s ease;
}

.bookmark-idle {
    color: var(--accent-jade);
    transition: color 0.3s ease;
}

/* view タイトル */
.view-title {
    color: var(--accent-gold);
}

#foot-container{
    background-color: var(--bg-header);
    opacity: 0.95;
    height: var(--footer-height);
}

.form-control, .form-control:hover, .form-control:focus, .form-control:active{
    background-color: transparent;
    color: var(--accent-teal);
}

.form-control::placeholder{
    color: var(--accent-jade);
}

.footer{
    color: var(--text-dark);
    text-align: center;
}

.desc {
    font-size: var(--fs-desc);
}

/* カラークラス */

.gold {
    color: var(--accent-gold);
}

.ruby {
    color: var(--accent-ruby);
}

.jade {
    color: var(--accent-jade);
}

.mercury{
    color: var(--text-muted);
}

/* レスポンシブ */
@media (max-width: 480px) {
    :root {
        --fs-aa: 6px;
        --fs-aa-line: 6px;
        --fs-header-comment: 9px;
    }
    .header-info {
        font-size: 12px;
    }
    .no-iphone {
        display: none;
    }
}

@media (min-width: 481px) and (max-width: 1024px) {
    :root {
        --fs-aa: 12px;
        --fs-aa-line: 12px;
        --fs-header-comment: 10px;
    }
}

@media (min-width: 1025px) {
    :root {
        --fs-aa: 16px;
        --fs-aa-line: 16px;
    }
}

/* View Transitions */
@keyframes fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

::view-transition-old(root) { animation: fade-out 0.15s ease; }
::view-transition-new(root) { animation: fade-in 0.15s ease; }

/* スクロールバー */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-header); }
::-webkit-scrollbar-thumb { background: rgba(61, 214, 140, 0.4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(61, 214, 140, 0.7); }

/* テキスト選択 */
::selection {
    background: rgba(61, 214, 140, 0.3);
    color: var(--text-content);
}

/* ===== Manager ===== */

.mgr-nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
    font-size: 13px;
    transition: color 0.2s;
}
.mgr-nav-link:hover {
    color: var(--accent-jade);
}

.mgr-section {
    margin-bottom: 24px;
}

.mgr-section-header {
    color: var(--accent-jade);
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    border-left: 3px solid var(--accent-jade);
    margin-bottom: 8px;
    background: rgba(34, 43, 32, 0.4);
}

.mgr-register {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: rgba(34, 43, 32, 0.6);
    border-radius: 4px;
}

.mgr-register input[type="url"] {
    flex: 1;
    max-width: 500px;
}

/* スレッドカード */
.mgr-thread-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mgr-thread-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 16px;
    background: rgba(34, 43, 32, 0.65);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
}

.mgr-thread-card:hover {
    border-left-color: var(--accent-jade);
    background: rgba(34, 43, 32, 0.8);
}

.mgr-thread-card.selected {
    border-left-color: var(--accent-jade);
    background: rgba(34, 43, 32, 0.9);
}

.mgr-thread-info {
    flex: 1;
    min-width: 0;
}

.mgr-thread-title {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mgr-thread-meta {
    display: flex;
    gap: 12px;
    margin-top: 2px;
    font-size: 12px;
    flex-wrap: wrap;
}

.mgr-thread-badge {
    color: var(--text-dark);
    font-size: 11px;
    margin-left: 12px;
    flex-shrink: 0;
}

/* 編集パネル */
.mgr-edit-panel {
    display: none;
    width: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(61, 214, 140, 0.15);
}

.mgr-thread-card.selected .mgr-edit-panel {
    display: block;
    animation: mgr-panel-in 0.2s ease;
}

@keyframes mgr-panel-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mgr-edit-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mgr-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mgr-edit-label {
    color: var(--accent-jade);
    font-size: 11px;
    font-weight: 500;
    width: 50px;
    flex-shrink: 0;
    text-align: right;
}

.mgr-input {
    background: rgba(21, 25, 21, 0.6) !important;
    border: 1px solid rgba(90, 104, 88, 0.3) !important;
    color: var(--text-content) !important;
    font-size: 13px !important;
    border-radius: 3px !important;
}

.mgr-input:focus {
    border-color: var(--accent-jade) !important;
    box-shadow: 0 0 0 1px rgba(61, 214, 140, 0.2) !important;
}

.mgr-input-short {
    max-width: 80px;
}

.mgr-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ボタンバリエーション */
.mgr-btn-jade {
    background: rgba(61, 214, 140, 0.15);
    border: 1px solid rgba(61, 214, 140, 0.4);
    color: var(--accent-jade);
    font-size: 12px;
}
.mgr-btn-jade:hover {
    background: rgba(61, 214, 140, 0.3);
    color: var(--accent-jade);
}

.mgr-btn-teal {
    background: rgba(115, 218, 202, 0.1);
    border: 1px solid rgba(115, 218, 202, 0.3);
    color: var(--accent-teal);
    font-size: 12px;
}
.mgr-btn-teal:hover {
    background: rgba(115, 218, 202, 0.25);
    color: var(--accent-teal);
}

.mgr-btn-ruby {
    background: rgba(232, 93, 117, 0.1);
    border: 1px solid rgba(232, 93, 117, 0.25);
    color: var(--accent-ruby);
    font-size: 12px;
}
.mgr-btn-ruby:hover {
    background: rgba(232, 93, 117, 0.25);
    color: var(--accent-ruby);
}

/* トースト通知 */
.mgr-toast {
    position: fixed;
    bottom: 80px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 6px;
    font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
    font-size: 13px;
    z-index: 100;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.mgr-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mgr-toast-ok {
    background: rgba(34, 43, 32, 0.95);
    border: 1px solid var(--accent-jade);
    color: var(--accent-jade);
}

.mgr-toast-ng {
    background: rgba(43, 32, 34, 0.95);
    border: 1px solid var(--accent-ruby);
    color: var(--accent-ruby);
}
