:root {
    --bg-deep: #0c0b09;
    --bg-card: #161411;
    --bg-panel: #1c1610;
    --accent: #f0b429;
    --accent-soft: rgba(240, 180, 41, 0.12);
    --accent-border: rgba(240, 180, 41, 0.24);
    --text-primary: #ffffff;
    --text-secondary: #ccc7be;
    --text-muted: #7a7568;
    --border: rgba(240, 180, 41, 0.18);
    --good: #a3c759;
    --warn: #e0a42f;
    --risk: #e94f4f;
    --font-display: 'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

button,
a,
span,
p,
h1,
h2,
li {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
    hyphens: auto;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg-deep);
    color: var(--text-secondary);
    font-family: var(--font-display);
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

body.standalone { padding: 24px; }
body.embedded { padding: 0; min-height: auto; }

.tool {
    width: 100%;
    max-width: 1180px;
    background: linear-gradient(180deg, var(--bg-card), var(--bg-deep));
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

body.embedded .tool {
    max-width: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.tool__brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(240, 180, 41, 0.04);
}

.tool__brand-left,
.tool__brand-right,
.kicker,
.label,
.value,
.chip,
.result__label,
.action-btn,
.note-link,
.bar__label,
.list-label {
    font-family: var(--font-mono);
}

.tool__brand-left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.tool__brand-right {
    font-size: 0.66rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    white-space: nowrap;
}

.monogram {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    letter-spacing: 0.06em;
}

.tool__body {
    display: grid;
    grid-template-columns: minmax(260px, 0.95fr) minmax(0, 1.15fr);
    min-height: 620px;
    min-width: 0;
}

.tool__inputs {
    padding: 24px;
    border-right: 1px solid var(--border);
    background: rgba(8, 7, 5, 0.38);
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.tool__output {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.kicker {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.35rem, 3vw, 1.85rem);
    line-height: 1.14;
    letter-spacing: -0.02em;
}

.intro {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
}

.control {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.label {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.69rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    min-width: 0;
}

.label__term {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
}

.info-note {
    position: relative;
    display: inline-grid;
    place-items: center;
    inline-size: 16px;
    block-size: 16px;
    flex: 0 0 auto;
    border: 1px solid var(--accent-border);
    border-radius: 50%;
    color: var(--accent);
    background: rgba(240, 180, 41, 0.05);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    text-transform: none;
    letter-spacing: 0;
}

.info-note__bubble {
    display: none;
    position: absolute;
    z-index: 20;
    inset-block-start: calc(100% + 8px);
    inset-inline-start: 0;
    inline-size: max-content;
    max-inline-size: min(22rem, calc(100vw - 3rem));
    padding: 9px 10px;
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    background: rgba(12, 11, 9, 0.98);
    color: var(--text-secondary);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
    font-family: var(--font-display);
    font-size: 0.76rem;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0;
    text-transform: none;
    text-align: left;
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
}

.info-note:hover .info-note__bubble,
.info-note:focus .info-note__bubble,
.info-note:focus-visible .info-note__bubble,
.info-note.is-visible .info-note__bubble {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.info-note:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.value {
    color: var(--accent);
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(240, 180, 41, 0.2);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--bg-deep);
    cursor: pointer;
    box-shadow: 0 0 0 1px var(--accent);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--bg-deep);
    cursor: pointer;
}

.chip-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chip:hover { border-color: var(--accent); color: var(--text-primary); }
.chip.is-active { background: var(--accent); color: var(--bg-deep); border-color: var(--accent); }

/* Segmented control — for discrete ordinal levels (0-4 maturity), a better fit
   than a slider: each level is an explicit, labeled choice. */
.seg {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.seg__btn {
    appearance: none;
    border: 0;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    padding: 10px 0;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.seg__btn:first-child { border-left: 0; }
.seg__btn:hover { background: rgba(240, 180, 41, 0.09); color: var(--text-secondary); }
.seg__btn.is-active { background: var(--accent); color: var(--bg-deep); }
.seg__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Foundations / references — shows the standards a tool draws on, so the model
   reads as grounded in established practice rather than abstracted from nothing. */
.refs__intro { margin: 0 0 9px; color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }
.refs__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.refs__list li { position: relative; padding-left: 15px; color: var(--text-secondary); font-size: 0.8rem; line-height: 1.45; }
.refs__list li::before { content: ""; position: absolute; left: 0; top: 0.6em; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.refs__list strong { color: var(--text-primary); font-weight: 600; }

.result {
    display: grid;
    grid-template-columns: minmax(168px, 0.42fr) minmax(0, 1fr);
    gap: 28px;
    align-items: center;
    min-width: 0;
}

.score-ring {
    width: 154px;
    height: 154px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--accent) 0deg, rgba(240, 180, 41, 0.12) 0deg);
    position: relative;
}

.score-ring::before {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: var(--bg-deep);
    border: 1px solid var(--border);
}

.score-ring__inner {
    position: relative;
    z-index: 1;
    text-align: center;
}

.score-ring__score {
    display: block;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
}

.score-ring__unit {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.result__label {
    margin: 0 0 7px;
    color: var(--accent);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.result__title {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.25rem, 2.2vw, 1.75rem);
    line-height: 1.12;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.result__text {
    margin: 10px 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.65;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 10px;
    min-width: 0;
}

.metric {
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
    min-width: 0;
    min-height: 86px;
    overflow: hidden;
}

.metric__value {
    display: block;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    font-weight: 700;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
}

.metric__label {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(8, 7, 5, 0.32);
    padding: 15px;
}

.panel h2 {
    margin: 0 0 10px;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.25;
}

.bars {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.bar__top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.bar__label,
.bar__value {
    color: var(--text-secondary);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bar__value { color: var(--accent); }

.bar__track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(240, 180, 41, 0.13);
    overflow: hidden;
}

.bar__fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #f7d87a);
}

.action-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 9px;
}

.action-list li {
    padding-left: 15px;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.action-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

.list-label {
    color: var(--accent);
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: auto;
}

.action-btn,
.note-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn:hover,
.note-link:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.action-btn--primary {
    background: var(--accent);
    color: var(--bg-deep);
    border-color: var(--accent);
    font-weight: 700;
}

.fine-print {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.73rem;
    line-height: 1.55;
}

@media (max-width: 680px) {
    body.standalone { padding: 0; }
    .tool { border-radius: 0; }
    .tool__brand { align-items: flex-start; flex-direction: column; }
    .tool__body { grid-template-columns: 1fr; min-height: auto; }
    .tool__inputs { border-right: 0; border-bottom: 1px solid var(--border); }
    .result { grid-template-columns: 1fr; }
    .score-ring { width: 138px; height: 138px; }
    .metrics { grid-template-columns: 1fr; }
    .info-note__bubble {
        position: fixed;
        inset-inline: 1rem;
        inset-block: auto 1rem;
        inline-size: auto;
        max-inline-size: none;
        transform: none;
    }
    .info-note:hover .info-note__bubble,
    .info-note:focus .info-note__bubble,
    .info-note:focus-visible .info-note__bubble {
        transform: none;
    }
}

@media (min-width: 681px) and (max-width: 860px) {
    .tool__body { grid-template-columns: 1fr; min-height: auto; }
    .tool__inputs { border-right: 0; border-bottom: 1px solid var(--border); }
    .result { grid-template-columns: minmax(150px, 0.36fr) minmax(0, 1fr); gap: 22px; }
    .score-ring { width: 138px; height: 138px; }
}

body.embedded .metrics {
    grid-template-columns: 1fr;
}
