@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
    --paper: #f3f0e8;
    --paper-deep: #e9e5db;
    --ink: #171815;
    --muted: #69695f;
    --line: #c8c5ba;
    --card: #faf8f1;
    --accent: #c8ff2e;
    --accent-deep: #9ece15;
    --orange: #ff6433;
    --code: #20211e;
    --code-text: #e8e9df;
    --shadow: 0 18px 60px rgba(37, 35, 26, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background:
        linear-gradient(rgba(24, 24, 20, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(24, 24, 20, 0.025) 1px, transparent 1px),
        var(--paper);
    background-size: 32px 32px;
    font-family: "IBM Plex Sans Thai", "Noto Sans Thai", sans-serif;
    transition: color .2s ease, background-color .2s ease;
}

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

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

.topbar {
    min-height: 78px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    width: fit-content;
    gap: 10px;
    align-items: center;
    color: inherit;
    text-decoration: none;
    font-family: "IBM Plex Mono", monospace;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .14em;
}

.brand-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    color: #111;
    background: var(--accent);
    border: 1px solid var(--ink);
    font-size: 16px;
    letter-spacing: 0;
    transform: rotate(-3deg);
}

.product-label,
.panel-index,
.shortcut-hint,
.page-foot,
.status-badge,
.match-type {
    font-family: "IBM Plex Mono", monospace;
    letter-spacing: .08em;
}

.product-label { margin: 0; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.text-button, .icon-button, .small-button, .line-link, .path-box button {
    border: 0;
    background: transparent;
    cursor: pointer;
}
.text-button { padding: 8px 4px; border-bottom: 1px solid currentColor; font-size: 13px; }
.icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    font-size: 18px;
}

.intro {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr);
    align-items: end;
    gap: 60px;
    padding: 64px 0 45px;
}

.eyebrow {
    margin: 0 0 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
}
.eyebrow span { width: 28px; height: 2px; background: var(--orange); }
h1 {
    max-width: 900px;
    margin: 0;
    font-size: clamp(43px, 5.6vw, 84px);
    font-weight: 600;
    line-height: .97;
    letter-spacing: -.055em;
}
h1 em { color: var(--muted); font-weight: 400; }
.intro-copy { margin: 0 0 5px; max-width: 470px; color: var(--muted); font-size: 15px; line-height: 1.85; }

.search-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 13px;
    background: var(--ink);
    box-shadow: var(--shadow);
}
.search-box { display: flex; align-items: center; gap: 15px; min-width: 0; padding: 0 18px; background: #fff; }
.search-icon { width: 17px; height: 17px; flex: 0 0 auto; border: 2px solid #222; border-radius: 50%; position: relative; }
.search-icon::after { content: ""; position: absolute; width: 7px; height: 2px; right: -6px; bottom: -3px; background: #222; transform: rotate(45deg); }
.search-box input { width: 100%; min-width: 0; height: 58px; border: 0; outline: 0; color: #171815; background: transparent; font-family: "IBM Plex Mono", monospace; font-size: clamp(13px, 1.5vw, 18px); }
kbd { padding: 3px 6px; color: var(--muted); background: var(--paper-deep); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; font-family: "IBM Plex Mono", monospace; font-size: 10px; white-space: nowrap; }
.search-button {
    min-width: 150px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    border: 1px solid var(--accent);
    color: #10110f;
    background: var(--accent);
    cursor: pointer;
    font-weight: 700;
    transition: transform .16s ease, background .16s ease;
}
.search-button:hover { background: #d5ff61; transform: translateY(-2px); }
.search-button span { font-size: 22px; }

.toolbar {
    min-height: 63px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--line);
}
.filter-group { display: flex; flex-wrap: wrap; gap: 22px; }
.check-control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; font-size: 12px; }
.check-control input { position: absolute; opacity: 0; }
.check-control > span { width: 15px; height: 15px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--card); }
.check-control input:checked + span { background: var(--ink); border-color: var(--ink); }
.check-control input:checked + span::after { content: "✓"; color: var(--accent); font-size: 11px; }
.shortcut-hint { margin: 0; color: var(--muted); font-size: 9px; }

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.32fr) minmax(380px, .68fr);
    min-height: 690px;
    margin: 36px 0;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.data-panel, .results-panel { min-width: 0; display: flex; flex-direction: column; }
.data-panel { border-right: 1px solid var(--line); }
.panel-head {
    min-height: 89px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}
.panel-index { margin: 0 0 4px; color: var(--orange); font-size: 9px; }
.panel-head h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.source-actions { display: flex; align-items: center; gap: 8px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; color: #38560d; background: #e5f9b7; border-radius: 999px; font-size: 8px; white-space: nowrap; }
.status-badge i { width: 6px; height: 6px; background: #5e8d13; border-radius: 50%; }
.status-badge.invalid { color: #87351d; background: #ffe0d5; }
.status-badge.invalid i { background: var(--orange); }
.small-button { padding: 6px 8px; color: var(--muted); font-size: 11px; }
.small-button:hover { color: var(--ink); background: var(--paper-deep); }
.small-button.danger:hover { color: #b53014; }

.editor-wrap { min-height: 535px; flex: 1; display: grid; grid-template-columns: 54px minmax(0, 1fr); position: relative; overflow: hidden; background: var(--code); }
.line-numbers { height: 100%; max-height: 590px; padding: 18px 12px; overflow: hidden; border-right: 1px solid #353631; color: #6f7168; font: 12px/24px "IBM Plex Mono", monospace; text-align: right; user-select: none; }
.line-numbers span { display: block; }
.editor-code-pane { min-width: 0; min-height: 535px; position: relative; overflow: hidden; }
.source-highlight-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.source-highlight-layer pre { width: max-content; min-width: 100%; min-height: 100%; margin: 0; padding: 18px 22px; color: var(--code-text); background: transparent; font: 12px/24px "IBM Plex Mono", monospace; tab-size: 2; white-space: pre; transform-origin: top left; will-change: transform; }
.source-highlight-layer mark { padding: 1px 0; color: #10110f; background: var(--accent); box-shadow: 0 0 0 2px var(--accent); border-radius: 1px; }
.editor-wrap textarea { width: 100%; height: 100%; min-height: 535px; position: relative; z-index: 1; padding: 18px 22px; resize: none; border: 0; outline: 0; color: var(--code-text); background: transparent; caret-color: var(--accent); font: 12px/24px "IBM Plex Mono", monospace; tab-size: 2; white-space: pre; }
.editor-wrap.has-source-highlights textarea { color: transparent; -webkit-text-fill-color: transparent; }
.editor-wrap textarea::selection { background: rgba(200, 255, 46, .35); }
.drop-message { position: absolute; inset: 14px; display: none; place-items: center; border: 1px dashed var(--accent); color: var(--accent); background: rgba(32, 33, 30, .92); font: 13px "IBM Plex Mono", monospace; z-index: 3; }
.editor-wrap.is-dragging .drop-message { display: grid; }
.panel-foot { min-height: 58px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); border-top: 1px solid var(--line); font: 10px "IBM Plex Mono", monospace; }
.file-button { padding: 7px 10px; color: var(--ink); border: 1px solid var(--line); cursor: pointer; }
.file-button:hover { background: var(--paper-deep); }
#fileInput { display: none; }

.result-count { min-width: 42px; height: 42px; display: grid; place-items: center; color: #111; background: var(--accent); border-radius: 50%; font: 600 13px "IBM Plex Mono", monospace; }
.results-body { min-height: 593px; flex: 1; background: var(--paper-deep); overflow: auto; }
.empty-state { min-height: 590px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--muted); text-align: center; }
.empty-glyph { width: 74px; height: 74px; display: grid; place-items: center; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--card); font: 38px "IBM Plex Mono", monospace; }
.empty-state h3 { margin: 0 0 8px; color: var(--ink); font-size: 18px; }
.empty-state p { margin: 0; font-size: 12px; line-height: 1.8; }
.no-result .empty-glyph { color: var(--orange); }
.result-summary { min-height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.result-summary strong, .result-summary span { display: block; }
.result-summary strong { margin-bottom: 2px; font-size: 14px; }
.result-summary div span { color: var(--muted); font: 10px "IBM Plex Mono", monospace; overflow-wrap: anywhere; }
.success-mark { width: 30px; height: 30px; display: grid !important; place-items: center; background: var(--accent); border-radius: 50%; font-weight: 700; }
.result-list { padding: 14px; }
.result-card { margin-bottom: 12px; background: var(--card); border: 1px solid var(--line); cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.result-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(25, 24, 20, .08); }
.result-card.is-active { border-color: var(--accent-deep); box-shadow: 0 0 0 2px var(--accent), 0 10px 28px rgba(25, 24, 20, .08); }
.result-card-head { min-height: 38px; display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-bottom: 1px solid var(--line); }
.match-number { color: var(--orange); font: 600 10px "IBM Plex Mono", monospace; }
.match-type { color: var(--muted); font-size: 8px; }
.line-link { margin-left: auto; color: var(--muted); font: 9px "IBM Plex Mono", monospace; }
.line-link:hover { color: var(--ink); text-decoration: underline; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; padding: 12px 14px 4px; color: var(--muted); font: 9px "IBM Plex Mono", monospace; }
.breadcrumb span:last-child { color: var(--ink); font-weight: 600; }
.breadcrumb b { color: var(--orange); font-weight: 400; }
.match-preview { margin: 8px 14px 13px; padding: 12px; display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 6px; color: var(--code-text); background: var(--code); font: 11px/1.6 "IBM Plex Mono", monospace; }
.property-name { color: #a8d7ff; overflow-wrap: anywhere; }
.property-separator { color: #777a70; }
.match-preview code { overflow-wrap: anywhere; }
mark { padding: 1px 2px; color: #111; background: var(--accent); }
.path-box { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 14px; border-top: 1px solid var(--line); }
.path-box code { min-width: 0; color: var(--muted); font: 9px/1.5 "IBM Plex Mono", monospace; overflow-wrap: anywhere; }
.path-box button { flex: 0 0 auto; padding: 5px 7px; color: var(--ink); border: 1px solid var(--line); font-size: 9px; }
.path-box button:hover { background: var(--accent); border-color: var(--accent-deep); }

.page-foot { min-height: 70px; display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; color: var(--muted); border-top: 1px solid var(--line); font-size: 8px; }
.page-foot p { margin: 16px 0; }

.dark-theme {
    --paper: #161714;
    --paper-deep: #20211d;
    --ink: #eeeee5;
    --muted: #a3a49a;
    --line: #3b3c36;
    --card: #252620;
    --code: #0f100e;
    --code-text: #e8e9df;
    --shadow: 0 18px 60px rgba(0, 0, 0, .22);
}
.dark-theme .search-panel { background: #050604; }
.dark-theme .search-box { background: #eeeee5; }
.dark-theme .brand-mark, .dark-theme .result-count, .dark-theme .success-mark { color: #111; }
.dark-theme .file-button { color: var(--ink); }
.dark-theme .status-badge { color: #c6ee72; background: #293614; }
.dark-theme .status-badge.invalid { color: #ff9b7c; background: #3c241d; }

@media (max-width: 980px) {
    .intro { grid-template-columns: 1fr; gap: 24px; padding-top: 46px; }
    .workspace { grid-template-columns: 1fr; }
    .data-panel { border-right: 0; border-bottom: 1px solid var(--line); }
    .results-body { min-height: 480px; }
    .empty-state { min-height: 480px; }
}

@media (max-width: 680px) {
    .app-shell { width: min(100% - 24px, 1500px); }
    .topbar { grid-template-columns: 1fr auto; }
    .product-label { display: none; }
    .text-button { display: none; }
    .intro { padding: 38px 0 30px; }
    h1 { font-size: clamp(39px, 13vw, 58px); }
    .search-panel { grid-template-columns: 1fr; }
    .search-button { min-height: 52px; }
    .search-box kbd { display: none; }
    .toolbar { align-items: flex-start; padding: 15px 0; }
    .shortcut-hint { display: none; }
    .filter-group { gap: 12px 18px; }
    .workspace { margin-top: 22px; }
    .panel-head { align-items: flex-start; flex-direction: column; }
    .source-actions { width: 100%; flex-wrap: wrap; }
    .editor-wrap { grid-template-columns: 42px minmax(0, 1fr); }
    .editor-wrap textarea { padding-inline: 14px; }
    .source-highlight-layer pre { padding-inline: 14px; }
    .panel-foot { padding-inline: 14px; }
    .page-foot { flex-direction: column; gap: 0; padding-bottom: 10px; }
    .page-foot p { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; }
}
