:root {
    color-scheme: dark;
    --bg: #111827;
    --panel: rgba(31, 41, 55, .88);
    --panel-strong: rgba(38, 50, 66, .96);
    --panel-soft: rgba(48, 60, 78, .74);
    --line: rgba(210, 198, 166, .18);
    --line-strong: rgba(210, 198, 166, .30);
    --text: #f4efe5;
    --muted: #b4bec8;
    --accent: #94c7bb;
    --accent-dark: #78afa3;
    --accent-warm: #c8b47e;
    --danger: #dc8f9b;
    --shadow: 0 18px 58px rgba(0, 0, 0, .42);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(200, 180, 126, .06), transparent 280px),
        radial-gradient(circle at 18% 10%, rgba(148, 199, 187, .10), transparent 34%),
        linear-gradient(135deg, rgba(148, 199, 187, .06) 0 1px, transparent 1px 36px),
        linear-gradient(45deg, rgba(210, 198, 166, .04) 0 1px, transparent 1px 32px),
        linear-gradient(180deg, #162033 0%, #1e293b 48%, #111827 100%);
    background-attachment: fixed;
    color: var(--text);
    font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(210, 198, 166, .055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 199, 187, .045) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(180deg, transparent, #000 16%, #000 78%, transparent);
    opacity: .30;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(115deg, transparent 0%, rgba(255,255,255,.035) 38%, transparent 52%),
        repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 4px);
    opacity: .18;
}

button,
input,
textarea {
    font: inherit;
}

button {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(180deg, rgba(50, 63, 82, .94), rgba(34, 45, 62, .94));
    color: var(--text);
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

button svg,
.type svg,
.file-label svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn,
.type,
.file-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

button:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 14px rgba(138, 182, 214, .12), inset 0 1px 0 rgba(255,255,255,.07);
}

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

.app-layout {
    width: min(1660px, calc(100vw - 180px));
    margin: 24px auto 24px max(24px, calc((100vw - 1780px) / 2));
    display: grid;
    grid-template-columns: minmax(760px, 1fr);
    gap: 16px;
    align-items: start;
    position: relative;
    z-index: 1;
}

body.has-frequent .app-layout {
    grid-template-columns: minmax(760px, 1fr) 520px;
}

.shell {
    min-width: 0;
}

.toolbar,
.controls,
.pathbar,
.result,
.frequent {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
    border-radius: 8px 8px 0 0;
    background:
        linear-gradient(90deg, rgba(138, 182, 214, .10), transparent 40%),
        var(--panel-strong);
}

.title {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(200, 180, 126, .22);
    border-radius: 8px;
    background: linear-gradient(145deg, rgba(200, 180, 126, .14), rgba(148, 199, 187, .09));
    color: #d5c59a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.brand-mark svg {
    width: 25px;
    height: 25px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.title h1 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    color: #f8fbff;
    text-shadow: 0 0 14px rgba(138, 182, 214, .18);
}

.title p {
    margin: 0;
    color: var(--muted);
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#searchBtn,
#saveConfigBtn,
#loginBtn {
    padding: 0 18px;
    background: linear-gradient(135deg, #6f9fbe, #9fc4dc);
    border-color: var(--accent);
    color: #06111f;
    font-weight: 700;
}

#searchBtn:hover,
#saveConfigBtn:hover,
#loginBtn:hover {
    background: linear-gradient(135deg, #8ab6d6, #a9cbbb);
    color: #06111f;
}

.controls {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 120px 92px;
    gap: 14px;
    align-items: end;
    padding: 16px 20px;
    border-top: 0;
    position: relative;
    z-index: 30;
}

dialog {
    width: min(720px, calc(100vw - 24px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
    color: var(--text);
    background: var(--panel-strong);
    box-shadow: 0 26px 76px rgba(0, 0, 0, .58), 0 0 28px rgba(138, 182, 214, .09);
}

dialog::backdrop {
    background: rgba(17, 24, 39, .58);
    backdrop-filter: blur(6px);
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 18px;
}

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

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkline input {
    width: 16px;
    min-height: 16px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 18px 18px;
}

label {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.keyword-field {
    position: relative;
}

label span {
    color: var(--muted);
    font-size: 13px;
}

input,
textarea {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 10px;
    outline: none;
    background: rgba(18, 28, 45, .78);
    color: var(--text);
}

button,
input,
textarea,
th,
td,
.source-chip,
.file-label {
    font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

input::placeholder,
textarea::placeholder {
    color: #64748b;
}

.search-history {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(148, 199, 187, .20);
    border-radius: 8px;
    background: rgba(22, 32, 49, .96);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .38), 0 0 20px rgba(138, 182, 214, .10);
    backdrop-filter: blur(18px);
}

.search-history[hidden] {
    display: none;
}

.history-chip {
    min-height: 28px;
    max-width: 100%;
    padding: 0 10px;
    border-color: rgba(148, 199, 187, .20);
    border-radius: 4px;
    background: rgba(49, 63, 82, .88);
    color: #dbe8f4;
    overflow-wrap: anywhere;
    word-break: break-all;
    text-align: left;
    font-size: 13px;
}

.history-chip:hover {
    border-color: rgba(200, 180, 126, .38);
    background: rgba(64, 78, 98, .94);
    color: #f5e8bf;
}

.source-filter {
    display: grid;
    gap: 6px;
    grid-column: 1 / -1;
}

.source-filter > span {
    color: var(--muted);
    font-size: 13px;
}

.source-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 36px;
    align-items: center;
}

.source-chip {
    min-height: 30px;
    padding: 0 12px;
    border-radius: 4px;
    white-space: nowrap;
}

.source-chip.active {
    border-color: var(--accent);
    background: rgba(138, 182, 214, .13);
    color: #c8dbea;
    box-shadow: inset 0 0 0 1px rgba(138, 182, 214, .12), 0 0 16px rgba(138, 182, 214, .08);
}

textarea {
    min-height: 64px;
    padding-top: 8px;
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(138, 182, 214, .11), 0 0 18px rgba(138, 182, 214, .08);
}

.pathbar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-top: 0;
}

.frequent {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(31, 41, 55, .84);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    padding: 16px 20px;
    max-height: none;
    align-self: start;
    overflow: visible;
}

.frequent[hidden] {
    display: none;
}

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

.frequent-head strong {
    color: var(--text);
}

#frequentCount {
    margin-left: 8px;
    color: var(--muted);
    font-size: 13px;
}

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

.frequent-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    min-height: 58px;
    padding: 10px 10px 10px 12px;
    border: 1px solid rgba(210, 198, 166, .12);
    border-radius: 8px;
    background: rgba(39, 50, 68, .78);
}

.frequent-card:hover {
    border-color: rgba(148, 199, 187, .24);
    background: rgba(50, 64, 84, .92);
}

.frequent-meta {
    min-width: 0;
}

.frequent-name {
    display: block;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-all;
    line-height: 1.45;
    color: var(--text);
    font-family: "JetBrains Mono", "Cascadia Mono", "Consolas", "Microsoft YaHei", monospace;
    font-size: 13px;
    font-weight: 600;
}

.frequent-info {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.frequent-meta .file-labels {
    margin-top: 7px;
    gap: 5px;
}

.frequent-copy {
    min-height: 32px;
    width: 100%;
    padding: 0 10px;
    justify-content: center;
    margin-top: 2px;
}

.path-btn {
    padding: 0 12px;
}

#breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.crumb {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result {
    border-top: 0;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    background: rgba(25, 35, 52, .88);
    position: relative;
    z-index: 1;
}

.result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

#resultCount {
    margin-left: 8px;
    color: var(--muted);
}

#nextBtn {
    padding: 0 14px;
}

.message {
    margin: 14px 20px 0;
    padding: 10px 12px;
    border: 1px solid rgba(251, 113, 133, .4);
    border-radius: 6px;
    background: rgba(127, 29, 29, .2);
    color: var(--danger);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    table-layout: fixed;
    padding: 0 12px 12px;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 600;
    background: rgba(31, 41, 55, .92);
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--line);
    padding-top: 12px;
    padding-bottom: 10px;
}

tbody td {
    background: rgba(34, 44, 60, .82);
    border-top: 1px solid rgba(210, 198, 166, .10);
    border-bottom: 1px solid rgba(210, 198, 166, .10);
}

tbody td:first-child {
    border-left: 1px solid rgba(210, 198, 166, .10);
    border-radius: 8px 0 0 8px;
}

tbody td:last-child {
    border-right: 1px solid rgba(210, 198, 166, .10);
    border-radius: 0 8px 8px 0;
}

tbody tr:nth-child(even) td {
    background: rgba(39, 50, 68, .82);
}

tbody tr:hover td {
    background: rgba(50, 64, 84, .92);
    border-color: rgba(148, 199, 187, .22);
}

td.name {
    word-break: break-all;
}

th:nth-child(2),
td:nth-child(2) {
    width: 104px;
    white-space: nowrap;
}

th:nth-child(3),
td:nth-child(3) {
    width: 176px;
    white-space: nowrap;
}

th:nth-child(4),
td:nth-child(4) {
    width: 150px;
    white-space: nowrap;
}

.muted {
    color: var(--muted);
}

mark {
    padding: 1px 2px;
    border-radius: 3px;
    background: rgba(207, 181, 111, .22);
    color: #ead9a8;
    box-shadow: 0 0 10px rgba(207, 181, 111, .08);
}

.file-main {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.file-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(148, 199, 187, .20);
    border-radius: 7px;
    background: rgba(148, 199, 187, .12);
    color: #bdd9cf;
}

.file-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.file-content {
    min-width: 0;
}

.file-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.file-label {
    min-height: 22px;
    padding: 0 7px;
    border: 1px solid rgba(138, 182, 214, .28);
    border-radius: 4px;
    background: rgba(138, 182, 214, .10);
    color: #c7d8e7;
    font-size: 12px;
}

.file-label.source {
    border-color: rgba(134, 199, 174, .28);
    background: rgba(134, 199, 174, .10);
    color: #c4ded2;
}

.file-label.build-id {
    border-color: rgba(200, 180, 126, .34);
    background: rgba(200, 180, 126, .12);
    color: #ead9a8;
}

.file-label.device {
    border-color: rgba(165, 180, 252, .30);
    background: rgba(99, 102, 241, .12);
    color: #c7d2fe;
}

.file-label.android {
    border-color: rgba(96, 165, 250, .30);
    background: rgba(59, 130, 246, .12);
    color: #bfdbfe;
}

.file-label.kernel {
    border-color: rgba(248, 113, 113, .28);
    background: rgba(239, 68, 68, .10);
    color: #fecaca;
}

.file-name {
    font-family: "JetBrains Mono", "Cascadia Mono", "Consolas", "SFMono-Regular", "Microsoft YaHei", monospace;
    font-weight: 600;
    line-height: 1.55;
    color: #f8fafc;
}

.title-device-label {
    display: inline-flex;
    align-items: center;
    max-width: 180px;
    margin-right: 8px;
    padding: 1px 7px;
    border: 1px solid rgba(165, 180, 252, .32);
    border-radius: 4px;
    background: rgba(99, 102, 241, .13);
    color: #d8defe;
    font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.6;
    vertical-align: 1px;
    overflow-wrap: anywhere;
}

.link-btn {
    width: 112px;
    justify-content: center;
    padding: 0 10px;
    min-height: 32px;
}

@media (max-width: 1450px) {
    .app-layout,
    body.has-frequent .app-layout {
        width: min(1180px, calc(100vw - 32px));
        margin: 24px auto;
        grid-template-columns: 1fr;
        gap: 0;
    }

    .frequent {
        position: static;
        border-radius: 0;
        border-top: 0;
    }
}

@media (max-width: 780px) {
    .app-layout {
        width: calc(100vw - 20px);
        margin: 10px auto;
    }

    .toolbar,
    .controls,
    .pathbar,
    .result-head {
        padding-left: 12px;
        padding-right: 12px;
    }

    .toolbar,
    .result-head {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

    .frequent-list {
        grid-template-columns: 1fr;
    }

    table {
        min-width: 760px;
    }

    .result {
        overflow-x: auto;
    }
}
