:root {
    --bg-gradient-start: #c6e6fb;
    --bg-gradient-mid: #ccefdc;
    --bg-gradient-end: #f5d9e8;
    --card: #ffffff;
    --text: #132a46;
    --muted: #355676;
    --border: #a9c3da;
    --primary: #2f96bb;
    --primary-hover: #257c9b;
    --secondary: #f2f7fb;
    --secondary-text: #324f6e;
    --log-bg: #f3f9fe;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 52%, var(--bg-gradient-end) 100%);
    padding: 24px;
}

.top-nav {
    max-width: 880px;
    margin: 0 auto 14px;
    display: flex;
    gap: 8px;
    padding: 6px;
    border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, #ffffff 78%, transparent);
}

.nav-tab {
    flex: 1;
    text-decoration: none;
    text-align: center;
    color: var(--secondary-text);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid color-mix(in srgb, var(--border) 68%, transparent);
    background: #f4fbff;
}

.nav-tab-active {
    color: #fff;
    border-color: var(--primary);
    background: linear-gradient(120deg, var(--primary) 0%, #5cb9d4 58%, #8fd3e7 100%);
}

.card {
    max-width: 880px;
    margin: 0 auto;
    background: color-mix(in srgb, var(--card) 94%, white);
    border: 1px solid color-mix(in srgb, var(--border) 84%, transparent);
    border-radius: 16px;
    box-shadow: 0 14px 38px rgba(45, 78, 118, 0.16);
    padding: 26px;
}

h1 {
    margin: 0;
    font-size: 32px;
    text-align: center;
}

.subtitle {
    margin: 8px 0 18px;
    color: var(--muted);
    line-height: 1.5;
    text-align: center;
}

.detect-card {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f7fcff;
    padding: 14px;
}

.detect-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 8px;
}

.detect-content {
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    white-space: pre-wrap;
    color: var(--text);
}

.row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.row > button {
    min-width: 180px;
}

.connect-row {
    margin-bottom: 10px;
}

.connect-row > button {
    width: 100%;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
    align-items: stretch;
}

.control-grid > button {
    width: 100%;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(120deg, var(--primary) 0%, #4fb8c9 60%, #7fd0df 100%);
}

button:hover:not(:disabled) {
    background: linear-gradient(120deg, var(--primary-hover) 0%, #3ea3bb 60%, #6ac4d8 100%);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

button.secondary {
    background: var(--secondary);
    color: var(--secondary-text);
    border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.field-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    margin-bottom: 12px;
}

.options-row {
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fcff;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 600;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.checkbox-card {
    width: 100%;
    height: 100%;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fcff;
    padding: 10px 12px;
    margin: 0;
    line-height: 1.25;
    font-size: 13px;
}

label.checkbox-inline {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 600;
    color: var(--muted);
}

input {
    border: 1px solid #98b6d1;
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
    font-size: 14px;
    color: var(--text);
}

input[type="file"] {
    width: 100%;
}

input:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
    outline-offset: 1px;
}

.status-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 10px 12px;
    margin-bottom: 12px;
    white-space: pre-wrap;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
}

.progress-wrap {
    margin-bottom: 12px;
    background: #e0eef9;
    border: 1px solid #c6dbee;
    border-radius: 999px;
    overflow: hidden;
    height: 30px;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(120deg, #3db7c9 0%, #74c5df 50%, #e7b6d6 100%);
    color: #fff;
    font-size: 12px;
    line-height: 30px;
    text-align: center;
    transition: width 0.15s ease;
}

.log {
    min-height: 180px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid #bed3e6;
    border-radius: 8px;
    background: var(--log-bg);
    padding: 12px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.is-hidden {
    display: none;
}

@media (max-width: 700px) {
    body {
        padding: 14px;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .row {
        flex-direction: column;
    }

    .control-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .nav-tab {
        font-size: 12px;
        padding: 8px 6px;
    }
}
