:root {
    --bg-dark: #1a1a2e;
    --bg-body: #fafafa;
    --bg-card: #ffffff;
    --accent: #e07a5f;
    --accent-hover: #c9694f;
    --text-primary: #1a1a2e;
    --text-muted: #6b7280;
    --text-light: #ffffff;
    --border: #e5e7eb;
    --star-color: #f59e0b;
    --gold: #fbbf24;
    --silver: #9ca3af;
    --bronze: #d97706;
    --rating-low: #ef4444;
    --rating-mid: #f59e0b;
    --rating-high: #22c55e;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
    --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
}

[hidden] {
    display: none !important;
}

/* Login */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
}

.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

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

.login-card input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    margin-bottom: 1rem;
    font-family: var(--font);
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(224,122,95,0.15);
}

.login-error {
    color: var(--rating-low);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-light);
    width: 100%;
}

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

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    opacity: 0.7;
}

.btn-ghost:hover {
    opacity: 1;
}

/* Header */
.app-header {
    background: var(--bg-dark);
    color: var(--text-light);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-select {
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: var(--text-light);
    font-size: 0.8rem;
    font-family: var(--font);
    cursor: pointer;
}

.filter-select option {
    background: var(--bg-dark);
    color: var(--text-light);
}

/* Main Layout */
.app-main {
    display: grid;
    grid-template-rows: 50vh 1fr;
    height: calc(100vh - 56px);
}

.map-container {
    width: 100%;
    height: 100%;
}

/* Marker hover effect */
.marker-icon {
    transition: transform 0.15s ease, filter 0.15s ease;
}

.marker-icon:hover {
    transform: scale(1.2);
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.25));
}

.restaurant-list {
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

/* Restaurant List */
.location-group {
    margin-bottom: 1.5rem;
}

.location-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.restaurant-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.1s;
    gap: 0.75rem;
}

.restaurant-item:hover {
    background: rgba(224,122,95,0.08);
}

.restaurant-item.highlighted {
    background: rgba(224,122,95,0.15);
}

.restaurant-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.restaurant-cuisine {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.restaurant-rating {
    font-size: 0.85rem;
    white-space: nowrap;
}

.stars {
    color: var(--star-color);
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal[hidden] {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

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

.modal-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* Detail Modal */
.detail-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.15rem;
}

.detail-header .detail-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.detail-label {
    color: var(--text-muted);
    font-weight: 500;
}

/* Visits */
.visits-section h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.visit-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.visit-item:last-child {
    border-bottom: none;
}

.visit-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.visit-comment {
    margin-top: 0.2rem;
    font-style: italic;
    color: var(--text-muted);
}

/* Visit Form */
.visit-form {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.visit-form h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.visit-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.visit-form input,
.visit-form textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.visit-form input:focus,
.visit-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.visit-form textarea {
    resize: vertical;
    min-height: 60px;
}

/* Star Input */
.star-input {
    display: inline-flex;
    gap: 0.15rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.star-input .star {
    font-size: 1.5rem;
    color: var(--border);
    transition: color 0.1s;
    user-select: none;
}

.star-input .star.active,
.star-input .star.hover {
    color: var(--star-color);
}

/* Ranking */
.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-rank {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 2.5rem;
    text-align: center;
}

.ranking-rank.gold { color: var(--gold); }
.ranking-rank.silver { color: var(--silver); }
.ranking-rank.bronze { color: var(--bronze); }

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-weight: 500;
}

.ranking-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.ranking-rating {
    font-size: 0.9rem;
    font-weight: 600;
}

.ranking-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
}

/* Add Form */
.add-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.add-form input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

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

/* Leaflet Tooltip */
.leaflet-tooltip-custom {
    font-family: var(--font);
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tooltip-name {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.tooltip-detail {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 0.5rem 1rem;
    }

    .header-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .app-main {
        grid-template-rows: 40vh 1fr;
    }

    .restaurant-list {
        padding: 0.75rem 1rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}
