:root {
    --bg-dark: #0a0a0e;
    --bg-panel: rgba(255, 255, 255, 0.03);
    --bg-panel-hover: rgba(255, 255, 255, 0.05);
    --primary: #00f260;
    /* Neon Green */
    --primary-dim: rgba(0, 242, 96, 0.1);
    --secondary: #0575e6;
    /* Blue */
    --accent: #ff4081;
    /* Pink */
    --text-main: #ffffff;
    --text-muted: #8b9bb4;
    --border: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.08);
    --blur: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* Dynamic Background */
.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 50%, rgba(5, 117, 230, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(0, 242, 96, 0.05), transparent 25%);
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Typography & Header */
.app-header {
    text-align: center;
    margin-bottom: 1rem;
    animation: fadeInDown 0.8s ease;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: var(--primary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.app-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Calculator Tabs */
.mode-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--bg-panel-hover);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tab-btn:hover:not(.active) {
    color: #fff;
}

/* Inputs */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.premium-select,
input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 1rem;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: 'Outfit', sans-serif;
}

.premium-select:focus,
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-dim);
}

/* Time Inputs Layout */
.time-inputs {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.time-field {
    position: relative;
    flex: 1;
}

.time-field input {
    padding-right: 2.5rem;
    /* Space for unit */
    text-align: center;
}

.time-field span {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.input-row {
    display: flex;
    gap: 0.8rem;
}

.custom-input-wrapper {
    flex: 1;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.custom-input-wrapper .unit {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Result Display */
.result-display {
    margin-top: 2.5rem;
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(0, 242, 96, 0.05), rgba(5, 117, 230, 0.05));
    border-radius: 16px;
    border: 1px solid rgba(0, 242, 96, 0.1);
}

.result-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.result-value {
    font-size: 3.5rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(0, 242, 96, 0.3);
    line-height: 1;
}

.result-unit {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-btn {
    flex: 1;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: filter 0.3s, transform 0.2s, background 0.3s;
}

.action-btn.primary {
    background: var(--primary);
    color: #000;
}

.action-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.action-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

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

/* Splits Table */
#splits-card {
    display: none;
    /* Hidden by default until calculated */
    animation: slideUp 0.5s ease;
}

#splits-card.visible {
    display: block;
}

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

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.split-controls button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.split-controls button.active {
    background: var(--text-main);
    color: #000;
    border-color: var(--text-main);
}

.table-container {
    max-height: 400px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
}

td {
    font-family: 'Outfit', monospace;
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

.app-footer {
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

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

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .result-value {
        font-size: 2.8rem;
    }
}

/* Footer Link Button */
.footer-link-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.footer-link-btn:hover {
    opacity: 1;
    color: var(--primary);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    position: relative;
    background: rgba(20, 20, 30, 0.8);
    /* Darker background for modal */
    animation: slideUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #fff;
}

.modal-content h2 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.modal-content textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 1rem;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    resize: vertical;
    font-family: inherit;
}

.modal-content textarea:focus {
    border-color: var(--primary);
}

.status-msg {
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
    min-height: 1.2em;
}

.status-msg.success {
    color: var(--primary);
}

.status-msg.error {
    color: var(--accent);
}