/* Test-harness chrome only. Deliberately plain so it never masks the widget's
   own styles (which arrive with the fetched form markup). */

:root {
    --navy: #1c2b4a;
    --border: #d6dbe2;
    --muted: #5b6675;
    --bg: #f4f6f9;
    --accent: #54abd9;
    --error: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #1a1a1a;
    background: var(--bg);
    line-height: 1.5;
}

header {
    background: var(--navy);
    color: #fff;
    padding: 1rem 1.5rem;
}

header h1 { margin: 0; font-size: 1.2rem; }
header p { margin: 0.25rem 0 0; color: #c7d2e3; font-size: 0.85rem; }

.repel {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* ---- header toggles ---- */
.toggles { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.segmented { display: inline-flex; border: 1px solid #3a4a6b; border-radius: 6px; overflow: hidden; }
.segmented button {
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 0;
    padding: 0.4rem 0.8rem;
    background: transparent;
    color: #c7d2e3;
}
.segmented button.is-active { background: var(--accent); color: #fff; }

.switch { display: inline-flex; align-items: center; gap: 0.4rem; color: #c7d2e3; font-size: 0.8rem; cursor: pointer; }
.switch input { width: 1rem; height: 1rem; cursor: pointer; }

/* Its own row below the header repel, aligned right under the switches. */
.target-note {
    margin: 0.6rem 0 0;
    font-size: 0.8rem;
    color: #c7d2e3;
    text-align: right;
}
.target-note #target-origin { font-weight: 600; color: #fff; }
.target-note .target-hint { color: #8ea3c4; }
.target-hint { color: var(--muted); font-size: 0.78rem; }
.target-hint::before { content: "· "; }

.section-hint { color: var(--muted); font-size: 0.8rem; margin: 0 0 0.5rem; }

main {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    align-items: start;
}

@media (max-width: 800px) {
    main { grid-template-columns: 1fr; }
}

.panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.panel h2 { margin-top: 0; font-size: 1rem; }

.section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 1.25rem 0 0.5rem;
}
.section-title:first-child { margin-top: 0; }

/* ---- collapsible manual-fields section ---- */
.manual { margin-block-start: 1.25rem; }
.manual > summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    margin: 0;
    list-style: none;
}
.manual > summary::-webkit-details-marker { display: none; }
.manual > summary::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}
.manual[open] > summary::before { transform: rotate(45deg); }
.manual > summary:hover { color: var(--navy); }
.manual[open] > summary { margin-block-end: 0.85rem; }

/* ---- CSS-only tabs (Configure / Style) ---- */
.tabs > input[name="side-tab"] { position: absolute; opacity: 0; pointer-events: none; }

.tablist {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-block-end: 1rem;
}
.tablist > label {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    padding: 0.4rem 0.75rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tablist > label:hover { color: var(--navy); }
.tablist .target-note { margin-left: auto; }

#tab-configure:checked ~ .tablist label[for="tab-configure"],
#tab-style:checked ~ .tablist label[for="tab-style"] {
    color: var(--navy);
    border-bottom-color: var(--accent);
}

.tabpanel { display: none; }
#tab-configure:checked ~ .tabpanel--configure { display: block; }
#tab-style:checked ~ .tabpanel--style { display: block; }

#embed {
    width: 100%;
    min-height: 130px;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
    font-size: 0.72rem;
    line-height: 1.45;
    tab-size: 2;
    resize: vertical;
    background: #0f1626;
    color: #d6e2f5;
}
#embed:focus { outline: none; border-color: var(--accent); }

.field { margin-block-end: 0.85rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; margin-block-end: 0.25rem; }
.field input[type="text"],
.field select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.9rem;
}

.field--check { display: flex; align-items: center; gap: 0.5rem; }
.field--check label { margin: 0; }

.actions { display: flex; gap: 0.5rem; align-items: center; margin-block-start: 0.5rem; }

button {
    font: inherit;
    cursor: pointer;
    border-radius: 5px;
    border: 1px solid transparent;
    padding: 0.5rem 0.9rem;
}

button[type="submit"] { background: var(--navy); color: #fff; }

button.ghost {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78rem;
    padding: 0.3rem 0.6rem;
}
button.ghost:hover { border-color: var(--accent); color: var(--navy); }

#widget-css {
    width: 100%;
    min-height: 240px;
    margin-block-start: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    tab-size: 2;
    resize: vertical;
    background: #fbfcfe;
    color: #1a2030;
}
#widget-css:focus { outline: none; border-color: var(--accent); }

/* #presets stacks study groups vertically; each group is a <details> that
   toggles a wrapping row of preset buttons. */
#presets {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-block-start: 0.5rem;
}

.preset-group[open] { padding-block-end: 0.5rem; }

.preset-group__title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.5rem 0;
    list-style: none;               /* hide native marker (Firefox) */
}
.preset-group__title::-webkit-details-marker { display: none; }
/* Disclosure caret that rotates when the group is open. */
.preset-group__title::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}
.preset-group[open] .preset-group__title::before { transform: rotate(45deg); }
.preset-group__title:hover { color: var(--navy); }
.preset-group[open] .preset-group__title { color: var(--navy); }
.preset-group__count {
    margin-inline-start: auto;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--muted);
    background: #eef1f5;
    border-radius: 10px;
    padding: 0 0.4rem;
    font-size: 0.68rem;
}

.presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.preset {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    background: #fff;
    border: 1px solid var(--border);
}
.preset:hover { border-color: var(--accent); }
.preset__label { font-weight: 600; font-size: 0.85rem; }
.preset__note { color: var(--muted); font-size: 0.72rem; }

#status {
    font-size: 0.82rem;
    margin-block-start: 0.75rem;
    color: var(--muted);
}
#status[data-error="true"] { color: var(--error); font-weight: 600; }

/* The live column has no panel chrome — the widget sits on the page background,
   centered horizontally and vertically, so it previews the way a host site
   would show it. align-self stretches the cell to the taller config column. */
.live {
    display: flex;
    justify-content: center;
    align-items: center;
    align-self: stretch;
}

#reg-widget {
    width: 100%;
    max-width: 560px;
    min-height: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

/* Make the widget's own busy state visible while testing. */
#reg-widget[aria-busy="true"] { opacity: 0.5; }
