:root {
    --bg-base: #0a0808;
    --bg-surface: #171012;
    --border-color: #352025;
    --border-hover: #4a2830;

    --text-main: #f8f3f4;
    --text-muted: #988b8e;

    --accent-color: #9f1239;
    --accent-hover: #be123c;
    --accent-light: rgba(159, 18, 57, 0.15);
    --accent-border: rgba(159, 18, 57, 0.3);
    --accent-text: #fda4af;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-pill: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(circle at 0% 0%, rgba(159, 18, 57, 0.25) 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(136, 19, 55, 0.25) 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(225, 29, 72, 0.12) 0%, transparent 30%);
    animation: ambientPulse 8s ease-in-out infinite alternate;
}

.ambient-glow::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 80px rgba(159, 18, 57, 0.1);
}

@keyframes ambientPulse {
    0% {
        opacity: 0.6;
        transform: scale(1);
    }
    100% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.workspace-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

h1, h2 {
    color: var(--text-main);
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2rem;
    font-weight: 600;
}

h2 {
    font-size: 1.4rem;
    font-weight: 500;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.gradient-text {
    background: linear-gradient(135deg, #fff 0%, #d4a5b2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-top: -16px;
    margin-bottom: 8px;
}

.input-field {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(159, 18, 57, 0.2);
}

textarea.input-field {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.form-controls {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.top-k-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 120px;
}

.top-k-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-submit {
    flex: 1;
    background-color: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
    height: 54px;
}

.btn-submit:hover {
    background-color: var(--accent-hover);
}

.btn-submit:active {
    transform: translateY(1px);
}

.btn-text {
    transition: opacity 0.2s;
}

.btn-loader {
    display: none;
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

.btn-submit.is-loading {
    pointer-events: none;
    background-color: var(--accent-hover);
}

.btn-submit.is-loading .btn-text {
    opacity: 0;
}

.btn-submit.is-loading .btn-loader {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.chip {
    display: inline-block;
    background-color: var(--accent-light);
    border: 1px solid var(--accent-border);
    color: var(--accent-text);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-family: ui-monospace, monospace;
    white-space: nowrap;
}

.data-table-wrapper {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th {
    background-color: rgba(255, 255, 255, 0.02);
    padding: 14px 16px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.cat-cell {
    width: 35%;
    padding: 16px;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.cat-title {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
    font-size: 1rem;
}

.nested-cell {
    width: 65%;
    padding: 0;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.inner-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.inner-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.inner-table tr:last-child td {
    border-bottom: none;
}

.col-name {
    width: 70%;
    word-wrap: break-word;
    line-height: 1.4;
}

.col-weight {
    width: 30%;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 24px !important;
}

.error-state {
    color: #f43f5e;
}

.range-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.range-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.range-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.range-value {
    color: var(--text-main);
    font-family: ui-monospace, monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-base);
    border-radius: var(--radius-pill);
    outline: none;
    margin: 8px 0;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(159, 18, 57, 0.4);
}

.range-slider::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

.range-slider:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.range-slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 8, 8, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 40px;
    max-width: 460px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-text {
    color: var(--text-muted);
    line-height: 1.5;
}

.info-accordion {
    margin-top: -12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.info-accordion summary {
    padding: 12px 16px;
    color: var(--accent-text);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    user-select: none;
    transition: background 0.2s;
}

.info-accordion summary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.info-content {
    padding: 0 16px 16px 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.info-content ol,
.info-content ul {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.info-content strong {
    color: var(--text-main);
}

.hint-text {
    font-size: 0.8rem;
    color: var(--accent-text);
    font-weight: normal;
    opacity: 0.9;
}

.col-check {
    width: 48px;
    text-align: center;
    vertical-align: middle !important;
}

.result-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.col-name {
    width: calc(70% - 48px);
    word-wrap: break-word;
    line-height: 1.4;
}

.col-weight {
    width: 30%;
    text-align: right;
    padding-right: 24px !important;
}

.save-btn-container {
    display: flex;
    justify-content: flex-end;
    background: var(--bg-surface);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 8px;
    animation: fadeIn 0.3s ease;
}

.btn-submit.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fab-download {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(159, 18, 57, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: transform 0.2s, background-color 0.2s;
}

.fab-download:hover {
    transform: scale(1.1);
    background-color: var(--accent-hover);
}

.fab-download svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

a {
    color: var(--accent-text);
    text-decoration: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover {
    text-decoration: underline;
}

div.incident {
    background-color: #00000080;
    border-radius: .5rem;
    margin: 1rem 0;
    padding: 1rem;
}
