:root {
    --primary: #E84393;
    --primary-hover: #D6307B;
    --secondary: #FD79A8;
    --accent: #00CEC9;

    --bg-dark: #1A0A14;
    --glass-bg: rgba(45, 15, 30, 0.4);
    --glass-border: rgba(253, 121, 168, 0.15);
    --panel-bg: rgba(30, 10, 20, 0.6);
    --panel-hover: rgba(40, 15, 25, 0.8);

    --text-main: #FDF4F8;
    --text-muted: #E2AABF;
    --error: #FF4757;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius: 16px;
    --radius-sm: 8px;
    --radius-pill: 99px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(232, 67, 147, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(0, 206, 201, 0.05), transparent 25%);
}

.app-container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Header */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.brand svg {
    width: 26px;
    height: 26px;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.badge {
    background: rgba(0, 206, 201, 0.15);
    color: var(--accent);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(0, 206, 201, 0.3);
}

/* Layout Grid */
.converter-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.full-width {
    grid-column: 1 / -1;
}

.panel {
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary);
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.row {
    display: flex;
    gap: 1rem;
}

.flex-1 {
    flex: 1;
}

.premium-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 1rem;
    transition: var(--transition);
}

.premium-input.accent-border {
    border-color: rgba(0, 206, 201, 0.3);
}

.premium-input.accent-border:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 206, 201, 0.15);
}

.premium-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 67, 147, 0.15);
}

.large-input {
    font-size: 1.5rem;
    padding: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.error-msg {
    color: var(--error);
    font-size: 0.8rem;
    font-weight: 500;
    display: none;
    margin-top: 0.25rem;
}

/* Preset Buttons */
.preset-bases {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Result Area */
.result-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 206, 201, 0.4);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    overflow-x: auto;
}

.base-badge {
    position: absolute;
    top: 0.75rem;
    left: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-all;
    margin-top: 1rem;
}

/* Quick Grid */
.simultaneous-bases h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.quick-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.q-base {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.q-val {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Breakdown Panel */
.tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: calc(var(--radius-sm) - 2px);
    transition: var(--transition);
}

.tab.active {
    background: rgba(253, 121, 168, 0.15);
    color: var(--secondary);
}

.breakdown-content {
    min-height: 250px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    line-height: 1.6;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(226, 170, 191, 0.5);
    font-family: var(--font-sans);
    font-style: italic;
}

/* Base Place Value Table */
.pv-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pv-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
}

.pv-table th,
.pv-table td {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem;
    text-align: center;
    border-radius: var(--radius-sm);
    min-width: 60px;
}

.pv-table th {
    color: var(--secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.pv-table td {
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 700;
}

.pv-table tr.powers td {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.pv-table tr.total th {
    text-align: right;
    padding-right: 1rem;
    color: var(--text-main);
    background: transparent;
}

.pv-table tr.total td {
    background: rgba(0, 206, 201, 0.15);
    color: var(--accent);
}

/* Algorithm Steps Line */
.step-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

.step-calc {
    color: var(--text-muted);
    width: 150px;
}

.step-quot {
    color: var(--text-main);
    width: 100px;
}

.step-rem {
    color: var(--primary);
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.ghost {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
}

.ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8125rem;
}

#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(232, 67, 147, 0.4);
    transform: translateY(100px);
    opacity: 0;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

@media (max-width: 900px) {
    .converter-layout {
        grid-template-columns: 1fr;
    }
}