  @import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;600;700&family=JetBrains+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap');

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg: #080c14;
    --surface: #0f172a;
    --border: #1e293b;
    --muted: #475569;
    --subtle: #334155;
    --text: #e2e8f0;
    --dim: #94a3b8;
  }

  body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 32px 20px 60px;
  }

  .wrap { max-width: 860px; margin: 0 auto; }

  /* Header */
  .header { text-align: center; margin-bottom: 40px; }
  .header-badge {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.25em;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 12px;
  }
  .header h1 {
    font-family: 'EB Garamond', serif;
    font-size: clamp(26px, 5vw, 38px);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #e2e8f0 30%, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
  }
  .header p { color: var(--muted); margin-top: 8px; font-size: 14px; }

  /* Tabs */
  .tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 32px;
  }
  .tab-btn {
    flex: 1;
    padding: 4px 4px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: all 0.2s;
    background: transparent;
    color: var(--muted);
    letter-spacing: 0.01em;
  }
  .tab-btn.active {
    background: var(--border);
    color: var(--text);
  }

  /* Panels */
  .panel { display: none; flex-direction: column; gap: 20px; }
  .panel.active { display: flex; }

  /* Cards */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
  }
  .card-sm {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
  }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

  /* Section label */
  .section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 14px;
  }

  /* Concept */
  .concept-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
  .concept-header h2 { font-family: 'EB Garamond', serif; font-size: 20px; font-weight: 600; }
  .concept-header p { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .concept-body { color: var(--dim); line-height: 1.8; font-size: 14px; }

  .feature-icon { font-size: 22px; margin-bottom: 10px; }
  .feature-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
  .feature-text { font-size: 12px; color: #64748b; line-height: 1.6; }

  .tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--border);
    border-radius: 20px;
    font-size: 11px;
    color: var(--dim);
    margin: 2px 3px 2px 0;
  }

  /* Structure diagram */
  .struct-head {
    background: var(--border);
    border: 1px solid #7c3aed;
    border-radius: 10px;
    padding: 12px 24px;
    text-align: center;
    font-size: 12px;
    color: #c084fc;
    display: inline-block;
    min-width: 220px;
  }
  .struct-line { width: 1px; height: 20px; background: var(--subtle); margin: 0 auto; }
  .struct-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
  .struct-node {
    background: var(--border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
  }
  .struct-node .node-label { font-size: 11px; }
  .struct-node .node-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }

  /* Stream */
  .stream { display: flex; gap: 16px; align-items: flex-start; padding: 16px 0; }
  .stream + .stream { border-top: 1px solid var(--border); }
  .stream-bar { width: 3px; border-radius: 2px; align-self: stretch; min-height: 40px; flex-shrink: 0; }
  .stream-name { font-size: 13px; font-weight: 600; margin-bottom: 8px; }

  /* Roles */
  .role-selector { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 24px; }
  .role-btn {
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--surface);
    color: var(--muted);
    transition: all 0.2s;
    text-align: center;
  }
  .role-btn .rbicon { font-size: 18px; margin-bottom: 4px; }
  .role-btn .rbsub { font-size: 10px; line-height: 1.3; }

  .role-card {
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
  }
  .role-header {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
  }
  .role-header-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
  .role-icon { font-size: 28px; }
  .role-title { font-family: 'EB Garamond', serif; font-size: 20px; font-weight: 700; }
  .role-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .role-desc { color: var(--dim); font-size: 14px; line-height: 1.7; }

  .role-body { display: grid; grid-template-columns: 1fr 1fr; }
  .role-col { padding: 24px; }
  .role-col:first-child { border-right: 1px solid var(--border); }

  .task-item { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
  .task-arrow { font-size: 10px; margin-top: 4px; flex-shrink: 0; }
  .task-text { font-size: 13px; color: var(--dim); line-height: 1.5; }

  .skill-row { margin-bottom: 10px; }
  .skill-meta { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; color: var(--dim); }
  .skill-meta span:last-child { opacity: 0.5; font-family: 'JetBrains Mono', monospace; }
  .skill-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
  .skill-fill { height: 100%; border-radius: 2px; }

  .role-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
  }
  .kpi-label { font-size: 11px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; margin-right: 10px; }
  .kpi-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    margin: 2px 4px 2px 0;
  }

  .role-note {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
  }

  /* ROI */
  .roi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
  .roi-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
  .roi-left { display: flex; gap: 8px; align-items: center; }
  .roi-name { font-size: 14px; font-weight: 500; }
  .roi-weight { font-size: 11px; color: var(--muted); margin-top: 2px; }
  .roi-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: var(--border);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--subtle);
    transition: color 0.2s;
  }
  .roi-score.active { color: #34d399; }
  .roi-levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .roi-level-btn {
    padding: 8px 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    text-align: center;
    transition: all 0.15s;
  }
  .roi-level-btn.selected { border-color: #34d399; background: #0a1f14; color: #34d399; }

  .result-card {
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    transition: all 0.4s;
  }
  .result-score-num {
    font-family: 'EB Garamond', serif;
    font-size: clamp(40px, 10vw, 60px);
    font-weight: 700;
    line-height: 1;
    transition: color 0.4s;
  }
  .result-of { font-size: 13px; color: var(--muted); margin-top: 2px; }
  .result-bar-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 20px 0; }
  .result-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease, background 0.4s; }
  .result-label { font-size: 22px; font-family: 'EB Garamond', serif; font-weight: 700; margin-bottom: 12px; }
  .result-advice { color: var(--dim); font-size: 13px; line-height: 1.7; }

  .legend-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
  .legend-range { width: 60px; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); flex-shrink: 0; }
  .legend-bar { flex: 1; height: 4px; border-radius: 2px; }
  .legend-label { font-size: 12px; flex-shrink: 0; width: 200px; }

  /* Edit Mode Styles */
  [contenteditable="true"] {
    outline: none;
    cursor: text;
    transition: all 0.2s;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
  }
  [contenteditable="true"]:hover {
    background: rgba(255,255,255,0.05);
    box-shadow: 0 0 0 1px var(--subtle);
  }
  [contenteditable="true"]:focus {
    background: var(--surface);
    box-shadow: 0 0 0 2px var(--dim);
    -webkit-text-fill-color: var(--text) !important;
    background-clip: border-box !important;
    color: var(--text) !important;
  }

  .edit-toolbar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 12px 24px -8px rgba(0,0,0,0.5);
    z-index: 1000;
  }
  .tool-btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .tool-btn:hover { background: var(--border); }
  .tool-btn.primary { background: #7c3aed; border-color: #7c3aed; color: white; }
  .tool-btn.primary:hover { background: #6d28d9; }
  .tool-btn.active { background: #34d399; border-color: #34d399; color: #080c14; }

  @media (max-width: 600px) {
    .grid-2 { grid-template-columns: 1fr; }
    .role-body { grid-template-columns: 1fr; }
    .role-col:first-child { border-right: none; border-bottom: 1px solid var(--border); }
    .struct-row { grid-template-columns: 1fr; }
    .role-selector { grid-template-columns: repeat(2, 1fr); }
    .roi-levels { grid-template-columns: repeat(2, 1fr); }
    .edit-toolbar { bottom: 12px; right: 12px; left: 12px; justify-content: center; }
  }
