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

body {
    font-family: 'Source Serif 4', Georgia, serif;
    line-height: 1.6;
    color: #333;
    background: #f8f7f4;
    min-height: 100vh;
    padding: 20px;
}

.back-link {
    color: #6366F1;
    text-decoration: none;
    font-size: 0.95rem;
    margin-bottom: 0;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    display: block;
}

.back-link:hover {
    color: #4F46E5;
}

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

header {
    text-align: center;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.tagline {
    color: #5a5a5a;
    font-size: 1.1rem;
    letter-spacing: 0.01em;
}

.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-left: 0.25rem;
    padding: 0.2rem;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #aaa;
    cursor: pointer;
    transition: color 0.15s;
}

.info-btn:hover {
    color: #6366F1;
}

.editor-wrapper {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-top: 1.5rem;
}

.editor-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
    display: flex;
    gap: 0.25rem;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.action-btn:hover {
    color: #6366F1;
    background: rgba(255, 255, 255, 1);
}

.action-btn:active {
    color: #4F46E5;
}

.action-btn.hidden {
    display: none;
}

.action-btn.primary {
    background: #6366F1;
    color: white;
    padding: 0.5rem;
    width: 34px;
    height: 34px;
}

.action-btn.primary:hover {
    background: #4F46E5;
    color: white;
}

.action-btn.primary:active {
    background: #4338CA;
}

.stats {
    position: absolute;
    top: -1.5rem;
    right: 0;
    color: #999;
    font-size: 0.8rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.editor {
    min-height: 500px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    outline: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.editor::-webkit-scrollbar {
    display: none;
}

.editor:empty::before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}

/* Hint at bottom - matches main site */
.hint {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-style: italic;
    color: #888;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Highlights */
.highlight {
    background: linear-gradient(180deg, transparent 65%, rgba(99, 102, 241, 0.35) 65%);
    cursor: pointer;
    padding: 0 1px;
    border-radius: 2px;
    transition: background 0.15s;
}

.highlight:hover {
    background: rgba(99, 102, 241, 0.25);
}

/* Suggestion popup */
.suggestion-popup {
    position: absolute;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    min-width: 260px;
    max-width: 340px;
    z-index: 1000;
    overflow: hidden;
}

.suggestion-popup.hidden {
    display: none;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f7f7f7;
    border-bottom: 1px solid #eee;
}

.popup-title {
    font-size: 0.9rem;
    color: #555;
}

.popup-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.popup-close:hover {
    color: #333;
}

#popup-suggestions {
    list-style: none;
    padding: 0.5rem;
    margin: 0;
    max-height: 280px;
    overflow-y: auto;
    /* Hide scrollbar but allow scrolling */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

#popup-suggestions::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

#popup-suggestions li {
    margin: 0;
}

.suggestion-btn {
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Source Serif 4', Georgia, serif;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.suggestion-btn:hover {
    background: #f0f0ff;
}

.suggestion-btn .word {
    font-weight: 600;
    color: #6366F1;
}

.suggestion-btn .phrase {
    font-size: 0.85rem;
    color: #888;
    font-style: italic;
    line-height: 1.4;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease-out;
    z-index: 1001;
}

.toast:not(.hidden) {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Info modal */
.info-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    padding: 1rem;
}

.info-modal.hidden {
    display: none;
}

.info-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.info-modal-content::-webkit-scrollbar {
    display: none;
}

.info-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.info-close:hover {
    color: #333;
}

.info-modal-content h2 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    color: #1a1a1a;
    padding-right: 2rem;
}

.info-modal-content h3 {
    font-size: 1.1rem;
    margin: 1.25rem 0 0.5rem;
    color: #333;
}

.info-modal-content p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.info-modal-content ul {
    margin: 0.5rem 0 1rem 1.25rem;
    color: #555;
    line-height: 1.8;
}

.info-modal-content li {
    margin-bottom: 0.25rem;
}

.info-modal-content strong {
    color: #333;
}

.info-modal-content a {
    color: #6366F1;
    text-decoration: none;
}

.info-modal-content a:hover {
    text-decoration: underline;
}

.info-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    text-align: center;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .editor-wrapper {
        margin-top: 3.5rem;
    }

    .editor-actions {
        top: -2.75rem;
        right: 0;
    }

    .stats {
        left: 0;
        right: auto;
    }

    .editor {
        min-height: 400px;
        padding: 1rem;
        font-size: 1rem;
    }

    .suggestion-popup {
        min-width: 220px;
        max-width: 90vw;
    }

    .hint {
        font-size: 0.8rem;
        white-space: normal;
        text-align: center;
        width: 90%;
    }

    .info-modal-content {
        padding: 1.5rem;
        max-height: 85vh;
    }

    .info-modal-content h2 {
        font-size: 1.2rem;
    }

    .info-modal-content h3 {
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
