:root {
    /* Color Palette - Slate & Indigo Theme */
    --primary-color: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --bg-body: #f1f5f9;
    /* Slate 100 */
    --bg-surface: #ffffff;
    /* White */
    --text-primary: #1e293b;
    /* Slate 800 (High contrast) */
    --text-secondary: #64748b;
    /* Slate 500 */
    --border-color: #cbd5e1;
    /* Slate 300 */
    --input-bg: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.6;
    /* Subtle texture or plain background */
    background-image:
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(219, 39, 119, 0.05) 0px, transparent 50%);
    padding: 2rem 0;
    /* Add padding for vertical spacing */
}

.container {
    width: 95%;
    max-width: 1200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem;
    /* More breathing room */
    box-shadow: var(--shadow-lg);
    margin: 2rem 0;
}

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

h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.highlight {
    color: var(--primary-color);
}

p {
    color: var(--text-secondary);
}

/* --- Input Area --- */
.input-row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 2rem;
    margin-bottom: 3rem;
}

.upload-section {
    flex: 1;
    border: 2px dashed var(--border-color);
    background: #f8fafc;
    /* Lighter than body for contrast inside white container? No, subtly diff */
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-section:hover,
.upload-section.dragover {
    background: #eff6ff;
    /* Very light indigo tint */
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.drop-content svg {
    color: var(--text-secondary);
    /* Muted icon color */
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    transition: color 0.2s;
}

.upload-section:hover .drop-content svg {
    color: var(--primary-color);
}

.drop-content p {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.drop-content .sub-text {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.or-divider {
    display: flex;
    align-items: center;
    font-weight: 700;
    color: var(--border-color);
    font-size: 1rem;
}

.manual-input-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#manual-text {
    width: 100%;
    height: 100%;
    min-height: 180px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

#manual-text:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.text-link-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 0.5rem;
    padding: 0;
    align-self: center;
    transition: color 0.2s;
}

.text-link-btn:hover {
    color: var(--primary-color);
}

/* --- Buttons --- */
.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.secondary-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

/* --- Sections --- */
.hidden {
    display: none !important;
}

.preview-section,
.settings-section,
.result-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Member List --- */
.count-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.instruction-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    text-align: right;
}

.member-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    max-height: 250px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.member-chip {
    background: var(--bg-surface);
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
}

.member-chip:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* --- Settings --- */
.settings-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    align-items: end;
}

.setting-group {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.unit {
    position: absolute;
    right: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
}

/* --- Results --- */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.result-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    background: var(--bg-surface);
    border-radius: var(--border-radius);
    padding: 0 0 1rem 0;
    /* Padding inside round-blocks mainly */
}

.round-block {
    background: var(--bg-surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.round-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
    display: inline-block;
}

.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.group-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.group-name {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.group-members {
    list-style: none;
}

.group-members li {
    font-size: 0.95rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-primary);
}

.group-members li:last-child {
    border-bottom: none;
}

footer {
    display: none;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    /* Slate 900 with opacity */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}

.modal {
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Media Queries */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem;
        width: 100%;
        margin: 0;
        border: none;
        box-shadow: none;
    }

    .input-row {
        flex-direction: column;
        gap: 1.5rem;
    }

    .settings-section {
        grid-template-columns: 1fr;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
}
