* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f3f5;
    --panel: #ffffff;
    --text: #1f1f23;
    --muted: #6f7480;
    --line: #e5e6eb;
    --accent: #6c3fa5;
    --accent-strong: #5a2f90;
    --accent-soft: #f4effd;
    --danger: #b42318;
    --shadow: 0 1px 1px rgba(12, 12, 13, 0.03);
}

body.dark {
    --bg: #141220;
    --panel: #1e1b2d;
    --text: #efecff;
    --muted: #b3adcc;
    --line: #38334e;
    --accent: #b894ff;
    --accent-strong: #9f79ef;
    --accent-soft: #241d3b;
    --danger: #ff8f87;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.4;
}

body.dark {
    background: #161720;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -50px;
    left: 0;
    z-index: 999;
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    border-radius: 0 0 8px 0;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

.app-shell {
    max-width: 1380px;
    margin: 0 auto;
    padding: 26px 24px 18px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 26px;
}

.topbar h1 {
    margin: 0;
    font-size: 2.05rem;
    font-weight: 450;
    letter-spacing: -0.01em;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.model-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-status-text {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    min-width: 160px;
    text-align: center;
}

.model-status-text.loading {
    animation: pulse 2s ease-in-out infinite;
}

.model-status-text.ready {
    /* Steady state - no animation */
}

/* Dark mode uses CSS variables, no overrides needed */

.model-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.model-label {
    min-width: 35px;
    text-align: center;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.theme-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    font-weight: 600;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background-color: #cfc6e9;
    transition: 0.2s;
    border-radius: 999px;
}

.slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider::before {
    transform: translateX(20px);
}

.playground {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: calc(100vh - 165px);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.left-pane,
.right-pane {
    background: var(--panel);
    padding: 0;
}

.left-pane {
    display: flex;
    flex-direction: column;
}

.right-pane {
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.field-label {
    display: block;
    font-weight: 500;
    margin: 18px 18px 8px;
}

#analyzer-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel);
    color: var(--text);
    margin: 0 18px 10px;
    max-width: 235px;
    font-size: 0.94rem;
}

#analyzer-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.editor-box {
    flex: 1;
    min-height: 0;
    margin: 0 12px 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
}

.editor-box:has(#source-text:disabled) {
    opacity: 0.6;
    pointer-events: none;
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 54px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-label {
    color: var(--text);
    font-size: 1.12rem;
    font-weight: 500;
}

.sample-select {
    border: 1px solid var(--line);
    border-radius: 5px;
    height: 34px;
    padding: 6px 10px;
    background: #f7f7fa;
    color: var(--muted);
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-btn,
.primary-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 999px;
    height: 30px;
    min-width: 38px;
    padding: 5px 12px;
    font-size: 0.84rem;
    cursor: pointer;
}

.primary-btn {
    background: #ececf0;
    color: #a7a9b2;
    border-color: #ececf0;
    font-weight: 500;
}

.primary-btn:hover {
    background: #d8d9df;
}

.primary-btn:not(:disabled) {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.primary-btn:not(:disabled):hover {
    background: var(--accent-strong);
}

.icon-btn:disabled,
.primary-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#source-text {
    width: 100%;
    flex: 1;
    border-radius: 0;
    border: none;
    resize: none;
    padding: 16px 14px;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    color: var(--muted);
    background: #fff;
}

body.dark #source-text {
    background: #000;
    color: #fff;
}

body.dark .sample-select {
    background: #000;
    color: #fff;
    border-color: var(--line);
}

#source-text:focus,
#analyzer-select:focus,
.sample-select:focus,
button:focus-visible,
input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
    outline-offset: 1px;
}

.hint {
    min-height: 18px;
    margin: 5px 14px 8px;
    color: var(--muted);
    font-size: 0.76rem;
}

.placeholder {
    display: grid;
    place-content: center;
    min-height: 100%;
    gap: 9px;
    justify-items: center;
    color: var(--muted);
    text-align: center;
    padding: 40px 20px;
}

.doc-icon {
    color: #5f626b;
    opacity: 1;
    border: 2px dotted #63666f;
    border-radius: 8px;
    padding: 11px;
    line-height: 0;
}

.doc-icon svg {
    width: 50px;
    height: 50px;
}

.doc-icon path {
    stroke-width: 2.6;
}

body.dark .doc-icon {
    color: #fff;
    border-color: #fff;
}

#placeholder-text {
    margin: 4px 0 0;
    color: #1f2130;
    font-size: 2rem;
    line-height: 1.2;
    font-weight: 400;
}

body.dark #placeholder-text {
    color: #fff;
}

.placeholder-subtext {
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.loading-state {
    display: grid;
    place-content: center;
    min-height: 100%;
    padding: 40px 20px;
    gap: 16px;
}

.loading-message {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    min-height: 28px;
}

.loading-dots {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.loading-dots span {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.results {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    width: 100%;
    min-height: 100%;
    overflow: auto;
}

.result-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    background: color-mix(in srgb, var(--panel) 80%, var(--accent-soft));
}

.result-title {
    margin: 0 0 8px;
    font-size: 1rem;
}

.lang-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.lang-name {
    font-size: 1.25rem;
    font-weight: 700;
}

.lang-code {
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 10px;
    font-family: Consolas, "Courier New", monospace;
}

.gauge-wrap {
    display: grid;
    place-items: center;
}

.gauge-svg {
    width: 150px;
    height: 150px;
    transform: rotate(-90deg);
}

.gauge-bg,
.gauge-fill {
    fill: none;
    stroke-width: 12;
}

.gauge-bg {
    stroke: color-mix(in srgb, var(--line) 85%, transparent);
}

.gauge-fill {
    stroke: var(--accent);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.35s ease;
}

.gauge-text {
    margin-top: -88px;
    font-size: 1.6rem;
    font-weight: 700;
}

.gauge-subtext {
    margin-top: -6px;
    color: var(--muted);
    font-size: 0.86rem;
}

.pii-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pii-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.pii-type {
    color: var(--muted);
}

.error-text {
    color: var(--danger);
    font-weight: 600;
}

@media (max-width: 900px) {
    .playground {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .left-pane,
    .right-pane {
        min-height: 360px;
    }

    .editor-box {
        height: calc(100% - 90px);
        margin: 0 10px 10px;
    }

    #placeholder-text {
        font-size: 1.45rem;
    }

    .toolbar-right {
        flex-direction: column;
        gap: 10px;
        align-items: flex-end;
    }

    .model-controls {
        flex-direction: column;
        gap: 8px;
    }
}