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

:root {
    --accent:        #8B5CF6;
    --accent-hover:  #7C3AED;
    --accent-light:  rgba(139, 92, 246, 0.08);
    --accent-glow:   rgba(139, 92, 246, 0.18);
    --bg:            #f3f4f6;
    --surface:       #ffffff;
    --border:        rgba(0, 0, 0, 0.09);
    --border-focus:  rgba(139, 92, 246, 0.45);
    --text:          #1A1A2E;
    --text-soft:     #6B7280;
    --text-muted:    #9CA3AF;
    --error:         #F43F5E;
    --error-surface: rgba(244, 63, 94, 0.06);
    --error-border:  rgba(244, 63, 94, 0.2);
    --success:       #10B981;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    min-height: 100vh;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

/* ── Container / Popup ──────────────────────────────────────────────────── */

.container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 28px 24px 24px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

header {
    text-align: center;
    padding: 4px 0 6px;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #8B5CF6, #A855F7);
    border-radius: 14px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.logo svg {
    width: 28px;
    height: 28px;
}

h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text);
    margin-bottom: 5px;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-soft);
    line-height: 1.5;
}

/* ── Input ──────────────────────────────────────────────────────────────── */

.input-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 7px 7px 7px 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 10px;
}

#addressInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 0.9rem;
    color: var(--text);
    font-family: var(--font);
    padding: 8px 0;
    min-width: 0;
    caret-color: var(--accent);
}

#addressInput::placeholder {
    color: var(--text-muted);
}

#formatButton {
    flex-shrink: 0;
    position: relative;
    width: 38px;
    height: 38px;
    background: var(--accent);
    border: none;
    border-radius: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.15s, transform 0.12s;
}

#formatButton:hover:not(:disabled) {
    background: var(--accent-hover);
}

#formatButton:active:not(:disabled) {
    transform: scale(0.93);
}

#formatButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-search,
.icon-loading {
    width: 16px;
    height: 16px;
    position: absolute;
    transition: opacity 0.15s;
}

.icon-loading { opacity: 0; }

#formatButton.loading .icon-search  { opacity: 0; }
#formatButton.loading .icon-loading {
    opacity: 1;
    animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ──────────────────────────────────────────────────────────────── */

.error-message {
    display: none;
    background: var(--error-surface);
    border: 1px solid var(--error-border);
    color: var(--error);
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 0.84rem;
    line-height: 1.45;
    animation: slideDown 0.2s ease;
}

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

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Result Cards ───────────────────────────────────────────────────────── */

.results-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    animation: fadeUp 0.3s ease both;
}

.result-card.has-value {
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.08);
}

.result-card.has-error {
    border-color: var(--error-border);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 7px;
}

.card-value {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.55;
    word-break: break-word;
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ── Coordinates ────────────────────────────────────────────────────────── */

.coordinates-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.coord-card {
    position: relative;
    padding-bottom: 44px;
}

.coord-value {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.3px;
}

.copy-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    transition: background 0.13s, border-color 0.13s, color 0.13s, transform 0.12s;
}

.copy-btn:hover:not(:disabled) {
    background: var(--accent-light);
    border-color: rgba(139, 92, 246, 0.3);
    color: var(--accent);
}

.copy-btn:active:not(:disabled) { transform: scale(0.88); }

.copy-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.copy-btn svg {
    width: 12px;
    height: 12px;
    position: absolute;
    transition: opacity 0.15s;
}

.copy-btn .icon-check { opacity: 0; }

.copy-btn.copied {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.copy-btn.copied svg:not(.icon-check) { opacity: 0; }
.copy-btn.copied .icon-check          { opacity: 1; }

/* ── Map ────────────────────────────────────────────────────────────────── */

.map-card { padding: 14px 16px; }

.map-container {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-top: 2px;
}

#map {
    width: 100%;
    height: 270px;
    background: var(--bg);
    position: relative;
}

.map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.map-empty svg {
    width: 28px;
    height: 28px;
    opacity: 0.35;
}

/* ── Shimmer ────────────────────────────────────────────────────────────── */

.shimmer {
    display: block;
    height: 1em;
    width: 65%;
    border-radius: 4px;
    background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

.shimmer.short { width: 45%; }

@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    body {
        padding: 0;
        align-items: flex-start;
    }

    .container {
        max-width: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
        padding: 24px 16px 28px;
        min-height: 100vh;
        backdrop-filter: none;
    }

    #addressInput      { font-size: 16px; }
    .coordinates-row   { grid-template-columns: 1fr; }
    .coord-value       { font-size: 0.95rem; }
    #map               { height: 230px; }
}

@media (max-width: 380px) {
    h1   { font-size: 1.3rem; }
    .logo { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .shimmer, .icon-loading { animation: none; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */

@media print {
    body { background: white; }
    .input-section, .map-card { display: none; }
    .result-card { box-shadow: none; }
}
