:root {
    --bg-color: #000000;
    --card-bg: #16181c;
    --text-primary: #e7e9ea;
    --text-secondary: #71767b;
    --accent-color: #1d9bf0;
    --accent-warning: #f91880;
    --border-color: #2f3336;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    line-height: 1.5; /* 可読性向上 */
}

.container {
    max-width: 600px;
    margin: 0 auto;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    min-height: 100vh;
    padding-bottom: 80px;
}

/* Global Erosion Monitor Section */
#erosion-monitor-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: #000;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: "";
    width: 4px;
    height: 12px;
    background: var(--accent-warning);
}

#erosion-monitor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 600px) {
    #erosion-monitor-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.sector-item {
    position: relative;
    cursor: help;
}

.sector-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    font-weight: 700;
    margin-bottom: 4px;
    font-family: monospace;
}

.sector-label {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sector-val {
    color: var(--text-primary);
}

.sector-bar-bg {
    height: 4px;
    background: #111;
    border: 1px solid #222;
    overflow: hidden;
}

.sector-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 1s ease-out;
}

/* Color States */
.sector-item.safe .sector-bar-fill { background: #00ba7c; }
.sector-item.caution .sector-bar-fill { background: #ffd900; }
.sector-item.danger .sector-bar-fill { background: #f91880; }

/* Tooltip (CSS only) */
.sector-item::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 4px 8px;
    font-size: 0.6rem;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 2000;
}

.sector-item:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* ... (Existing Styles) ... */
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

#current-time {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: monospace;
}

/* AI Threat Level Meter */
#threat-level-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 180px;
}

.threat-info {
    display: flex;
    gap: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    margin-bottom: 2px;
    font-family: monospace;
}

.threat-label {
    color: var(--text-secondary);
}

#threat-alert {
    transition: color 0.3s;
}

#threat-score {
    color: var(--text-primary);
}

.threat-gauge {
    width: 100%;
    height: 4px;
    background: #111;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

#threat-bar {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease-out, background-color 0.3s;
}

/* Color States */
.threat-safe #threat-bar { background-color: #00ba7c; }
.threat-safe #threat-alert { color: #00ba7c; }

.threat-caution #threat-bar { background-color: #ffd900; }
.threat-caution #threat-alert { color: #ffd900; }

.threat-danger #threat-bar { background-color: #f91880; }
.threat-danger #threat-alert { color: #f91880; }
.threat-danger #threat-level-container {
    animation: alert-blink 1.5s infinite;
}

@keyframes alert-blink {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* ... (Existing Styles) ... */

/* Feed & Post Card Layout */
#feed {
    display: flex;
    flex-direction: column;
}

/* Wide Container for Grid */
.container-wide {
    max-width: 1200px;
}

/* Grid Feed Layout */
#grid-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px;
}

.grid-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 200px; /* Fixed height for uniformity */
}

.grid-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 243, 255, 0.15);
    border-color: var(--accent-color);
}

.grid-card-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    margin-bottom: 8px;
    font-family: monospace;
}

.grid-tag {
    background: #333;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-color);
}

.grid-date {
    color: var(--text-secondary);
}

.grid-title {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.4;
    margin: 0 0 12px 0;
    flex-grow: 1; /* Pushes meta down */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.grid-threat {
    margin-bottom: 12px;
}

.mini-threat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-family: monospace;
}

.mini-threat-bar-bg {
    height: 4px;
    background: #111;
    width: 100%;
    border-radius: 2px;
    overflow: hidden;
}

.mini-threat-bar-fill {
    height: 100%;
}

.grid-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.post-card {
    display: flex; /* Flexboxレイアウト */
    gap: 12px; /* アバターとコンテンツの間隔 */
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    transition: background 0.2s;
}

.post-card:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.avatar {
    width: 48px; /* 少しサイズアップ */
    height: 48px;
    border-radius: 4px;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    flex-shrink: 0; /* つぶれ防止 */
}

.post-content-wrapper {
    flex: 1; /* 残りの幅をすべて占有 */
    min-width: 0; /* 折り返しを正常に機能させる */
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.username {
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.post-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 4px 0 8px 0;
    line-height: 1.25;
}

.post-body {
    font-size: 1rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word; /* 長い単語の溢れ防止 */
}

.news-link-card {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 12px;
    text-decoration: none;
    display: block;
}

.news-meta {
    padding: 12px;
    background: var(--card-bg);
}

.news-title {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 4px;
    font-weight: 700;
}

.news-points {
    margin: 8px 0 12px 0;
    padding-left: 18px;
    list-style-type: disc;
    color: var(--text-secondary);
}

.news-points li {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 4px;
}

.news-points li::marker {
    color: var(--accent-color);
}

.news-url {
    color: var(--text-secondary);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.actions {
    display: flex;
    justify-content: space-between;
    max-width: 425px;
    margin-top: 12px;
    color: var(--text-secondary);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    transition: color 0.15s;
    cursor: pointer;
}

.action-btn:hover {
    color: var(--accent-color);
}

/* Archives Section */
.archives-section {
    padding: 40px 16px;
    border-top: 1px solid var(--border-color);
}

.archives-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-transform: uppercase;
}

.log-list {
    list-style: none;
    padding: 0;
}

.log-item {
    margin-bottom: 12px;
}

.log-item a {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
}

.log-item a:hover {
    text-decoration: underline;
}

/* Read Only Footer */
.read-only-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    padding: 16px;
    display: flex;
    justify-content: center;
    z-index: 2000;
}

.disabled-input {
    background-color: #16181c;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 12px 24px;
    border-radius: 4px;
    width: 100%;
    max-width: 568px;
    font-size: 0.95rem;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Resonance Highlight System */
.resonance-highlight {
    background-color: rgba(0, 243, 255, 0.15);
    border-bottom: 1px dashed #00f3ff;
    cursor: help;
    transition: all 0.3s ease;
    position: relative;
}

.resonance-highlight:hover {
    background-color: rgba(0, 243, 255, 0.3);
}

.resonance-highlight::after {
    content: attr(data-count) " RESONATED";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #00f3ff;
    border: 1px solid #00f3ff;
    padding: 2px 6px;
    font-size: 0.6rem;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
    z-index: 100;
}

.resonance-highlight:hover::after {
    opacity: 1;
}

#resonance-tooltip {
    position: absolute;
    background-color: #000;
    color: #00f3ff;
    border: 1px solid #00f3ff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    transform: translate(-50%, 5px);
    white-space: nowrap;
}

#resonance-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

#resonance-tooltip:hover {
    background-color: #00f3ff;
    color: #000;
}

.interaction-hint {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 8px;
    margin-bottom: 12px;
    font-style: italic;
}

.hint-icon {
    color: #ffd900;
    font-style: normal;
    margin-right: 4px;
}
/* ... (Existing Styles) ... */
.comment-branch {
    position: relative;
    display: flex;
    flex-direction: column;
}

.comment-branch.nested {
    margin-left: 20px; /* Indent */
    border-left: 1px solid var(--border-color); /* Thread line */
}

@media (max-width: 600px) {
    .comment-branch.nested {
        margin-left: 12px;
    }
}

.children-container {
    display: flex;
    flex-direction: column;
}

/* Refine nested post-cards */
.comment-branch.nested > .post-card {
    border-bottom: none;
    padding-top: 8px;
    padding-bottom: 8px;
}

.comment-branch.nested .avatar {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
}
