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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: rgba(30, 30, 30, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-blue: #1d9bf0;
    --accent-blue-hover: #1a8cd8;
    --border-color: rgba(255, 255, 255, 0.1);
    --counter-normal: #71767b;
    --counter-warning: #ffd400;
    --counter-danger: #f4212e;
    --glow-blue: rgba(29, 155, 240, 0.3);
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
            ellipse at 20% 20%,
            rgba(29, 155, 240, 0.15) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse at 80% 80%,
            rgba(120, 86, 255, 0.1) 0%,
            transparent 50%
        );
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px var(--glow-blue);
}

.logo-icon svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.logo-text {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #a0a0a0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Editor Card */
.editor-wrapper {
    position: relative;
}

.editor-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.editor-card:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 4px var(--glow-blue);
}

/* Header with Checkbox */
.editor-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    transition: color 0.2s;
}

.toggle-label:hover {
    color: var(--text-primary);
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: 0.3s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-blue);
}

input:checked + .slider:before {
    transform: translateX(16px);
    background-color: white;
}

/* Editor Content */
.editor-inner {
    display: flex;
    gap: 16px;
    padding: 24px;
}

.textarea-container {
    flex: 1;
    position: relative;
}

#threadInput {
    width: 100%;
    min-height: 300px;
    height: auto;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    line-height: 1.8;
    resize: none;
    outline: none;
    overflow: hidden;
    padding: 0;
    letter-spacing: normal;
    word-spacing: normal;
    overflow-wrap: break-word; /* Ensure wrapping matches mirror */
}

#threadInput::placeholder {
    color: var(--text-secondary);
}

/* Mirror for measurement */
.mirror {
    position: absolute;
    top: 0;
    left: 0;
    visibility: hidden;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.8;
    padding: 0;
    border: none;
    width: 100%;
    pointer-events: none;
    z-index: -100;
}

/* Right Column Counters */
.inline-counters {
    width: 150px;
    flex-shrink: 0;
    position: relative;
}

/* Widget: Copy Btn + Counter */
.inline-widget {
    position: absolute;
    right: 0;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    transform: translateY(-100%); /* Bottom aligns with yPos */
}

.copy-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    height: 32px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.copy-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex-shrink: 0;
}

.inline-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    height: 32px;
}

.inline-counter:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tweet-num {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--accent-blue), #7856ff);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.count {
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease;
}

.count.normal {
    color: var(--counter-normal);
}
.count.warning {
    color: var(--counter-warning);
}
.count.danger {
    color: var(--counter-danger);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Stats */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), #7856ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.empty-hint {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.6;
    text-align: right;
    line-height: 1.4;
    padding: 4px 0;
}

/* Instructions */
.instructions {
    margin-top: 32px;
    padding: 20px;
    background: rgba(29, 155, 240, 0.1);
    border: 1px solid rgba(29, 155, 240, 0.2);
    border-radius: 12px;
}

.instructions h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.instructions ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instructions li {
    font-size: 13px;
    color: var(--text-secondary);
    padding-left: 20px;
    position: relative;
}

.instructions li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent-blue);
}

/* Responsive */
@media (max-width: 600px) {
    .inline-counters {
        width: 90px;
    }
    .inline-counter {
        padding: 3px 6px;
    }
    .tweet-num {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
    .count {
        font-size: 10px;
    }
    .editor-header {
        padding: 12px 16px;
    }
    .toggle-label {
        font-size: 12px;
    }

    /* Compact Copy Button on Mobile */
    .copy-btn {
        padding: 0;
        width: 28px;
        height: 28px;
        justify-content: center;
    }
    .copy-btn span {
        display: none;
    }
}
