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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    color: #333;
    padding: 40px 20px;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border: 1px solid #e0e0e0;
    padding: 40px;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 30px;
    color: #111;
}

h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #111;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d0d0d0;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
    background: #fafafa;
}

textarea:focus {
    outline: none;
    border-color: #888;
    background: white;
}

select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d0d0d0;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #888;
}

button {
    width: 100%;
    padding: 12px;
    background: #111;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #333;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 12px;
}

.level-badge {
    display: inline-block;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #d0d0d0;
    background: #fafafa;
    color: #555;
}

.mode-toggle-group {
    display: inline-flex;
    border: 1px solid #d0d0d0;
}

.mode-toggle-btn {
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.mode-toggle-btn:first-child {
    border-right: 1px solid #d0d0d0;
}

.mode-toggle-btn:hover:not(.active) {
    background: #f5f5f5;
}

.mode-toggle-btn.active {
    background: #111;
    color: white;
}

.mode-toggle-btn.loading {
    opacity: 0.6;
    cursor: wait;
}

.instruction {
    font-size: 13px;
    color: #888;
    margin-bottom: 20px;
}

.code-container {
    border: 1px solid #e0e0e0;
    background: #fafafa;
    margin-bottom: 30px;
}

.code-line {
    display: flex;
    border-bottom: 1px solid #eee;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
}

.code-line:last-child {
    border-bottom: none;
}

.line-number {
    padding: 8px 12px;
    background: #f0f0f0;
    color: #999;
    text-align: right;
    min-width: 50px;
    user-select: none;
    border-right: 1px solid #e0e0e0;
}

.line-content {
    padding: 8px 12px;
    flex: 1;
    white-space: pre;
    overflow-x: auto;
    background: white;
}

.highlight {
    padding: 1px 4px;
    border-radius: 3px;
    cursor: help;
    font-weight: 600;
    transition: opacity 0.2s;
}

.highlight:hover {
    opacity: 0.8;
}

.ai-line-highlight {
    cursor: help;
    background-color: rgba(152, 195, 121, 0.15);
    border-left: 2px solid #98c379;
    padding-left: 4px;
    margin-left: -6px;
    transition: background-color 0.2s;
}

.ai-line-highlight:hover {
    background-color: rgba(152, 195, 121, 0.3);
}

.custom-tooltip {
    position: absolute;
    background: #111;
    color: white;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: normal;
    white-space: normal;
    max-width: 300px;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    z-index: 99999;
    transition: opacity 0.2s, visibility 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
    transform: translateX(-50%);
}

/* Active state for tapped elements on mobile */
.highlight.tooltip-active {
    opacity: 0.8;
}

.ai-line-highlight.tooltip-active {
    background-color: rgba(152, 195, 121, 0.3);
}

/* Mobile-specific adjustments */
@media (max-width: 600px) {
    .custom-tooltip {
        max-width: calc(100vw - 40px);
        min-width: 120px;
        font-size: 13px;
        padding: 12px 16px;
    }
}

.ai-explanation-box {
    background: #f8f9fa;
    border-left: 3px solid #61afef;
    padding: 20px;
    margin-bottom: 30px;
    line-height: 1.7;
    font-size: 14px;
    white-space: pre-wrap;
    color: #444;
}

.ai-explanation-box strong {
    color: #333;
    font-weight: 600;
}

.ai-explanation-box code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    color: #d63384;
}

.ai-explanation-box .arrow {
    color: #61afef;
    font-weight: bold;
    padding: 0 4px;
}

.ai-explanation-box .ai-list {
    margin: 10px 0;
    padding-left: 20px;
    list-style: none;
}

.ai-explanation-box .ai-list li {
    position: relative;
    padding-left: 15px;
    margin-bottom: 8px;
}

.ai-explanation-box .ai-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #61afef;
    font-weight: bold;
}

.ai-explanation-box .summary-conclusion {
    margin-top: 15px;
    font-weight: 500;
    color: #333;
}

.ai-explanation-box .summary-quote {
    background: #fff;
    border-left: 3px solid #98c379;
    padding: 12px 15px;
    margin: 10px 0;
    font-style: italic;
    color: #555;
}

.back-link {
    display: inline-block;
    color: #111;
    text-decoration: none;
    font-size: 14px;
    padding-bottom: 2px;
    border-bottom: 1px solid #111;
}

.back-link:hover {
    color: #555;
    border-color: #555;
}

.examples {
    margin-bottom: 20px;
}

.examples p {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.example-btn {
    width: auto;
    padding: 8px 16px;
    margin-right: 8px;
    margin-bottom: 8px;
    background: #666;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.example-btn:hover {
    background: #888;
}

.error-message {
    background: #fff0f0;
    border: 1px solid #ffcccc;
    padding: 12px;
    margin-bottom: 20px;
    color: #cc0000;
    font-size: 14px;
}

footer {
    max-width: 800px;
    margin: 30px auto 0;
    padding-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #999;
}

footer a {
    color: #666;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}
