:root {
    color-scheme: light;
    font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f3f3f6;
    color: #333;
}

* { box-sizing: border-box; }
body { margin: 0; padding: 24px; background: #f3f3f6; }
button, input, select, textarea { font: inherit; }

#ml-tool-content-optimizer {
    --navy: #001c64;
    --navy-dark: #001129;
    --blue: #003087;
    --accent: #0070e0;
    --sky: #449afb;
    --ink: #1e3251;
    --muted: #666;
    --line: #e2e2e2;
    --paper: #fff;
    --success: #0f8b5f;
    --error: #c0392b;
    max-width: 980px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid rgba(0, 28, 100, .11);
    border-radius: 18px;
    background: var(--paper);
    box-shadow: 0 18px 55px rgba(0, 28, 100, .1);
}

.ml-tool-header {
    position: relative;
    overflow: hidden;
    padding: 44px 48px;
    background: linear-gradient(160deg, #001129, #001c64, #003087);
    color: #fff;
}

.ml-tool-motif {
    position: absolute;
    right: -36px;
    bottom: -122px;
    color: rgba(255,255,255,.055);
    font-size: 330px;
    font-weight: 900;
    line-height: 1;
    transform: rotate(-13deg);
    pointer-events: none;
}

.ml-tool-badge {
    display: inline-flex;
    margin-bottom: 16px;
    border: 1px solid rgba(159,195,245,.35);
    border-radius: 999px;
    padding: 6px 11px;
    background: rgba(68,154,251,.15);
    color: #dceaff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.ml-tool-header h1 {
    position: relative;
    max-width: 680px;
    margin: 0 0 12px;
    font-size: clamp(38px, 6vw, 62px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -.03em;
}

.ml-tool-header p {
    position: relative;
    max-width: 690px;
    margin: 0;
    color: #c8dbf5;
    font-size: 17px;
    line-height: 1.6;
}

.ml-tool-body, .ml-tool-results { padding: 38px 48px; }
.ml-tool-results { border-top: 1px solid var(--line); background: #fbfcff; }

.ml-tool-intro, .ml-tool-results-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.ml-tool-eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.ml-tool-intro h2, .ml-tool-results-head h2 {
    margin: 0;
    color: var(--ink);
    font-size: 28px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -.02em;
}

.ml-tool-example {
    flex: none;
    border: 0;
    padding: 8px 0;
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
}
.ml-tool-example:hover { text-decoration: underline; }

.ml-tool-field { margin-bottom: 24px; }
.ml-tool-field > label, .ml-tool-label-row label {
    color: var(--ink);
    font-size: 14px;
    font-weight: 800;
}
.ml-tool-label-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}
.ml-tool-label-row span, .ml-tool-field small {
    color: var(--muted);
    font-size: 12px;
}
.ml-tool-field small { display: block; margin-top: 7px; }
.ml-tool-mode-field label { display: block; margin-bottom: 8px; }

input, select, textarea {
    width: 100%;
    border: 1px solid #cfd5df;
    border-radius: 9px;
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
input, select { height: 50px; padding: 0 14px; }
textarea { min-height: 245px; resize: vertical; padding: 14px; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
    border-color: var(--sky);
    box-shadow: 0 0 0 3px rgba(68,154,251,.16);
}

.ml-tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.ml-tool-grid .ml-tool-field { margin-bottom: 0; }

.ml-tool-privacy {
    display: flex;
    gap: 11px;
    margin: 24px 0;
    border-radius: 9px;
    padding: 14px 16px;
    background: rgba(15,139,95,.07);
    color: #315d50;
    font-size: 13px;
}
.ml-tool-privacy span { color: var(--success); font-weight: 900; }
.ml-tool-privacy p { margin: 0; }

.ml-tool-error {
    margin-bottom: 20px;
    border-left: 4px solid var(--error);
    border-radius: 0 8px 8px 0;
    padding: 13px 16px;
    background: rgba(192,57,43,.07);
    color: #962e23;
    font-size: 14px;
    font-weight: 700;
}

.ml-tool-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ml-tool-button {
    min-height: 48px;
    border-radius: 8px;
    padding: 0 20px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .18s, box-shadow .18s, background .18s;
}
.ml-tool-button:hover:not(:disabled) { transform: translateY(-1px); }
.ml-tool-button:disabled { cursor: not-allowed; opacity: .65; }
.ml-tool-button-primary {
    min-width: 196px;
    border: 0;
    background: linear-gradient(135deg, #001c64, #003087);
    color: #fff;
    box-shadow: 0 8px 20px rgba(0,48,135,.18);
}
.ml-tool-button-primary:hover:not(:disabled) { box-shadow: 0 10px 24px rgba(0,48,135,.26); }
.ml-tool-button-secondary, .ml-tool-button-cancel {
    border: 1px solid #cfd5df;
    background: #fff;
    color: var(--ink);
}
.ml-tool-button-cancel { border-color: rgba(192,57,43,.35); color: var(--error); }

.ml-tool-spinner {
    display: none;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: -3px;
    animation: ml-spin .7s linear infinite;
}
.ml-tool-loading .ml-tool-spinner { display: inline-block; }
@keyframes ml-spin { to { transform: rotate(360deg); } }

.ml-tool-confidence {
    flex: none;
    border-radius: 999px;
    padding: 7px 12px;
    background: rgba(0,112,224,.09);
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}
.ml-tool-progress-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf5;
}
.ml-tool-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--navy), var(--sky));
    transition: width .35s ease;
}
.ml-tool-progress-text { margin: 9px 0 24px; color: var(--muted); font-size: 13px; }

.ml-tool-score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ml-tool-score-grid article {
    border: 1px solid #e1e6ee;
    border-radius: 12px;
    padding: 20px;
    background: #fff;
}
.ml-tool-score-grid span, .ml-tool-score-grid small { display: block; color: var(--muted); }
.ml-tool-score-grid span { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.ml-tool-score-grid strong {
    display: block;
    margin: 5px 0 1px;
    color: var(--navy);
    font-size: 42px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}
.ml-tool-score-grid small { font-size: 12px; }

.ml-tool-summary {
    margin-top: 22px;
    border-left: 4px solid var(--sky);
    border-radius: 0 10px 10px 0;
    padding: 20px 22px;
    background: #fff;
    box-shadow: 0 3px 14px rgba(0,28,100,.05);
}
.ml-tool-summary h3 { margin: 0 0 8px; color: var(--ink); font-size: 15px; font-weight: 900; }
.ml-tool-summary p { margin: 0; line-height: 1.65; }
.ml-tool-recommendations { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.ml-tool-recommendations ul { margin: 0; padding-left: 19px; }
.ml-tool-recommendations li + li { margin-top: 7px; }

.ml-tool-breakdown { margin-top: 22px; border: 1px solid #e1e6ee; border-radius: 12px; background: #fff; }
.ml-tool-breakdown > button {
    display: flex;
    width: 100%;
    justify-content: space-between;
    border: 0;
    padding: 17px 19px;
    background: transparent;
    color: var(--ink);
    font-weight: 900;
    cursor: pointer;
}
.ml-tool-breakdown > button span { transition: transform .18s; }
.ml-tool-breakdown > button[aria-expanded="false"] span { transform: rotate(180deg); }
#ml-rounds-list { border-top: 1px solid #e8ebf0; }
#ml-rounds-list:empty { display: none; }
.ml-tool-criterion { display: grid; grid-template-columns: 170px 92px 1fr; gap: 16px; padding: 17px 19px; }
.ml-tool-criterion + .ml-tool-criterion { border-top: 1px solid #eef0f4; }
.ml-tool-criterion h3 { margin: 0; color: var(--ink); font-size: 14px; }
.ml-tool-criterion strong { color: var(--accent); font-size: 13px; }
.ml-tool-criterion p { margin: 0; color: #555; font-size: 13px; line-height: 1.55; }

.ml-tool-footer {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    border-top: 1px solid var(--line);
    padding: 20px 48px;
    background: #f7f8fb;
    color: var(--muted);
    font-size: 11px;
}
.ml-tool-footer a { color: var(--accent); font-weight: 800; text-decoration: none; }
.ml-tool-hidden { display: none !important; }

@media (max-width: 720px) {
    body { padding: 10px; }
    #ml-tool-content-optimizer { border-radius: 12px; }
    .ml-tool-header, .ml-tool-body, .ml-tool-results { padding: 28px 22px; }
    .ml-tool-header h1 { font-size: 40px; }
    .ml-tool-grid, .ml-tool-score-grid { grid-template-columns: 1fr; }
    textarea { min-height: 190px; }
    .ml-tool-intro, .ml-tool-results-head, .ml-tool-footer { flex-direction: column; }
    .ml-tool-intro, .ml-tool-results-head { align-items: stretch; }
    .ml-tool-confidence { align-self: flex-start; }
    .ml-tool-criterion { grid-template-columns: 1fr; gap: 5px; }
    .ml-tool-footer { padding: 20px 22px; }
    .ml-tool-button { flex: 1 1 140px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
