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

:root {
    --primary-color: #000;
    --secondary-color: #666;
    --bg-color: #e3dec7;
    --white: #ffffff;
    --border-color: #e0e0e0;
    --hover-color: #333;
    --error-color: #d32f2f;
    --success-color: #28a745;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--primary-color);
    font-size: 16px;
    line-height: 1.5;
}

.main-header {
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.logo:hover {
    opacity: 0.8;
}

.main-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.main-nav a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: var(--hover-color);
}

#userEmail {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 73px);
    padding: 2rem;
}

.main-content {
    display: flex;
    gap: 2rem;
    height: 100%;
}

.sidebar {
    width: 320px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.sidebar-section {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.sidebar-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.search-section {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    align-items: stretch;
    width: 100%;
}

#searchInput {
    flex: 1;
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

#searchBtn {
    flex-shrink: 0;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.map-type-toggle {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.map-type-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--white);
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.map-type-btn i {
    font-size: 1.25rem;
}

.map-type-btn:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

.map-type-btn.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.map-type-btn.active:hover {
    background: var(--hover-color);
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

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

.btn-secondary {
    background: var(--white);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-color);
}

.btn-danger {
    background: var(--error-color);
    color: var(--white);
}

.btn-danger:hover {
    background: #b71c1c;
}

.btn-full {
    width: 100%;
}

.upload-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--white);
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 500;
    width: 100%;
}

.upload-button:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

.upload-button i {
    font-size: 1.1rem;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.position-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.position-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.move-btn {
    width: 45px;
    height: 45px;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--primary-color);
    border-radius: 6px;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.move-btn i {
    font-size: 1.25rem;
}

.move-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

#moveCenter {
    width: 50px;
}

#moveCenter i {
    font-size: 1rem;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-group input[type="range"] {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    border: 2px solid #000;
    outline: none;
    -webkit-appearance: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.slider-group span {
    min-width: 50px;
    font-weight: 500;
    color: var(--primary-color);
    font-size: 0.9rem;
    text-align: right;
}

.control-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.control-actions button {
    width: 100%;
}

.map-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    min-width: 0;
}

#map {
    width: 100%;
    height: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--white);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-large {
    max-width: 600px;
}

.close-modal {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 1.25rem;
    color: var(--secondary-color);
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-modal:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.modal-subtitle {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
}

.modal-subtitle a {
    color: var(--primary-color);
    text-decoration: underline;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input[readonly] {
    background: var(--bg-color);
    cursor: not-allowed;
}

.form-group input+button {
    margin-top: 0.75rem;
}

.form-group .input-with-button {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.form-group .input-with-button input {
    flex: 1;
}

.form-group .input-with-button button {
    margin-top: 0;
    white-space: nowrap;
}

.success-message {
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
    display: none;
}

.success-message.show {
    display: block;
}

.error-message {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 1rem;
    display: none;
}

.error-message.show {
    display: block;
}

.maps-list {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.map-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    gap: 1rem;
    align-items: center;
    transition: all 0.2s;
}

.map-item:hover {
    background: var(--bg-color);
}

.map-preview {
    width: 120px;
    height: 120px;
    min-width: 120px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.map-item-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.map-item-info p {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.map-item-actions {
    display: flex;
    gap: 0.5rem;
}

.map-item-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
    }

    #map {
        aspect-ratio: 1;
        max-height: 50vh;
    }

    .container {
        padding: 1rem;
    }
}