:root {
    --bg: #0f1115;
    --panel: #171a21;
    --border: #2a2e38;
    --text: #e8e9ed;
    --muted: #8a8f9c;
    --accent: #6c8cff;
    --accent-hover: #5578ef;
    --good: #34c77b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 6px;
}

p.subtitle {
    color: var(--muted);
    margin: 0 0 28px;
    font-size: 0.9rem;
}

.container {
    width: 100%;
    max-width: 1000px;
}

.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 720px) {
    body {
        padding: 24px 14px;
    }

    h1 {
        font-size: 1.2rem;
    }

    p.subtitle {
        margin-bottom: 20px;
        font-size: 0.85rem;
        text-align: center;
    }

    .panels {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .panel {
        padding: 12px;
    }

    textarea {
        min-height: 200px;
        font-size: 16px;
        /* prevents iOS auto-zoom on focus */
    }

    .actions {
        flex-direction: column;
        gap: 10px;
        margin: 18px 0 4px;
    }

    #fixBtn,
    .secondary-btn {
        width: 100%;
        padding: 14px 20px;
    }

    .header-actions {
        gap: 6px;
    }

    .copy-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .icon-btn {
        width: 28px;
        height: 28px;
    }

    .info-popup {
        right: -12px;
        max-width: calc(100vw - 60px);
    }
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

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

.panel-header label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

textarea {
    width: 100%;
    min-height: 340px;
    resize: vertical;
    background: #0f1115;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    font-family: inherit;
}

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

textarea[readonly] {
    background: #12141a;
    color: var(--text);
}

.placeholder-text {
    color: var(--muted);
    font-size: 0.9rem;
}

.actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin: 22px 0;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease, transform 0.05s ease;
}

button:active {
    transform: scale(0.98);
}

#fixBtn {
    background: var(--accent);
    color: white;
    padding: 12px 32px;
    font-size: 1rem;
}

#fixBtn:hover {
    background: var(--accent-hover);
}

#fixBtn:disabled {
    background: var(--border);
    color: var(--muted);
    cursor: not-allowed;
}

.secondary-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 12px 24px;
    font-size: 0.9rem;
}

.secondary-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.copy-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.copy-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.copy-btn.copied {
    color: var(--good);
    border-color: var(--good);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-wrap {
    position: relative;
    display: inline-block;
}

.icon-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-style: italic;
    font-family: Georgia, serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.icon-btn:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--accent);
}

.icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.icon-btn.has-changes {
    color: var(--accent);
    border-color: var(--accent);
}

.info-popup {
    display: none;
    position: absolute;
    top: 30px;
    right: 0;
    z-index: 10;
    min-width: 220px;
    max-width: 300px;
    background: #1d2029;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 0.82rem;
}

.info-popup.open {
    display: block;
}

.info-popup .info-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.info-popup .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    color: var(--muted);
}

.info-popup .info-row .from-to {
    font-family: "SF Mono", Consolas, Menlo, monospace;
    color: var(--text);
    overflow-wrap: anywhere;
}

.info-popup .info-row .count {
    flex-shrink: 0;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: 10px;
}

.info-popup .info-empty {
    color: var(--muted);
}