/*
Theme Name: LifeDebug v1
Description: Institutional White Lab Interface
Version: 1.0
Author: LifeDebug Research Institute
*/

:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #777777;
  --border: #e5e5e5;
  --panel: #f9f9f9;
  --accent: #000000;

  --low: #4caf50;
  --medium: #f5b400;
  --high: #ff7a00;
  --critical: #e10600;

  --font-main: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", "Menlo", monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
img { max-width: 100%; height: auto; }

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 60px 20px;
}
@media (max-width: 600px) {
  .container { padding: 30px 20px; }
}

/* HEADER */
.ld-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 30px;
  margin-bottom: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.ld-brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ld-search {
  flex-grow: 1;
  max-width: 300px;
}
.ld-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--panel);
}
.ld-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

/* CARDS & GRID */
.ld-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.ld-card {
  display: block;
  border: 1px solid var(--border);
  padding: 25px;
  background: #fff;
}
.ld-card:hover {
  border-color: var(--accent);
  background: var(--panel);
}
.ld-card-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 10px;
  line-height: 1.4;
}
.ld-card-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

/* SINGLE REPORT */
.ld-report-header {
  margin-bottom: 40px;
}
.ld-title {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.ld-meta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

/* SEVERITY BAR */
.ld-severity-bar {
  height: 4px;
  width: 100%;
  background: var(--panel);
  margin-bottom: 40px;
  position: relative;
}
.ld-severity-fill {
  height: 100%;
}

/* TABS */
.ld-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 50px;
  overflow-x: auto;
}
.ld-tab {
  padding: 10px 15px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.ld-tab:hover { color: var(--text); }
.ld-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.ld-tab.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* SECTIONS */
.ld-section {
  margin-bottom: 60px;
}
.ld-heading {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 20px;
}
.ld-subtitle {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 15px;
}
.ld-content {
  white-space: pre-wrap;
  color: #333;
}

/* ARCHIVE & SEARCH TITLE */
.page-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 30px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
  padding-bottom: 5px;
}

/* ================================================================
   CASE LAYOUT  (Publisher が出力する .ld-* クラス)
   ================================================================ */

/* Case meta bar */
.ld-case-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.ld-case-number {
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ld-title-en {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Question headline */
.ld-question { margin: 24px 0 36px; }
.ld-question p {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
@media (max-width: 600px) {
  .ld-question p { font-size: 1.2rem; }
}

/* Case Report ? poetic intro */
.ld-case-report {
  margin: 36px 0;
  padding: 24px 20px;
  border-left: 2px solid var(--border);
  background: var(--panel);
}
.ld-case-report p {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: #555;
  line-height: 2;
  margin: 0 0 10px;
}
.ld-case-report p:last-child { margin: 0; }

/* AI Arena */
.ld-ai-arena { margin: 48px 0; }
.ld-ai-arena > h2 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 36px;
  font-weight: 400;
}

/* AI Card */
.ld-ai-card {
  border-left: 3px solid var(--ai-color, #888);
  padding-left: 22px;
  margin-bottom: 44px;
}
.ld-ai-card-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.ld-ai-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #bbb;
}
.ld-ai-name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ai-color, #888);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ld-ai-tag {
  font-size: 0.75rem;
  color: var(--muted);
}

/* AI output body */
.ld-ai-output {
  font-size: 0.9rem;
  line-height: 1.85;
  color: #333;
}
.ld-ai-output h3 {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #bbb;
  margin: 22px 0 7px;
  font-weight: 400;
}
.ld-ai-output h3:first-child { margin-top: 0; }
.ld-ai-output p { margin: 0 0 9px; }
.ld-ai-output p:last-child { margin: 0; }
.ld-ai-output strong { font-weight: 600; color: var(--text); }

/* ================================================================
   VOTE SECTION
   ================================================================ */

.ld-vote-section {
  margin: 52px 0 40px;
  padding-top: 36px;
  border-top: 2px solid var(--text);
}
.ld-vote-section > h2 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 14px;
  font-weight: 400;
}
.ld-vote-section > p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 16px;
}

/* Vote message */
.ld-vote-msg {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 0 0 20px;
}

/* AI vote buttons */
.ld-ai-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}
.ld-vote-btn {
  padding: 9px 18px;
  border: 1px solid var(--ai-color, #888);
  background: transparent;
  color: var(--ai-color, #888);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.ld-vote-btn:hover,
.ld-vote-btn.ld-sel {
  background: var(--ai-color, #888);
  color: #fff;
}
.ld-vote-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Cognitive buttons */
.ld-cognitive-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.ld-cog-btn {
  padding: 9px 22px;
  border: 1px solid var(--text);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.ld-cog-btn:hover,
.ld-cog-btn.ld-sel {
  background: var(--text);
  color: var(--bg);
}
.ld-cog-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ================================================================
   RESULTS (post-vote)
   ================================================================ */

.ld-results { margin-top: 28px; }
.ld-results-block { margin-bottom: 28px; }
.ld-results-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
}
.ld-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
}
.ld-result-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  width: 84px;
  flex-shrink: 0;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ld-result-track {
  flex: 1;
  height: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.ld-result-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--text);
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.ld-result-pct {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  width: 42px;
  text-align: right;
  flex-shrink: 0;
}
.ld-results-total {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 16px;
  letter-spacing: 0.04em;
}

/* ================================================================
   CVI WIDGET  (fixed top-right)
   ================================================================ */

#ld-cvi-widget {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 14px;
  pointer-events: none;
  user-select: none;
}
.ld-cvi-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.ld-cvi-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
#ld-cvi-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
#ld-cvi-phase {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
@media (max-width: 600px) {
  #ld-cvi-widget {
    top: auto;
    bottom: 12px;
    right: 12px;
    padding: 7px 10px;
  }
  #ld-cvi-value { font-size: 0.9rem; }
}

/* ================================================================
   FRONT PAGE (v6 Index)
   ================================================================ */

.ld-index-header {
  margin-bottom: 44px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.ld-index-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 10px;
}
.ld-index-desc {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.7;
}
.ld-card-status {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.ld-no-data {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ================================================================
   FOOTER (v6)
   ================================================================ */

.ld-footer {
  margin-top: 80px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
  padding-bottom: 40px;
}
.ld-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  text-align: center;
}
.ld-footer-tag {
  font-size: 0.75rem;
  color: var(--text);
  letter-spacing: 0.1em;
}
.ld-footer-sub {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.ld-footer-copy {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 8px;
}