:root {
    --primary-color: #0066ff;
    --primary-hover: #0052cc;
    --success-color: #36b37e;
    --error-color: #ff5630;
    --warning-color: #ffab00;
    --background: #ffffff;
    --surface: #f4f5f7;
    --border: #dfe1e6;
    --text-primary: #172b4d;
    --text-secondary: #6b778c;
    --code-bg: #091e420a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 8px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--background);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
    color: white;
    padding: 40px;
    text-align: center;
    position: relative;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.logo {
    font-size: 3rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 20px;
}

.lang-switcher {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.lang-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.lang-btn.active {
    background: white;
    color: var(--primary-color);
}

main {
    padding: 40px;
}

.input-section {
    display: grid;
    gap: 30px;
    margin-bottom: 40px;
}

.input-group {
    position: relative;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 1rem;
}

.toolbar {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: var(--background);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

textarea {
    width: 100%;
    min-height: 250px;
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.3s ease;
    background: var(--surface);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--background);
}

.xpath-section {
    margin-top: 20px;
}

.xpath-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

input[type="text"] {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--surface);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--background);
}

.btn-primary {
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.options {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.quick-examples {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.example-btn {
    padding: 6px 12px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.example-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.results-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 40px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.results-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.result-info {
    display: flex;
    gap: 20px;
    font-size: 0.95rem;
}

.match-count {
    font-weight: 600;
    color: var(--success-color);
}

.match-count.error {
    color: var(--error-color);
}

.execution-time {
    color: var(--text-secondary);
}

.result-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-color);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.tab-panel {
    display: none;
    min-height: 200px;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.match-item, .tree-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 15px;
    overflow: hidden;
}

.match-header, .tree-header {
    background: var(--code-bg);
    padding: 10px 15px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.match-content, pre {
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.tree-node {
    padding: 2px 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.tree-tag {
    color: var(--primary-color);
    font-weight: 600;
}

.tree-attr {
    color: var(--warning-color);
}

.tree-text {
    color: var(--text-primary);
    margin: 0 5px;
}

.text-values {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
}

.no-matches, .error-message {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.error-message {
    color: var(--error-color);
    background: #ff563010;
    border: 1px solid #ff563030;
    border-radius: var(--radius);
    padding: 20px;
}

.help-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 40px;
}

.help-section h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.help-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.3s ease;
}

.help-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.help-card h4 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.help-card ul {
    list-style: none;
}

.help-card li {
    padding: 5px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.help-card code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
}

footer {
    text-align: center;
    padding: 30px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        border-radius: 0;
    }
    
    body {
        padding: 0;
    }
    
    header {
        padding: 30px 20px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 20px;
    }
    
    .xpath-input-container {
        flex-direction: column;
    }
    
    .help-grid {
        grid-template-columns: 1fr;
    }
    
    .lang-switcher {
        flex-wrap: wrap;
    }
    
    .quick-examples {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1e1e1e;
        --surface: #2d2d2d;
        --border: #404040;
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --code-bg: #3a3a3a;
    }
    
    body {
        background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    }
    
    textarea, input[type="text"] {
        background: var(--surface);
        color: var(--text-primary);
    }
    
    .btn-small {
        background: var(--surface);
        color: var(--text-primary);
    }
    
    .example-btn {
        background: var(--surface);
        color: var(--text-primary);
    }
}