:root {
    --ink: #16201a;
    --muted: #647066;
    --paper: #f6f1e6;
    --panel: rgba(255, 252, 243, 0.82);
    --line: rgba(22, 32, 26, 0.14);
    --shadow: 0 30px 80px rgba(45, 54, 44, 0.16);
    --blue: #2f6fb2;
    --gold: #b56d18;
    --green: #4a8b63;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
    background:
        radial-gradient(circle at 18% 10%, rgba(255, 184, 77, 0.2), transparent 30%),
        radial-gradient(circle at 90% 18%, rgba(79, 140, 255, 0.18), transparent 32%),
        linear-gradient(135deg, #f7f0e3 0%, #edf3e8 100%);
}

body::before {
    position: fixed;
    inset: 0;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(rgba(22, 32, 26, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22, 32, 26, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 82%);
}

.tool-topbar {
    width: min(1400px, calc(100% - 32px));
    margin: 20px auto 24px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
}

.back-link {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    box-shadow: 0 10px 28px rgba(45, 54, 44, 0.12);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    justify-self: start;
}

.topbar-title {
    justify-self: center;
    color: var(--ink);
    font-size: 1.8em;
    font-weight: 800;
    margin: 0;
}

.tool-shell {
    position: relative;
    width: min(1400px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 0 56px;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    gap: 24px;
}

.tool-sidebar,
.tool-content,
.tool-section {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.tool-sidebar {
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    padding: 20px 16px;
    overflow-y: auto;
    border-radius: 30px;
}

.abroad-toggle {
    min-width: 116px;
    height: 38px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 252, 243, 0.72);
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
    justify-self: end;
}

.abroad-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    width: 34px;
    height: 18px;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: rgba(22, 32, 26, 0.18);
    transition: background 180ms ease;
}

.toggle-thumb {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #fffaf0;
    box-shadow: 0 2px 6px rgba(22, 32, 26, 0.22);
    transition: transform 180ms ease;
}

.abroad-toggle:has(input:checked) {
    color: #fffaf0;
    border-color: rgba(47, 111, 178, 0.42);
    background: var(--blue);
}

.abroad-toggle:has(input:checked) .toggle-track {
    background: rgba(255, 252, 243, 0.32);
}

.abroad-toggle:has(input:checked) .toggle-thumb {
    transform: translateX(16px);
}

.abroad-toggle:has(input:focus-visible) {
    outline: 3px solid rgba(47, 111, 178, 0.18);
    outline-offset: 2px;
}

.brand-block {
    display: grid;
    gap: 14px;
    margin: 22px 4px 18px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    color: #fffaf0;
    border-radius: 18px;
    background: #16201a;
    box-shadow: 0 18px 42px rgba(45, 54, 44, 0.2);
    font-size: 24px;
    font-weight: 900;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    letter-spacing: -0.04em;
}

h1 {
    font-size: 1.8em;
    font-weight: 800;
    line-height: 1.1;
}

h2 {
    font-size: 1.8em;
    font-weight: 800;
    line-height: 1.1;
}

h3 {
    font-size: 22px;
    line-height: 1.2;
}

.category-nav {
    display: grid;
    gap: 8px;
}

.category-button {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--ink);
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.category-button:hover,
.category-button:focus-visible,
.category-button.active {
    border-color: rgba(47, 111, 178, 0.22);
    background: rgba(47, 111, 178, 0.1);
    outline: none;
}

.category-button:hover,
.category-button:focus-visible {
    transform: translateX(2px);
}

.category-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.tool-content {
    min-width: 0;
    padding: 28px;
    border-radius: 32px;
}

.content-header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

.search-wrap {
    width: min(360px, 42vw);
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
}

.diy-actions {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 8px;
}

#tool-search {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 252, 243, 0.72);
    font: inherit;
    font-weight: 700;
    outline: none;
}

#tool-search:focus {
    border-color: rgba(47, 111, 178, 0.42);
    box-shadow: 0 0 0 4px rgba(47, 111, 178, 0.1);
}

.common-edit,
.diy-open,
.diy-submit {
    height: 46px;
    padding: 0 18px;
    color: #fffaf0;
    border: 0;
    border-radius: 999px;
    background: #16201a;
    box-shadow: 0 14px 30px rgba(45, 54, 44, 0.18);
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.common-edit {
    background: var(--blue);
}

.common-edit:hover,
.common-edit:focus-visible,
.diy-open:hover,
.diy-open:focus-visible,
.diy-submit:hover,
.diy-submit:focus-visible {
    transform: translateY(-2px);
    outline: none;
}

.common-edit:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

.section-list {
    display: grid;
    gap: 18px;
}

.tool-section {
    padding: 18px;
    border-radius: 24px;
    box-shadow: 0 18px 42px rgba(45, 54, 44, 0.1);
}

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

.section-count {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.tool-card {
    position: relative;
    min-height: 62px;
    padding: 10px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    color: var(--ink);
    border: 1px solid rgba(22, 32, 26, 0.1);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.42);
    text-decoration: none;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.tool-card:hover,
.tool-card:focus-visible {
    transform: translateY(-3px);
    border-color: rgba(47, 111, 178, 0.24);
    box-shadow: 0 16px 34px rgba(45, 54, 44, 0.14);
    outline: none;
}

.tool-card.disabled {
    cursor: default;
    opacity: 0.58;
}

.tool-card.disabled:hover,
.tool-card.disabled:focus-visible {
    transform: none;
    box-shadow: none;
}

.diy-tool-card {
    padding: 0;
    display: block;
}

.diy-tool-card.editing {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.diy-tool-card.dragging {
    opacity: 0.56;
    border-color: rgba(47, 111, 178, 0.42);
    box-shadow: 0 20px 42px rgba(45, 54, 44, 0.18);
}

.diy-tool-card.drag-over-before,
.diy-tool-card.drag-over-after {
    border-color: rgba(47, 111, 178, 0.46);
    background: rgba(47, 111, 178, 0.08);
}

.diy-tool-card.drag-over-before::before,
.diy-tool-card.drag-over-after::before {
    position: absolute;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 999px;
    background: var(--blue);
    content: "";
}

.diy-tool-card.drag-over-before::before {
    left: -7px;
}

.diy-tool-card.drag-over-after::before {
    right: -7px;
}

.tool-card-link {
    min-height: 62px;
    padding: 10px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    color: var(--ink);
    text-decoration: none;
}

.tool-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 252, 243, 0.9);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.tool-remove:hover,
.tool-remove:focus-visible {
    color: #b84b3c;
    border-color: rgba(184, 75, 60, 0.34);
    outline: none;
}

.tool-logo {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.tool-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: #fffaf0;
    border-radius: 14px;
    background: var(--icon-color, var(--blue));
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
}

.tool-name {
    display: block;
    overflow: hidden;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-desc {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-marks {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.tool-mark {
    display: inline-flex;
    padding: 2px 6px;
    color: #fffaf0;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    line-height: 1.2;
}

.abroad-mark,
.vip-mark {
    background: var(--gold);
}

.diy-tool-card.editing .tool-marks {
    right: 38px;
}

.empty-state {
    margin: 48px 0 24px;
    color: var(--muted);
    text-align: center;
    font-size: 16px;
    font-weight: 800;
}

.diy-modal[hidden] {
    display: none;
}

.diy-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
}

.diy-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(22, 32, 26, 0.36);
    backdrop-filter: blur(10px);
}

.diy-panel {
    position: relative;
    width: min(960px, 100%);
    max-height: min(760px, calc(100vh - 48px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: rgba(255, 252, 243, 0.96);
    box-shadow: 0 34px 90px rgba(22, 32, 26, 0.26);
}

.diy-header {
    position: relative;
    padding: 22px 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.diy-kicker {
    margin: 0 0 4px;
    color: var(--gold);
    font-size: 12px;
    font-weight: 900;
}

.diy-close {
    position: absolute;
    right: 24px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.66);
    color: var(--ink);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.diy-body {
    min-height: 0;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 18px;
    overflow: hidden;
}

.diy-select-box,
.diy-form {
    min-height: 0;
    height: 100%;
    padding: 16px;
    border: 1px solid rgba(22, 32, 26, 0.1);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.44);
}

.diy-select-box {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.diy-field-head {
    display: grid;
    grid-template-columns: 1fr minmax(180px, 240px);
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.diy-col-title {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    background: var(--accent, #4a7cf7);
    border-radius: 4px;
    padding: 1px 7px;
    margin-right: 7px;
    line-height: 1.7;
}

.diy-field-head h4,
.diy-form h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 900;
    display: flex;
    align-items: center;
}

#diy-filter,
.diy-form input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 252, 243, 0.8);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    outline: none;
}

.diy-tool-list {
    min-height: 0;
    display: grid;
    align-content: start;
    gap: 8px;
    overflow: auto;
    padding-right: 4px;
}

.diy-pick {
    min-height: 58px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid rgba(22, 32, 26, 0.1);
    border-radius: 14px;
    background: rgba(255, 252, 243, 0.62);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.diy-pick:hover,
.diy-pick:focus-visible,
.diy-pick.selected {
    border-color: rgba(47, 111, 178, 0.28);
    background: rgba(47, 111, 178, 0.1);
    outline: none;
}

.diy-pick-main {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.diy-pick-main strong,
.diy-pick-main span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diy-pick-main strong {
    font-size: 14px;
    font-weight: 900;
}

.diy-pick-main span,
.diy-empty {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.diy-pick-state {
    flex: 0 0 auto;
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
}

.diy-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diy-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.diy-submit {
    width: 100%;
    margin-top: auto;
}

.required-mark {
    margin-left: 3px;
    color: #c7372f;
    font-weight: 900;
}

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

@media (max-width: 1100px) {
    .diy-body {
        grid-template-columns: 1fr;
        overflow: auto;
    }

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

@media (max-width: 820px) {
    .tool-topbar {
        width: min(100% - 28px, 680px);
        gap: 12px;
    }

    .topbar-title {
        font-size: 1.4em;
    }

    .abroad-toggle {
        min-width: 0;
    }

    .tool-shell {
        width: min(100% - 28px, 680px);
        grid-template-columns: 1fr;
    }

    .tool-sidebar {
        position: static;
        height: auto;
    }

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

    .content-header {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .search-wrap,
    .diy-actions {
        grid-column: 1;
        justify-self: stretch;
    }

    .search-wrap {
        width: 100%;
    }

    .diy-open {
        width: 100%;
    }

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

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