/* 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;
    color: #d4d8de;
    background: linear-gradient(135deg, #0d0d0f 0%, #171719 100%);
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Layout container — wide by default on desktop (Uto-qsxw) */
.container {
    max-width: 95vw;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
}

/* Header styling */
header {
    background: rgba(10, 10, 12, 0.97);
    text-align: center;
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.header-content {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
}

.site-logo {
    width: 90px;
    height: 90px;
    object-fit: contain;
    flex-shrink: 0;
}

header h1 {
    color: #8aafc8;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
}

header p {
    color: #7a8290;
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    header p {
        font-size: 1rem;
    }
}

/* Main content area */
main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    main {
        grid-template-columns: 1fr 1fr;
    }
}

/* Section styling */
section {
    background: rgba(18, 18, 20, 0.97);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
}

section h2 {
    color: #8aafc8;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

section > p,
section > label {
    color: #7a8290;
    margin-bottom: 1rem;
    display: block;
}

/* =====================================================
   Advanced Settings Panel
   ===================================================== */

.adv-panel {
    grid-column: 1 / -1;
    padding: 0;
    overflow: hidden;
}

.adv-toggle-btn {
    background: none;
    border: none;
    border-radius: 10px;
    width: 100%;
    text-align: left;
    padding: 1rem 2rem;
    color: #8aafc8;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transform: none;
    box-shadow: none;
}

.adv-toggle-btn:hover {
    background: rgba(138, 175, 200, 0.08);
    transform: none;
    box-shadow: none;
}

.adv-toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.adv-toggle-btn[aria-expanded="true"] .adv-toggle-icon {
    transform: rotate(90deg);
}

#adv-content[hidden] {
    display: none;
}

#adv-content {
    padding: 0 2rem 1.5rem;
    border-top: 1px solid #2a2a2e;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0 2rem;
}

.adv-group-title {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 700;
    color: #7a8290;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 1rem 0 0.5rem;
}

.adv-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.adv-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #d4d8de;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 0;
}

.adv-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #8aafc8;
    cursor: pointer;
    flex-shrink: 0;
}

.adv-group input[type="number"] {
    width: 56px;
    padding: 0.15rem 0.4rem;
    border: 1px solid #2a2a2e;
    border-radius: 4px;
    background: #0d0d0f;
    color: #d4d8de;
    font-size: 0.9rem;
    text-align: center;
}

/* Parent-child checkbox groups in Show/Hide */
.adv-parent-group {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.adv-children {
    display: flex;
    flex-direction: column;
    padding-left: 1.6rem;
}

.adv-child-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0;
}

.adv-child-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #b8bec8;
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 0;
}

.adv-child-group input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #8aafc8;
    cursor: pointer;
    flex-shrink: 0;
}

.adv-children.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Section order list */
.section-order-list {
    list-style: none;
    padding: 0;
    margin: 0;
    grid-column: 1 / -1;
}

.section-order-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    color: #d4d8de;
    font-size: 0.9rem;
}

.section-order-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #8aafc8;
    cursor: pointer;
    flex-shrink: 0;
}

.order-btn {
    background: rgba(138, 175, 200, 0.12);
    border: 1px solid rgba(138, 175, 200, 0.3);
    border-radius: 4px;
    color: #8aafc8;
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transform: none;
    box-shadow: none;
    min-width: unset;
    min-height: unset;
    line-height: 1;
}

.order-btn:hover {
    background: rgba(138, 175, 200, 0.22);
    transform: none;
    box-shadow: none;
}

.order-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mobile */
@media (max-width: 768px) {
    .adv-toggle-btn {
        padding: 1rem 1.5rem;
    }

    #adv-content {
        padding: 0 1.5rem 1.5rem;
        grid-template-columns: 1fr;
    }
}

/* Auto-detect badge */
.detect-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 12px;
    background: rgba(138, 175, 200, 0.15);
    color: #8aafc8;
    border: 1px solid rgba(138, 175, 200, 0.35);
    margin-top: 0.5rem;
}

/* Focus indicators — keyboard navigation */
button:focus-visible,
input:focus-visible,
details > summary:focus-visible {
    outline: 3px solid #8aafc8;
    outline-offset: 2px;
}

textarea:focus-visible {
    outline: 2px solid #8aafc8;
    outline-offset: 2px;
}

/* Textarea styling */
textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid #2a2a2e;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    background-color: #141416;
    color: #d4d8de;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

@media (max-width: 768px) {
    textarea {
        font-size: 16px;
        padding: 0.75rem;
        min-height: 120px;
    }
}

textarea:focus {
    outline: none;
    border-color: #8aafc8;
    box-shadow: 0 0 0 3px rgba(138, 175, 200, 0.2);
}

textarea[readonly] {
    background-color: #0d0d0f;
    color: #d4d8de;
    white-space: pre-wrap;
    word-wrap: break-word;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Button styling */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .button-group {
        gap: 0.75rem;
    }
}

button {
    background: linear-gradient(135deg, #4a7a9b 0%, #2d5470 100%);
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (max-width: 768px) {
    button {
        padding: 1rem;
        font-size: 1.1rem;
        min-height: 44px;
        min-width: 44px;
    }
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(138, 175, 200, 0.4);
}

button:active {
    transform: translateY(0);
}

#clear-btn {
    background: linear-gradient(135deg, #c53030 0%, #8b2323 100%);
    color: #fff;
}

#copy-btn {
    background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
    color: #fff;
}

#discord-copy-btn {
    background: linear-gradient(135deg, #3c3263 0%, #5c4d9a 100%);
    color: #e0d9ff;
}

/* Feedback message */
.feedback {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
}

.feedback.hidden {
    display: none;
}

.feedback:not(.hidden) {
    background: #1c2e1c;
    color: #68d391;
    border: 1px solid #2d4a2d;
}

.feedback:not(.hidden):has([style*="fed7d7"]) {
    background: #2e1a1a;
    color: #fc8181;
    border: 1px solid #742a2a;
}

.feedback:not(.hidden):has([style*="feebc8"]) {
    background: #2e2014;
    color: #f6ad55;
    border: 1px solid #744210;
}

/* Keyboard shortcuts hint */
.kbd-shortcuts {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #7a8290;
}

.kbd-shortcuts summary {
    cursor: pointer;
    color: #7a8290;
    user-select: none;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.kbd-shortcuts summary::-webkit-details-marker {
    display: none;
}

.kbd-shortcuts summary::before {
    content: '▶';
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.kbd-shortcuts[open] summary::before {
    transform: rotate(90deg);
}

.kbd-shortcuts summary:hover {
    color: #8aafc8;
}

.kbd-shortcuts ul {
    list-style: none;
    margin-top: 0.5rem;
    padding-left: 0.75rem;
}

.kbd-shortcuts li {
    padding: 0.2rem 0;
    color: #7a8290;
}

kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    font-size: 0.8rem;
    border: 1px solid #2a2a2e;
    border-radius: 3px;
    background: #0d0d0f;
    color: #8aafc8;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

/* Footer styling */
footer {
    background: rgba(10, 10, 12, 0.97);
    text-align: center;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    color: #7a8290;
}

/* Utility classes */
.hidden {
    display: none !important;
}

@media (max-width: 768px) and (orientation: portrait) {
    .site-logo {
        display: none;
    }
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    section {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    section h2 {
        font-size: 1.3rem;
    }

    section p,
    section label {
        font-size: 0.95rem;
    }

    /* Enhanced text selection for mobile copy-paste */
    textarea[readonly] {
        font-size: 16px;
        line-height: 1.5;
        padding: 0.75rem;
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
        -webkit-touch-callout: default;
    }

    /* Feedback message adjustments for mobile */
    .feedback {
        font-size: 0.9rem;
        padding: 1rem;
        text-align: center;
    }

    /* Expand order button touch targets to 44×44 on mobile */
    .order-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }
}

/* Footer link — GitHub Issues (Uto-htd9) */
.footer-issues {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.footer-issues a {
    color: #7a8290;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.footer-issues a:hover {
    color: #8aafc8;
}

/* Reduced motion — disable transitions and animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}
