/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main content */
main {
    flex: 1;
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

/* Input section */
.input-section {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #4a5568;
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    background: #f8fafc;
}

textarea:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
    background: white;
}

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

#lineCount {
    font-weight: 600;
    color: #4285f4;
}

.note {
    color: #6b7280;
    font-style: italic;
}

/* Buttons */
.button-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn {
    background: linear-gradient(45deg, #4285f4, #34a853);
    color: white;
    flex: 1;
    min-width: 200px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(66, 133, 244, 0.4);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    background: #f1f3f4;
    color: #5f6368;
    border: 1px solid #dadce0;
}

.secondary-btn:hover {
    background: #e8eaed;
    transform: translateY(-1px);
}

.copy-btn {
    background: #34a853;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.copy-btn:hover {
    background: #2d8a47;
    transform: translateY(-1px);
}

.open-all-btn {
    background: linear-gradient(45deg, #ff6b6b, #ffa500);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.open-all-btn:hover {
    background: linear-gradient(45deg, #ff5252, #ff9800);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.3);
}

.open-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
/* Advanced panel */
.advanced-panel { background:#f8fafc; border:1px solid #e2e8f0; border-radius:12px; padding:1rem 1rem 0.5rem; margin-bottom:1rem; animation: slideIn 0.4s ease; }
.advanced-row { display:flex; flex-wrap:wrap; align-items:center; gap:0.75rem; margin-bottom:0.75rem; }
.output-buttons.compact { gap:0.5rem; }
.advanced-panel .automation-btn, .advanced-panel .bookmarklet-btn { padding:0.4rem 0.8rem; font-size:0.75rem; }
.advanced-panel .lang-btn { padding:0.4rem 0.8rem; font-size:0.75rem; }
.lang-btn { background:#1e3a8a; color:#fff; }
.lang-btn:hover { background:#1e40af; }
.delay-setting { display:flex; align-items:center; gap:0.4rem; flex-wrap:wrap; }
.delay-label,.maxcount-label { font-size:0.75rem; color:#555; }
.delay-input { width:90px; padding:0.4rem 0.5rem; border:1px solid #cbd5e1; border-radius:6px; font-size:0.85rem; }
.maxcount-input { width:70px; padding:0.4rem 0.5rem; border:1px solid #cbd5e1; border-radius:6px; font-size:0.85rem; }
.delay-input:focus { outline:none; border-color:#4285f4; box-shadow:0 0 0 2px rgba(66,133,244,.15); }
.maxcount-input:focus { outline:none; border-color:#34a853; box-shadow:0 0 0 2px rgba(52,168,83,.15); }
.script-preview-wrapper { background:#f1f5f9; border:1px solid #e2e8f0; border-radius:12px; padding:1rem; margin-top:1rem; }
.script-preview { max-height:260px; overflow:auto; background:#0f172a; color:#e2e8f0; padding:0.75rem; border-radius:8px; font-size:0.75rem; line-height:1.3; }
.script-preview.collapsed { display:none; }
.preview-title { margin:0 0 0.5rem 0; font-size:0.95rem; color:#374151; }
.preview-controls { display:flex; gap:0.5rem; margin-bottom:0.5rem; flex-wrap:wrap; }
.small-btn { padding:0.4rem 0.8rem; font-size:0.75rem; }

/* Error message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: #dc2626;
    font-weight: 500;
}

/* Output section */
.output-section {
    margin-top: 1.5rem;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 1rem;
}

.output-header h3 {
    color: #374151;
    font-size: 1.25rem;
    margin: 0;
}

.output-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.output-list {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom scrollbar */
.output-list::-webkit-scrollbar {
    width: 6px;
}

.output-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.output-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.output-list::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Output items */
.output-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.output-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateX(4px);
}

.prompt-number {
    font-weight: 700;
    color: #4285f4;
    font-size: 1.1rem;
}

.prompt-text {
    margin: 0.25rem 0 0.5rem 0;
    color: #374151;
    line-height: 1.5;
}

.prompt-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #4285f4;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    background: rgba(66, 133, 244, 0.1);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.prompt-link:hover {
    background: rgba(66, 133, 244, 0.2);
    transform: translateY(-1px);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* Success message */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
    z-index: 1000;
    animation: slideInRight 0.5s ease, fadeOut 0.5s ease 2.5s forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 1.5rem;
        margin: 0;
    }
    
    .button-section {
        flex-direction: column;
    }
    
    .primary-btn,
    .secondary-btn {
        min-width: auto;
    }
    
    .output-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .output-buttons {
        justify-content: space-between;
    }
    
    .copy-btn,
    .open-all-btn {
        flex: 1;
        text-align: center;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    main {
        padding: 1rem;
    }
    
    textarea {
        font-size: 0.9rem;
    }
    
    .input-info {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }
}

/* Loading state */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Popup help styles */
.popup-help,
.popup-instructions,
.sequential-open {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    animation: slideIn 0.3s ease;
}

.help-content h4,
.instruction-content h4,
.sequential-content h4 {
    color: #856404;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.solution-buttons {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.solution-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.solution-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.help-instructions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f0e68c;
}

.help-instructions ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.help-instructions li {
    margin: 0.25rem 0;
    color: #6c757d;
}

/* Sequential open styles */
.sequential-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.sequential-link-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sequential-link-btn:hover:not(:disabled) {
    background: #0056b3;
    transform: translateX(4px);
}

.sequential-link-btn.opened {
    background: #28a745;
    cursor: default;
}

.sequential-link-btn:disabled {
    opacity: 0.7;
    cursor: default;
}

.sequential-note {
    font-size: 0.85rem;
    color: #6c757d;
    font-style: italic;
    margin: 0.5rem 0 0 0;
}

/* Instruction content styles */
.instruction-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.instruction-content li {
    margin: 0.5rem 0;
    color: #495057;
}

/* Mobile responsiveness for new elements */
@media (max-width: 768px) {
    .solution-buttons {
        flex-direction: column;
    }
    
    .solution-btn {
        width: 100%;
    }
    
    .sequential-buttons {
        max-height: 250px;
    }
    
    .sequential-link-btn {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }
}