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

:root {
    --background: #ffffff;
    --foreground: #1a1a1a;
    --card: #5E5EA1;
    --card-light: #E6E6F8;
    --primary: #d4a855;
    --purple: #5E5EA1;
    --success: #27ae60;
    --error: #e74c3c;
    --warning: #f39c12;
}

html {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    padding-top: 80px;
    margin: 0;
}

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 16px;
}

.tools-row {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-start;
    gap: 20px;
}

@media (max-width: 900px) {
    .tools-row {
        flex-direction: column;
        align-items: center;
    }
    .tools-row > div {
        width: 100%;
    }
    .text-area-container {
        grid-template-columns: 1fr;
    }
}

.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.section-header-bar {
    background: var(--purple);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.subtitle {
    color: #666;
    font-size: 13px;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
}

.card-body {
    padding: 0 20px 20px 20px;
}

.text-area-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .text-area-container {
        grid-template-columns: 1fr;
    }
}

.text-box {
    display: flex;
    flex-direction: column;
}

.text-box label {
    font-weight: 600;
    color: var(--purple);
    margin-bottom: 8px;
    font-size: 14px;
}

textarea {
    width: 100%;
    min-height: 125px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.3s, height 0.1s;
    overflow-y: hidden;
}

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

textarea.result {
    background: #f8fff8;
    border-color: var(--success);
}

.tools-section {
    margin: 20px 0;
}

.tools-label {
    font-weight: 600;
    color: #666;
    margin-bottom: 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.btn {
    display: inline-block;
    padding: 5px 12px;
    background: white;
    color: var(--purple);
    text-decoration: none;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #ccc;
    transition: all 0.2s;
    font-size: 13px;
}
.btn:hover { background: #f0f0f0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.selected, .btn.active {
    background: var(--purple);
    color: white;
    border-color: var(--purple);
}
.btn.selected:hover, .btn.active:hover { background: #4a4a8a; }

.btn.success { background: var(--success); color: white; border-color: var(--success); }
.btn.success:hover { background: #219a52; }

.tool-btn {
    min-width: 80px;
}

.tool-btn.selected {
    background: var(--purple);
    color: white;
    border-color: var(--purple);
}

.style-toggle {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.style-toggle:hover { border-color: var(--purple); }
.style-toggle input { display: none; }
.style-toggle:has(input:checked) {
    background: var(--purple);
    color: white;
    border-color: var(--purple);
}

#status {
    margin: 0;
    text-align: center;
    font-size: 1em;
    min-height: 0;
    color: #666;
}
#status:not(:empty) {
    margin: 10px 0;
    min-height: 24px;
}
#status.error { color: var(--error); }
#status.success { color: var(--success); }
#status .spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid #ddd;
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stats {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 15px 0;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--card-light);
    padding: 10px 18px;
    border-radius: 10px;
    text-align: center;
}

.stat-box .number {
    font-size: 20px;
    font-weight: bold;
    color: var(--purple);
}

.stat-box .label {
    font-size: 11px;
    color: #666;
}

.char-count {
    text-align: right;
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

.action-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.collapse-icon {
    display: inline-block;
    width: 12px;
    font-size: 10px;
    color: var(--purple);
    transition: transform 0.2s;
}

/* Editor container styles */
.editor-container {
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 20px;
    margin-top: 25px;
    margin-bottom: 20px;
    background: #f0f4ff;
}

.input-controls {
    display: flex;
    align-items: center;
    margin-top: 5px;
}

.input-actions,
.output-actions {
    flex: 1;
    text-align: right;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.tone-select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
    cursor: pointer;
}

.optional-label {
    text-align: center;
    font-size: 16px;
    color: #888;
    margin-bottom: 10px;
}

.options-row {
    display: flex;
    gap: 40px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.option-group {
    text-align: center;
}

.option-label {
    font-size: 14px;
    color: #888;
    margin-bottom: 8px;
}

.tone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.modifiers-grid {
    font-size: 11px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px 6px;
    text-align: left;
}

.modifier-label {
    cursor: pointer;
    white-space: nowrap;
}

.info-textarea {
    height: 320px;
    overflow-y: hidden;
    resize: none;
}

.stats {
    display: none;
}

@media (max-width: 768px) {
    .modifiers-grid {
        grid-template-columns: 1fr 1fr;
    }
    .tone-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.promo-section {
    text-align: center;
    padding: 40px 20px;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
    color: #444;
    font-size: 14px;
}
.promo-section h2 {
    color: var(--purple);
    font-size: 22px;
    margin-bottom: 20px;
}
.promo-section h3 {
    color: var(--purple);
    font-size: 18px;
    margin: 25px 0 15px 0;
}
.promo-section p {
    margin: 12px 0;
}
.promo-section .join-btn {
    display: inline-block;
    background: var(--purple);
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    margin: 15px 0;
    transition: background 0.2s;
}
.promo-section .join-btn:hover {
    background: #4a4a8a;
}
.promo-features {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-top: 20px;
    font-weight: 600;
    color: var(--purple);
}

.footer {
    text-align: center;
    padding: 30px 20px;
    font-size: 11px;
    color: #666;
    line-height: 1.8;
    max-width: 800px;
    margin: 0 auto;
}
.footer p {
    margin: 8px 0;
}
.footer a {
    color: var(--purple);
    text-decoration: none;
}
.footer a:hover {
    text-decoration: underline;
}
