:root {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    --control-height: 2.4rem;
}
body {
    margin: 0 auto;
    max-width: 960px;
    padding: 0rem 1rem 1rem;
    line-height: 1.5;
}
h1 {
    font-size: 1.8rem;
    margin-bottom: 0.4rem;
}
.dotted-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    padding-bottom: 0.05rem;
}
.dotted-link:hover,
.dotted-link:focus-visible {
    border-bottom-color: #5c6066;
}
select,
input,
textarea {
    font: inherit;
    padding: 0.55rem 0.7rem;
    border: 1px solid #b9bec5;
    border-radius: 3px;
    background-color: #f1f2f4;
}
textarea {
    width: 100%;
    min-height: 150px;
    resize: none;
}
#model {
    height: var(--control-height);
    padding: 0 2.25rem 0 0.85rem;
}
.prompt-card label {
    cursor: text;
}
.prompt-card label h3 {
    margin: 0;
}
.prompt-body {
    border: 1px solid #d5dadd;
    border-radius: 3px;
    padding: 1rem;
    background: #fff;
}
.prompt-body textarea {
    border: none;
    padding: 0;
    min-height: 180px;
    resize: none;
    background: transparent;
}
.prompt-body textarea:focus {
    outline: none;
}
.row.prompt-actions {
    margin-top: 1rem;
    align-items: flex-start;
    gap: 1rem;
}
.prompt-actions button#run {
    flex: 0 0 auto;
    align-self: flex-start;
    white-space: nowrap;
}
.prompt-actions .sampling-settings {
    flex: 1 1 0;
    margin: 0;
}
button {
    font: inherit;
    border: 1px solid #d5dadd;
    border-radius: 3px;
    padding: 0 1.5rem;
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    background: #f8f9fb;
    color: #111;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease;
}
button:hover:not(:disabled) {
    background: #eef1f6;
    border-color: #c5cbd3;
}
button:disabled {
    opacity: 0.6;
    cursor: default;
}
.mode-toggle {
    display: inline-flex;
    border: 1px solid #cbd0d6;
    border-radius: 3px;
    overflow: hidden;
}
.mode-toggle .mode-btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.9rem;
    color: #879099;
    background: #f1f2f4;
    cursor: pointer;
    border: none;
    height: auto;
    font-weight: 400;
    display: inline-block;
}
.mode-toggle .mode-btn.active {
    background: #f1f2f4;
    color: black;
    opacity: 1;
}
.mode-toggle .mode-btn:not(.active) {
    background: #fafbfc;
}
.mode-toggle .mode-btn:disabled {
    cursor: default;
}
.row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}
.controls {
    margin: 1rem 0;
    gap: 1rem;
}
progress {
    width: 180px;
    height: 0.5rem;
}
#out-wrapper {
    border: 1px solid #d5dadd;
    border-radius: 3px;
    padding: 1rem;
    min-height: 200px;
    background: #fff;
    overflow-y: auto;
}
#out {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
#out.raw-mode {
    gap: 0;
}
#out.raw-mode section:first-child {
    display: none;
}
#answer-block p {
    margin: 0.4rem 0;
}
#answer-block pre {
    background: #111;
    color: #f1f1f1;
    padding: 0.6rem;
    border-radius: 2px;
    overflow-x: auto;
}
#answer-block code {
    background: rgba(0, 0, 0, 0.08);
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
}
#think-block {
    margin-bottom: 1rem;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.think-live ~ h4,
#answer-block + h4 {
    margin-top: 0;
}
.think-live {
    padding: 0.6rem 0.8rem;
}
.think-live header {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}
.think-live .think-tokens,
details.think-done summary .think-tokens {
    font-weight: 400;
    color: #5c6066;
    margin-left: 0.4rem;
}

.think-live .think-text {
    border: 1px solid #e4e7eb;
    border-radius: 2px;
    padding: 0.5rem;
    background: #fbfbfb;
    white-space: normal;
}
details.think-done summary {
    cursor: pointer;
    font-weight: 600;
}
details.think-done .think-text {
    margin: 0.4rem 0 0;
    border: 1px solid #d5dadd;
    border-radius: 2px;
    padding: 0.5rem;
    background: #fff;
    white-space: normal;
}
.think-live .think-text pre,
details.think-done .think-text pre {
    background: #111;
    color: #f8f8f8;
    padding: 0.5rem;
    border-radius: 2px;
    overflow-x: auto;
}
.think-live .think-text code,
details.think-done .think-text code {
    background: rgba(0, 0, 0, 0.08);
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
}

.raw-output {
    white-space: pre-wrap;
    font-family:
        "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.95rem;
}
.advanced-output {
    display: none;
    font-family:
        "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 180px;
}
.advanced-output.active {
    display: block;
}
.advanced-output .advanced-hint {
    margin: 0;
    color: #5c6066;
    font-size: 0.9rem;
}
.advanced-token {
    display: inline;
    white-space: inherit;
    margin: 0 0.02rem;
    padding: 0.05rem 0.18rem;
    border-radius: 0.25rem;
    cursor: help;
    transition: outline 120ms ease, transform 120ms ease;
    min-width: 0.2rem;
}
.advanced-token:hover {
    outline: 1px solid rgba(255, 255, 255, 0.4);
    transform: translateY(-0.5px);
}
.advanced-token.manual-token {
    background: rgba(65, 140, 255, 0.5) !important;
    color: #fff;
}
.advanced-token.alt-selection {
    border: 1px solid rgba(255, 255, 255, 0.5);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.5);
}
.advanced-token.branch-anchor {
    outline: 1px solid rgba(190, 190, 190, 0.9);
    box-shadow: 0 0 0 1px rgba(190, 190, 190, 0.4);
}
.advanced-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    pointer-events: none;
    background: #111;
    color: #f8f8f8;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.4rem;
    padding: 0.6rem 0.75rem;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
    font-size: 0.8rem;
    line-height: 1.4;
    max-width: 320px;
    display: none;
}
.advanced-tooltip.visible {
    display: block;
}
.advanced-tooltip h4 {
    margin: 0 0 0.25rem;
    font-size: 0.85rem;
    color: #fff;
}
.advanced-tooltip .tooltip-metrics {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: #d7d7d7;
    margin-bottom: 0.35rem;
}
.advanced-tooltip .tooltip-alternatives {
    margin: 0.3rem 0 0;
}
.advanced-tooltip .tooltip-alternatives p {
    margin: 0 0 0.2rem;
    font-size: 0.74rem;
    color: #bcbcbc;
}
.advanced-tooltip .tooltip-alternatives ol {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.74rem;
    color: #f1f1f1;
}
.advanced-tooltip .tooltip-alternatives li span {
    color: #fbbebe;
}
.advanced-tooltip .tooltip-token {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}
.token-editor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    pointer-events: none;
    display: none;
}
.token-editor.visible {
    display: block;
    pointer-events: none;
}
.token-editor-panel {
    background: #111;
    color: #f8f8f8;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
    width: 260px;
    padding: 0.75rem;
    font-size: 0.9rem;
    pointer-events: auto;
}
.token-editor-panel header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.token-editor-panel textarea {
    width: 100%;
    min-height: 60px;
    resize: vertical;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.4rem 0.5rem;
    font: inherit;
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}
.token-editor-panel label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
}
.token-editor-alts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0.4rem 0;
}
.token-editor-alts button {
    font-size: 0.8rem;
    padding: 0.2rem 0.45rem;
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}
.token-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.6rem;
}
.token-editor-actions button {
    background: rgba(65, 140, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(65, 140, 255, 0.4);
    border-radius: 4px;
    padding: 0.35rem 0.7rem;
}
.token-editor-panel button {
    cursor: pointer;
}
.sampling-settings {
    margin: 0;
    border: 1px solid #d5dadd;
    border-radius: 3px;
    background: #f8f9fb;
    padding: 0;
    overflow: hidden;
}
.sampling-settings summary {
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    min-height: var(--control-height);
    padding: 0 1rem;
    list-style: none;
}
.sampling-settings summary::-webkit-details-marker {
    display: none;
}
.sampling-settings summary::after {
    content: "▾";
    margin-left: auto;
    color: #5c6066;
    transition: transform 0.2s ease;
}
.sampling-settings[open] summary::after {
    transform: rotate(180deg);
}
.sampling-settings[open] summary {
    border-bottom: 1px solid #d5dadd;
}
.sampling-content {
    padding: 0.8rem 1rem 1rem;
}
.sampling-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.6rem;
}
.sampling-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    gap: 0.2rem;
}
.sampling-grid input {
    width: 120px;
}
.sampling-grid label.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}
.sampling-grid label.checkbox-field input {
    width: auto;
}
.sampling-hint {
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    color: #5c6066;
}
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin: 1rem 0 1rem;
}
.output-left {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}
.output-left h3 {
    margin: 0;
}
.metric {
    font-size: 0.9rem;
    color: #5c6066;
}
.metric strong {
    color: #111;
    display: inline-block;
    min-width: 3.2rem;
    text-align: right;
}
