:root {
    color-scheme: light;
    --surface: #f4f6f5;
    --panel: #ffffff;
    --sidebar: #202522;
    --sidebar-muted: #9ba49f;
    --text: #1d2420;
    --muted: #68716c;
    --line: #dce2de;
    --line-strong: #c6cec9;
    --accent: #167a51;
    --accent-hover: #106642;
    --accent-soft: #e7f4ed;
    --warning: #b36a18;
    --danger: #b43b37;
    --danger-soft: #fbeceb;
    --focus: rgba(22, 122, 81, 0.2);
    font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
    letter-spacing: 0;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.setup-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100svh;
}

.setup-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100svh;
    padding: 36px 28px 28px;
    background: var(--sidebar);
    color: #f7faf8;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    color: inherit;
    text-decoration: none;
}

.brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.brand span,
.step span,
.sidebar-status span,
.identity span,
.job-current span {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.brand strong {
    font-size: 17px;
    line-height: 1.25;
}

.brand small,
.step small,
.sidebar-status small {
    margin-top: 3px;
    color: var(--sidebar-muted);
    font-size: 12px;
}

.step-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    margin: 64px 0 40px;
    padding: 0;
    list-style: none;
}

.step {
    position: relative;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 66px;
    padding: 10px 8px;
    color: var(--sidebar-muted);
}

.step:not(:last-child)::after {
    position: absolute;
    top: 51px;
    bottom: -15px;
    left: 23px;
    width: 1px;
    background: #3d4541;
    content: "";
}

.step-index {
    z-index: 1;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid #505a54;
    border-radius: 50%;
    background: var(--sidebar);
    font-size: 12px;
    font-weight: 700;
}

.step strong {
    color: inherit;
    font-size: 14px;
}

.step.is-active {
    color: #ffffff;
}

.step.is-active .step-index {
    border-color: #56c18c;
    background: #56c18c;
    color: #16211b;
}

.step.is-done .step-index {
    border-color: #56c18c;
    color: #56c18c;
    font-size: 0;
}

.step.is-done .step-index::before {
    font: normal normal normal 13px/1 FontAwesome;
    content: "\f00c";
}

.step.is-done::after {
    background: #377b59;
}

.sidebar-status {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding-top: 22px;
    border-top: 1px solid #38403c;
}

.sidebar-status strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8d9791;
}

.status-dot.is-ready {
    background: #56c18c;
    box-shadow: 0 0 0 4px rgba(86, 193, 140, 0.14);
}

.status-dot.is-error {
    background: #e06a62;
}

.setup-workspace {
    width: min(100%, 1040px);
    margin: 0 auto;
    padding: 52px clamp(32px, 6vw, 92px) 72px;
}

.workspace-header,
.job-panel > header {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    justify-content: space-between;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.workspace-header h1 {
    margin: 0;
    font-size: clamp(28px, 3vw, 38px);
    line-height: 1.14;
}

.workspace-header > div > p:last-child {
    max-width: 620px;
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.65;
}

.environment-label,
.job-state {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 7px;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--panel);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.notice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 28px;
    padding: 13px 15px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    color: #24573f;
    line-height: 1.55;
}

.notice.is-error {
    border-left-color: var(--danger);
    background: var(--danger-soft);
    color: #7d2926;
}

.setup-form,
.job-panel,
.auth-required {
    margin-top: 38px;
    animation: reveal 240ms ease-out both;
}

.form-section {
    padding: 30px 0 34px;
    border-top: 1px solid var(--line);
}

.section-heading {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.section-number {
    padding-top: 3px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}

.section-heading h2,
.job-panel h2,
.auth-required h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.35;
}

.section-heading p,
.auth-required p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.field-row,
.field-grid {
    margin-left: 52px;
}

.field-row-action {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.field-span {
    grid-column: 1 / -1;
}

.field,
.field > span:first-child {
    display: flex;
}

.field {
    min-width: 0;
    flex-direction: column;
    gap: 8px;
    margin-left: 52px;
}

.field-row .field,
.field-grid .field {
    margin-left: 0;
}

.field-grow {
    flex: 1;
}

.field > span:first-child {
    gap: 6px;
    align-items: baseline;
    color: #36403a;
    font-size: 12px;
    font-weight: 700;
}

.field em {
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
    font-weight: 500;
}

input,
select {
    width: 100%;
    height: 44px;
    padding: 0 13px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    outline: 0;
    background: var(--panel);
    color: var(--text);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder {
    color: #9aa29d;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
}

input.is-invalid,
select.is-invalid {
    border-color: var(--danger);
}

.input-with-action {
    position: relative;
    display: block;
}

.input-with-action input {
    padding-right: 44px;
}

.icon-button {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.icon-button:hover {
    background: var(--surface);
    color: var(--text);
}

.field-error {
    min-height: 16px;
    color: var(--danger);
    font-size: 11px;
}

.button {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.button-primary {
    background: var(--accent);
    color: #ffffff;
}

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

.button-secondary {
    border-color: var(--line-strong);
    background: var(--panel);
    color: #344039;
}

.button-secondary:hover:not(:disabled) {
    border-color: #9ba59f;
    background: #f9faf9;
}

.validate-button {
    min-width: 116px;
    margin-top: 27px;
}

.identity {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin: 12px 0 0 52px;
    padding: 13px 14px;
    border: 1px solid #badbc9;
    border-radius: 5px;
    background: var(--accent-soft);
}

.identity-mark {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
}

.identity small,
.job-current small {
    color: var(--muted);
    font-size: 11px;
}

.identity strong,
.job-current strong {
    margin-top: 2px;
}

.identity code {
    overflow: hidden;
    color: #4b5750;
    font-size: 11px;
    text-overflow: ellipsis;
}

.form-actions {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.form-actions p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.form-actions .button {
    min-width: 132px;
}

.auth-required {
    max-width: 560px;
    padding: 34px 0;
    border-top: 1px solid var(--line);
}

.auth-required > i {
    margin-bottom: 18px;
    color: var(--accent);
    font-size: 24px;
}

.auth-required .button {
    margin-top: 22px;
}

.job-panel {
    padding-top: 30px;
    border-top: 1px solid var(--line);
}

.job-state.is-success {
    border-color: #badbc9;
    background: var(--accent-soft);
    color: var(--accent);
}

.job-state.is-error {
    border-color: #edc6c4;
    background: var(--danger-soft);
    color: var(--danger);
}

.progress-track {
    height: 3px;
    margin: 28px 0;
    overflow: hidden;
    background: var(--line);
}

.progress-track span {
    display: block;
    width: 8%;
    height: 100%;
    background: var(--accent);
    transition: width 360ms ease;
}

.job-current {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
}

.job-current > i {
    width: 24px;
    color: var(--accent);
    font-size: 18px;
    text-align: center;
}

.job-log {
    height: 280px;
    padding: 17px 18px;
    overflow: auto;
    border-radius: 5px;
    background: #171c19;
    color: #cbd4cf;
    font: 12px/1.75 Consolas, "SFMono-Regular", monospace;
}

.log-line {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 6px;
    animation: log-in 180ms ease-out both;
}

.log-line::before {
    color: #56c18c;
    content: ">";
}

.log-line.is-error::before {
    color: #e06a62;
}

.job-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.is-hidden {
    display: none !important;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes log-in {
    from {
        opacity: 0;
        transform: translateY(3px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 820px) {
    .setup-shell {
        grid-template-columns: 1fr;
    }

    .setup-sidebar {
        min-height: auto;
        padding: 22px 20px;
    }

    .step-list {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        margin: 26px 0 18px;
    }

    .step {
        display: flex;
        min-height: auto;
        flex-direction: column;
        gap: 7px;
        align-items: flex-start;
        padding: 0;
    }

    .step:not(:last-child)::after,
    .step small {
        display: none;
    }

    .step-index {
        width: 27px;
        height: 27px;
    }

    .step strong {
        font-size: 11px;
        line-height: 1.3;
    }

    .sidebar-status {
        display: none;
    }

    .setup-workspace {
        padding: 34px 20px 52px;
    }

    .environment-label {
        display: none;
    }

    .workspace-header h1 {
        font-size: 28px;
    }
}

@media (max-width: 600px) {
    .field-row-action,
    .form-actions,
    .job-panel > header {
        align-items: stretch;
        flex-direction: column;
    }

    .field-row,
    .field-grid,
    .field,
    .identity {
        margin-left: 0;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .field-span {
        grid-column: auto;
    }

    .validate-button {
        width: 100%;
        margin-top: 0;
    }

    .identity {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .identity code {
        grid-column: 2;
    }

    .form-actions .button,
    .job-actions .button {
        width: 100%;
    }

    .job-actions {
        flex-direction: column;
    }
}

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