:root {
    --bg: #f4f7f8;
    --surface: #ffffff;
    --surface-alt: #eef4f3;
    --ink: #18232f;
    --muted: #647083;
    --border: #d8e1e7;
    --accent: #0f8f73;
    --accent-ink: #ffffff;
    --blue: #2563eb;
    --warning: #b7791f;
    --danger: #b42318;
    --shadow: 0 18px 48px rgba(25, 43, 57, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

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

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
    gap: 20px;
    align-items: start;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.result-panel {
    padding: 22px;
}

.settings-panel {
    display: grid;
    gap: 18px;
    padding: 20px;
}

.result-head,
.field-heading,
.strength-row,
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.result-head label,
.field-label,
.field-heading label,
legend {
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.password-output {
    width: 100%;
    min-height: 132px;
    margin-top: 12px;
    padding: 18px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #0f172a;
    background: #fbfcfd;
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 23px;
    line-height: 1.45;
    word-break: break-all;
}

.strength-row {
    margin-top: 16px;
}

.strength-meter {
    position: relative;
    flex: 1;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e6edf1;
}

.strength-meter span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 160ms ease;
}

.strength-meter span[data-level="weak"] {
    background: var(--danger);
}

.strength-meter span[data-level="medium"] {
    background: var(--warning);
}

.strength-meter span[data-level="strong"] {
    background: var(--blue);
}

.strength-meter span[data-level="excellent"] {
    background: var(--accent);
}

.strength-copy {
    display: flex;
    min-width: 128px;
    justify-content: flex-end;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

.strength-copy strong {
    color: var(--ink);
}

.status-line {
    min-height: 22px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
}

.status-line[data-type="success"] {
    color: var(--accent);
}

.status-line[data-type="error"] {
    color: var(--danger);
}

.batch-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.batch-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 36px;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfd;
}

.batch-row span {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: var(--muted);
    background: var(--surface-alt);
    font-size: 12px;
    font-weight: 700;
}

.batch-row code {
    overflow: hidden;
    color: #172033;
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field {
    display: grid;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
}

.segmented-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented-control span {
    display: grid;
    min-height: 38px;
    place-items: center;
    border-radius: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.segmented-control input:checked + span {
    color: var(--ink);
    background: var(--surface);
    box-shadow: 0 1px 5px rgba(23, 35, 47, 0.1);
}

.symbol-mode-field {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfd;
}

.symbol-segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    background: #e9f0f1;
}

.symbol-segmented span {
    min-height: 34px;
    font-size: 13px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.preset-button {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink);
    background: #fbfcfd;
    font-size: 13px;
    font-weight: 700;
}

.preset-button:hover {
    border-color: var(--accent);
}

.number-input,
select {
    width: 72px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink);
    background: #fbfcfd;
    text-align: center;
}

.range-input {
    width: 100%;
    accent-color: var(--accent);
}

.checkbox-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-grid legend {
    grid-column: 1 / -1;
    margin-bottom: 2px;
}

.checkbox-tile,
.select-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfd;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
}

.checkbox-tile input,
.toggle-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.select-field select {
    width: 128px;
}

.select-field .compact-select {
    width: 64px;
}

.toggle-row {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfd;
    font-size: 14px;
    font-weight: 700;
}

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.button {
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    font-weight: 800;
}

.button:hover,
.icon-button:hover,
.preset-button:hover {
    transform: translateY(-1px);
}

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

.button-secondary {
    color: var(--ink);
    border-color: var(--border);
    background: var(--surface);
}

.icon-button {
    width: 42px;
    height: 42px;
    color: var(--ink);
    border-color: var(--border);
    background: var(--surface);
}

.icon-button-small {
    width: 32px;
    height: 32px;
}

.icon-button-small svg {
    width: 16px;
    height: 16px;
}

[hidden] {
    display: none !important;
}

@media (max-width: 880px) {
    .app-shell {
        width: min(100% - 24px, 720px);
        padding: 20px 0;
    }

    .topbar,
    .workspace {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    .topbar .button {
        width: 100%;
    }
}

@media (max-width: 540px) {
    h1 {
        font-size: 25px;
    }

    .result-panel,
    .settings-panel {
        padding: 16px;
    }

    .password-output {
        min-height: 118px;
        font-size: 18px;
    }

    .strength-row {
        align-items: stretch;
        flex-direction: column;
    }

    .strength-copy {
        justify-content: space-between;
        min-width: 0;
    }

    .preset-grid,
    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .batch-row {
        grid-template-columns: 30px minmax(0, 1fr) 34px;
        padding: 8px;
    }
}
